Hello, Robert!

This looks like what I need!

Now I can remove bind() calls and just do:

    @Contribute(WorkerManager.class)

    public static void defineWorkers(Configuration<Worker> conf) {

        conf.addInstance(GitPullWorker.class);

        conf.addInstance(GitCloneWorker.class);

    }

And I even don't need the buildWorkerManager method, since I can just

binder.bind(WorkerManager.class, WorkerManagerImpl.class);

and get all workers in constructor.

    public WorkerManagerImpl(Collection<Worker> workers) {

        this.workers = new ArrayList<Worker>();

        for (Worker worker : workers) {

            registerWorker(worker);

        }

    }

This is cool, thanks!

On Thu, Aug 9, 2012 at 10:05 PM, Robert Zeigler <robert.zeig...@roxanemy.com
> wrote:

> Hi Dimitry.
>
> What you need is to contribute your workers to the worker manager.
> Something like:
>
> contributeWorkerManager(Configuration<Worker> conf) {
>   conf.add(...)
>   conf.add(...)
> }
>
> Now, the useful thing about this is that any module that is used in your
> app that has a "contributeWorkerManager" will be called and all of the
> conf.adds will be conglomerated into the single collection which will be
> passed to your buildWorerManager method.
>
> So the missing piece for you is just the contributeWorkerManager. Or you
> could use annotations for better type-safety:
>
> @Contribute(WorkerManager.class)
> configWorkerManager(Configuration<Worker> conf) {
>   ...
> }
>
> Robert
>
> On Aug 9, 2012, at 8/912:57 PM , Dmitry Gusev wrote
>
> > Yes, thanks for correction. But you get the idea?
> >
> > How can I fix the signature to get all the implementations?
> >
> > On Thu, Aug 9, 2012 at 9:52 PM, Thiago H de Paula Figueiredo <
> > thiag...@gmail.com> wrote:
> >
> >> On Thu, 09 Aug 2012 14:38:25 -0300, Dmitry Gusev <
> dmitry.gu...@gmail.com>
> >> wrote:
> >>
> >> Hi,
> >>>
> >>
> >> Hi!
> >>
> >>
> >> But I'd like to inject them all at once like this:
> >>>
> >>>    public static WorkerManager buildWorkerManager(Collection<**Worker>
> >>> workers) {
> >>>
> >>
> >> This isn't dependency injection, it's receiving distributed
> configuration,
> >> hence the empty collection.
> >>
> >> --
> >> Thiago H. de Paula Figueiredo
> >>
> >>
> ------------------------------**------------------------------**---------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<
> users-unsubscr...@tapestry.apache.org>
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > Dmitry Gusev
> >
> > AnjLab Team
> > http://anjlab.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com

Reply via email to