Maybe you can restructure your program differently. My first thought was why use Strings to identify things?
This implies clients know ahead of time which Strings to look for. Why don't you use interfaces instead? Imho the whole point of Guice is that Class definition itself serves as injection identity (qualifier) with optional annotation. It looks to me as if you want to do some lightweight pluggable stuff. I'd have ServiceX-API.jar ServiceX-impl.jar (has ServiceLoader entries for Guice Module) ..... have clients of ServiceY depend on ServiceX-API.jar and put proper require bindings in ServiceY-impl. In runtime just get all Guice Modules of the various Service_-Impls via ServiceLoader and register them. Using something like that it just works OOTB hassle free. Cheers Alen On Feb 19, 9:01 pm, Mark Addleman <[email protected]> wrote: > I'd like to gain access to an annotation at the injection point within a > provider. The idea is that at startup, clients dynamically register names > of objects. After startup, clients can gain access to these objects using > the @Named annotation. The provider would use the value of @Named to find > the named object. > > Example client code: > @Inject > public Constructor(@Named("my-object-name") SomeClass object) {...} > > Provider code that I'd like to write: > public ObjectProvider { > public SomeClass get(Annotation a) { > // lookup value of a and return it > } > > } > > How can I accomplish this? I'm sure I'm missing something obvious in the > docs. > > Thanks -- 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.
