On May 10, 2011, at 5:03 PM, Vincent Massol wrote:

> Hi,
> 
> I'd like to commit @Inject injection of Loggers at the same time as I do the 
> switch to SLF4J/Logback (I have it mostly done on my machine). 
> 
> The idea is to move from:
> 
> public MyComponent implements LogEnabled, MyComponentRole
> {
> ...
> }
> 
> to:
> 
> public MyComponent implements MyComponentRole
> {
>  @Inject
>  private Logger logger;
> ...
> }
> 
> Rationale:
> * More consistent with how we inject dependencies
> * Makes it easier to move to another DI framework later on (CDI, Guice, etc) 
> since the way to implement this with them is to use the JSR299 @Producer 
> annotation on a class that produces Loggers.

For the record, here's how it's done with our DI fwk:

* Guice: http://glauche.de/2009/08/24/logging-with-slf4j-and-guice/
* Weld: http://docs.jboss.org/weld/reference/1.0.0/en-US/html/extensions.html
* CDI in general: 
http://rbergerpa.blogspot.com/2011/02/dependency-injection-and-logging.html

To summarize:
* Guice: Based on TypeListeners
* CDI: Based on @Produces

Thanks
-Vincent

> * Allows to keep the current logging behavior unchanged for backward 
> compatibility (we juste deprecate it).
> 
> WDYT?
> 
> Thanks
> -Vincent
> 

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to