Hi,
I have different loaders which share a common functionality, implemented in the ExchangerLoader:
Now I've specific loaders:Code:public abstract class ExchangerLoader { // Declarations protected IMapper mapper; protected IDocumentHandler docHandler; protected String initialProcess = "AKT"; /* * DEPENDENCY INJECTIONS */ public void setDocumentHandler(IDocumentHandler docHandler) { this.docHandler = docHandler; } public void setInitialProcess(String process) { this.initialProcess = process; } public void setDataMapper(IMapper mapper) { this.mapper = mapper; } //Some shared methods, which are used by all loaders //This class must be implement by all derived classes public abstract String loadData(String docId, String folder, String type, String viewField);
- ViewLoader
- ObjectLoader
- TreeLoader
These loaders extend the ExchangeLoader and implements the loadData-Method. The specific loaders also access methods from the ExchangerLoader.
The configured loaders are now injected to a service which decides what loader should be used. I think this is an implementation of the Strategy Design pattern. Now my question, as you can see on the declaration above all my loaders need the documentHandler and mapperService. Is there a better way to configure these loaders?Code:<!-- LOADERS --> <bean id="viewLoader" class="com.mycomp.exchanger.loader.ViewLoader"> <property name="documentHandler"> <ref bean="documentHandler"/> </property> <property name="dataMapper"> <ref bean="mapperService"/> </property> </bean> <bean id="objectLoader" class="com.mycomp.exchanger.loader.ObjectLoader"> <property name="documentHandler"> <ref bean="documentHandler"/> </property> <property name="dataMapper"> <ref bean="mapperService"/> </property> </bean> <bean id="treeLoader" class="com.mycomp.exchanger.loader.TreeLoader"> <property name="documentHandler"> <ref bean="documentHandler"/> </property> <property name="dataMapper"> <ref bean="mapperService"/> </property> </bean>
thank you for your advices
markus


Reply With Quote
for example: