Hi Fred.
The problem is, that is too static for me.
I have a series of customers / users sharing 1 database.
each users have different settings (the constants).
depending on which constant they have saved in the database, I wish get
a different implementation.
What I desire is.
String myConstant = "SOME_CONSTANT"; //or "SOME_OTHER_CONSTANT";
Provider<GlobalSearchController> p...init provider
GlobalSearchController controller = p.get()@Named(myConstant );
But the Provider doesn't seem to envisage the use of the @Named parameter.
I assume I've just missed the point of it all.
I want to bind at run time via a variable.
Inject wants me to define my binding conditions in the module?
Thanks
Martin
On 20.05.2011 00:51, Fred Faber wrote:
Are you looking for:
@Inject @Named("SOME_CONSTANT")
GlobalSearchController globalSearchController;
Fred
On Thu, May 19, 2011 at 5:39 PM, Marty
<[email protected]
<mailto:[email protected]>> wrote:
Hi Guice users.
I'm rather new to Guice, but I'm really enjoying it.
I have a fairly simple problem, but I can't figure out how to solve
this.
In my application I have some variables, which I want to use to decide
which instance to create.
e.g.
my modules
bind(GlobalSearchController.class)
.annotatedWith(Names.named("SOME_CONSTANT"))
.to(GlobalSearchControllerImpl.class);
bind(GlobalSearchController.class)
.annotatedWith(Names.named("SOME_OTHER_CONSTANT"))
.to(GlobalSearchControllerOtherImpl.class);
...
so then later in my code has
String = "SOME_CONSTANT";
now how do I get Guice to give me an instance which matches to my
constant?
write now I have written a provider, which does IF/ELSE before
creating an instance with new.
Its not really now I envisaged solving this problem.
Thanks in advance
Martin
--
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]
<mailto:[email protected]>.
To unsubscribe from this group, send email to
[email protected]
<mailto:google-guice%[email protected]>.
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.
--
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.
--
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.