users@jersey.java.net

Re: [Jersey] Guice access to Jersey-created objects

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 26 Aug 2009 16:24:18 +0200

On Aug 17, 2009, at 1:09 PM, James Strachan wrote:
>>
>> Hmm... perhaps even better one could inject the contextual
>> information for a
>> provider e.g.:
>>
>> @Provides
>> public Logger providerLogger(InjectionContext ic) {
>> return Logger.getLogger(ic.getTarget());
>> }
>
> Agreed! I like the idea of just passing the binding annotation or the
> injection context as a parameter to @Provides methods. (I really like
> @Provides methods!)
>

I was just reading 299 and it can do this, and it presented the logger
example we have been discussing :-)

   class Loggers {
     @Produces Logger getLogger(InjectionPoint injectionPoint) {
       return
Logger
.getLogger
( injectionPoint.getMember().getDeclaringClass().getSimpleName() );
     }
   }

   @SessionScoped
   public class Permissions {
     @Inject Logger log;
     ...
   }

Paul.