Hi,

I've been reading quite a lot of documentation around named bindings, 
factorymodulebuilder, mapped bindings and it is still not clear if I can 
achieve something along the following lines.

For example I want a Factory to be able to look up different services at 
runtime based a key. In spring you can do something like this

public class ServiceFactory {

        private Map<String, Service> services = new HashMap<String, Service>();
        
        @Autowired
        private Map<String, Service> mappedServices;
        
        public void init() {
                services.put(SitemapListService.class.getName(), new 
SitemapListService());
                services.put(SitemapService.class.getName(), new 
SitemapService());
                services.put(SitemapExcelService.class.getName(), new 
SitemapExcelService());
                services.put(CategoryService.class.getName(), new 
CategoryService());
                services.put(AdminDirectoryListService.class.getName(), new 
AdminDirectoryListService());
                services.put(CompositeConceptsService.class.getName(), new 
CompositeConceptsService());
        }
        
        public Service getService(String key) {
                Service service = services.get(key);
                if (service == null) {
                        throw new IllegalArgumentException("Unknown service 
type: " + key);
                }
                return service; 
        }
}


Then for example the service name could be configured in a configuration file 
or calculated at runtime? How can I achieve something similar with Guice?


Thanks

Jon

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to