I'll post that as a separate thread to make it easier to find later. Norman Franke Answering Service for Directors, Inc. www.myasd.com
On Aug 9, 2012, at 2:08 PM, Dmitry Gusev wrote: > Hello, Norman! > > Sure, I'd like to see your approach. > > On Thu, Aug 9, 2012 at 10:02 PM, Norman Franke <nor...@myasd.com> wrote: > >> If all the workers are in the same package you could make/Google a >> PackageEnumerator class that uses a ClassLoader to get all of the classes >> in the package, and then register those. I do this with my DAOs interface >> and implementations to keep me from having to remember to add them to the >> AppModule. >> >> I can dig up some code if you are interested and assuming you can get an >> instance of the service via the class. >> >> Norman Franke >> Answering Service for Directors, Inc. >> www.myasd.com >> >> >> >> On Aug 9, 2012, at 1:38 PM, Dmitry Gusev wrote: >> >>> Hi, >>> >>> I have several implementations of Worker interface: >>> >>> binder.bind(Worker.class, GitCloneWorker.class).withId(GIT_CLONE); >>> >>> binder.bind(Worker.class, GitPullWorker.class).withId(GIT_PULL); >>> >>> Right now I'm doing this: >>> >>> public static WorkerManager buildWorkerManager( >>> >>> @InjectService(GIT_CLONE) Worker gitCloneWorker, >>> >>> @InjectService(GIT_PULL) Worker gitPullWorker) { >>> >>> WorkerManager workerManager = new WorkerManagerImpl(); >>> >>> workerManager.registerWorker(gitCloneWorker); >>> >>> workerManager.registerWorker(gitPullWorker); >>> >>> return workerManager; >>> >>> } >>> >>> But I'd like to inject them all at once like this: >>> >>> public static WorkerManager buildWorkerManager(Collection<Worker> >>> workers) { >>> >>> WorkerManager workerManager = new WorkerManagerImpl(); >>> >>> for (Worker worker : workers) { >>> >>> workerManager.registerWorker(worker); >>> >>> } >>> >>> return workerManager; >>> >>> } >>> >>> This code will even run, but workers would be an empty collection. >>> >>> Is it possible? >>> >>> -- >>> Dmitry Gusev >>> >>> AnjLab Team >>> http://anjlab.com >> >> > > > -- > Dmitry Gusev > > AnjLab Team > http://anjlab.com