Hi,

perhaps it's a stupid question, but I'm a guice-beginner. ;)

I've got a Class A which has a loop which produces some Tasks (Classes of type TaskImpl).
The loop looks like:

while(condition) {
    Task t = taskFactory.createTask();
    taskProcessor.useTask(t);
}

The taskFactory is a standard bean which is injected using Guice. But within this bean I've got to do the injection for each Task programmatically. Is there any way to use
Guice to do the injection for this beans?

The createTask() method is looking like this:

public Task createTask() {
    Task t = new TaskImpl();
    t.setSomePropery1(prop1);
    t.setSomePropery2(prop2);
    t.setSomePropery3(prop3);
}
prop1-3 are injected in the TaskFactory using Guice now it would be great if I could let guice doing the job to inject them in the Task t and avoid these classes in the factory.

I had thought about using Guice.getInjector(..) but I wouldn't use it because of the unwanted
dependency in the Class.

Within the descripion of guice I've read that it (guice) should avoid the reoccuring task of writing factories so I would expect that there might be a elegant solution of this case.

Thanks for your help.

Marc

--
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to