GuptaJi,

What does your implementation of your Annotation look like?  The javadoc has
a unique contract that you might want to browse to be sure your class is in
accord w/ it.

-Fred

On Tue, Apr 20, 2010 at 12:05 AM, GuptaJi <[email protected]> wrote:

> Hi Fred,
>
> I tried what you had suggested but still no luck.  I am trying to use
> the method:
> MapBinder.newMapBinder(Binder binder, Class<K> keyType, Class<V>
> valueType, Annotation annotation) ;
>
> If I pass the AnnotationImpl object as the fourth parameter, the map
> inject elsewhere contains no value.  However, if I modify the
> Annotation to be without value, it works fine. (I did remove the value
> method from AnnotationImpl and at the point of injection).
>
> Any ideas on what I might be doing wrong?
>
> Thanks,
> GuptaJi
>
>
>
>
> On Apr 19, 7:58 pm, Fred Faber <[email protected]> wrote:
> > Basically you need to be able to reference an instance of your annotation
> in
> > your binding.
> >
> > You can do this by implementing your annotation:
> >
> > class AnnotationNameImpl implements @AnnotationName {
> >  ....
> >
> > }
> >
> > and then you can instantiate an instance in your binding:
> >
> > bind(...).annotatedWith(new AnnotationNameImpl(AnEnum.someValue));
> >
> > I bet you could also develop a simple service that would allow you do do:
> >
> > class YourModule {
> >   ....
> >
> >  @AnnotationName(AnEnum.someValue)
> >  private static final String annotatedString = null;
> >
> >   protected void configure() {
> >      Annotation annotation =
> >          AnnotationReader.readAnnotationFrom(getClass(),
> "annotatedString");
> >      bind(....)
> >   }
> >
> > }
> >
> > -Fred
> >
> >
> >
> >
> >
> > On Mon, Apr 19, 2010 at 11:44 AM, GuptaJi <[email protected]> wrote:
> > > Hi,
> >
> > > I am relatively new to Guice but I have read the documentation well.
> > > I am looking for a way to create a map binder in my module with an
> > > annotation.  Creating with an annotation is easy enough by supplying
> > > AnnotationName.class as the fourth parameter in newBinder().  My
> > > requirements need the annotation to be supplied with a value so that
> > > it is possible to use something like:
> > >  @AnnotationName(AnEnum.someValue).
> >
> > > Is it even possible to do something like what I am describing?
> >
> > > Thanks a lot for your help.
> >
> > > Cheers,
> > > GuptaJi
> >
> > > --
> > > 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]<google-guice%[email protected]>
> <google-guice%2bunsubscr...@google­groups.com>
> > > .
> > > 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]<google-guice%[email protected]>
> .
> > For more options, visit this group athttp://
> groups.google.com/group/google-guice?hl=en.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> 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]<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.

Reply via email to