Is there any prettier way of doing this? Having to manually construct
SomeObject just to be able to use it as a listener:

@Provides
@Singleton
public SomeObject getSomeObject(DependencyA a, DependencyB b,
ListenerDispatcher ld) {
SomeObject someObject = new SomeObject(a, b);
ld.addListener(someObject);
return someObject;
}

Where SomeObject can be constructed without a provider with just a
regular bind. There is quite some boilerplate to write for this, even
more if SomeObject has more dependencies. One solution that comes in
mind is that I could use a binding annotation + @Provides like this:

@Provides
@Singleton
@Named("someTag")
public SomeObject getSomeObject(SomeObject someObject,
ListenerDispatcher ld) {
ld.addListener(someObject);
return someObject;
}

I'm not sure if I'm fully happy to add the need of always using an
annotation everywhere where I want to use SomeObject tho. Is there
some prettier way to do this?
--~--~---------~--~----~------------~-------~--~----~
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