Announcement Announcement Module
Collapse
No announcement yet.
Strategy for implementing a driver factory.. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Strategy for implementing a driver factory..

    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).

    Code:
        public AccessServiceImpl(CollectionAdapterFactory adapterFactory) {}
    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 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) {...}
    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.


    Can someone point me in the right direction?

    Regards,
    Damon.

  • #2
    I'm not sure I know what you want to do but it is easy with the List tag to create a collection inside you context xml. There are examples in the reference. Hope that helps some.

    Jeff

    Comment

    Working...
    X