The MICR Tools facilities can be easily configured within Spring's XML configuration file. In fact, MICR Tools was designed from the ground-up to be IoC "aware", with dependencies easily injected and coded to the interface.
The following snippet of XML shows an example of Spring bean configuration for the MICR Parser facility:
<beans> ... <bean id="auxOnUsVal" class="com.minderupt.micrtools.validator.AuxOnUsFieldValidator" /> <bean id="micrParser" class="com.minderupt.micrtools.parser.MICRParserImpl"> <property name="transitSymbol" value="d" /> <property name="onUsSymbol" value="c" /> <property name="amountSymbol" value="b" /> <property name="dashSymbol" value="-" /> <property name="auxOnUsFieldValidator"> <ref bean="auxOnUsVal" /> </property> </bean> <bean id="serviceObject" class="test.ServiceObject"> <property name="micrParser"> <ref bean="micrParser" /> </property> </bean> ... </beans>
The ServiceObject code would look like this, with the MICRParser injected using Spring:
package test; import com.minderupt.micrtools.MICRParser; import com.minderupt.micrtools.data.MICR; public class ServiceObject { private MICRParser parser; /* IoC methods */ public void setMicrParser(MICRParser parser) { this.parser = parser; } public MICRParser getMicrParser() { return(this.parser); } public void someMethod() { String micr = "c1234567c d026010757d 987654c"; MICR parsedMicr = null; try { parsedMicr = getMicrParser().parseMICR(micr); } catch(Exception e) { // handle error } } }
TBD Spring Config