Results 1 to 2 of 2

Thread: Strategy for implementing a driver factory..

  1. #1
    Join Date
    Jul 2005
    Posts
    11

    Default 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. #2

    Default

    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

Similar Threads

  1. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  2. Replies: 1
    Last Post: Jul 28th, 2005, 05:08 PM
  3. Question about bean factory usage
    By T in forum Container
    Replies: 6
    Last Post: Jul 1st, 2005, 01:04 PM
  4. Stack Overflow
    By rayho222 in forum Container
    Replies: 6
    Last Post: May 17th, 2005, 03:42 AM
  5. Replies: 13
    Last Post: Dec 7th, 2004, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •