Hi there,
I'm fairly new to Spring..
I have a service POJO that relies on what I call an AdapterFactory (essentially a driver factory).
My CollectionAdapterFactory maintains a list of adapter instances. Currently the factory is initialized with repeated calls to registerAdapter() for each type of adapter. Application code will later call newCollectionAdapter when it needs to work with a specific collection.Code:public AccessServiceImpl(CollectionAdapterFactory adapterFactory) {}
I can't work out how to convert CollectionAdapterFactory to Spring or refactor the code so it fits into Spring more easily. What I think I want is some way to configure the list of all adapters in the application context and then call setAdaptersList() on the adapterFactory. Or else I want to simply register each adapter as a bean with spring.. And then have the CollectionAdapterFactory be spring-aware and able to interogate the context itself inside the newCollectionAdapter() call.Code:public CollectionAdapterFactory() { super(); } public void registerAdapter(String collectionType, ICollectionAdapter adapter) { if (adapter == null || collectionType == null) throw new IllegalArgumentException(); adapters.put(collectionType, adapter); } public ICollectionAdapter newCollectionAdapter( Collection collection) {...}
Can someone point me in the right direction?
Regards,
Damon.


Reply With Quote