You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Thorsten Scherler <sc...@gmail.com> on 2011/07/13 20:12:08 UTC
@Logger in RestController or independent?
Hi all,
I developed a small @Logger annotation for a customer project which I
would like to contribute. The question is ATM what is the best way?
ATM I have implemented the annotation based on an independent
BeanPostProcessor which I then invoke with adding
<!-- logger annotation implementation -->
<bean class="org.apache.cocoon.common.LoggerInjector"/>
Basically the class is doing:
if (field.getAnnotation(Logger.class) != null) {
Log log = LogFactory.getLog(bean.getClass());
field.set(bean, log);
}
I saw SpringRESTController and I wonder whether we should add it there
in getController as populateLogger(configuration, unpackedController,
annotatedFields);
or to leave it independent to allow usages as well in REST independent
components such as generators, etc.
WDYT?
salu2
--
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/
Re: @Logger in RestController or independent?
Posted by Thorsten Scherler <sc...@gmail.com>.
On Fri, 2011-07-15 at 16:00 +0200, Reinhard Pötz wrote:
> On 07/13/2011 08:12 PM, Thorsten Scherler wrote:
> > Hi all,
> >
> > I developed a small @Logger annotation for a customer project which I
> > would like to contribute. The question is ATM what is the best way?
> >
> > ATM I have implemented the annotation based on an independent
> > BeanPostProcessor which I then invoke with adding
> > <!-- logger annotation implementation -->
> > <bean class="org.apache.cocoon.common.LoggerInjector"/>
> >
> > Basically the class is doing:
> > if (field.getAnnotation(Logger.class) != null) {
> > Log log = LogFactory.getLog(bean.getClass());
> > field.set(bean, log);
> > }
> >
> > I saw SpringRESTController and I wonder whether we should add it there
> > in getController as populateLogger(configuration, unpackedController,
> > annotatedFields);
> >
> > or to leave it independent to allow usages as well in REST independent
> > components such as generators, etc.
>
> Injection logger instances is already supported. You can use the
> org.apache.cocoon.rest.controller.annotation.Inject annotation on a
> field of type org.apache.commons.logging.Log.
Hmm but how I do get then the instance of
LogFactory.getLog(bean.getClass()); injected?
The javadoc is not very clear for @interface Inject, what is the
difference from @autowired?
salu2
>
> BTW, in the beta phase we should move our codebase to slf4j ...
>
--
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/
Re: @Logger in RestController or independent?
Posted by Reinhard Pötz <re...@apache.org>.
On 07/13/2011 08:12 PM, Thorsten Scherler wrote:
> Hi all,
>
> I developed a small @Logger annotation for a customer project which I
> would like to contribute. The question is ATM what is the best way?
>
> ATM I have implemented the annotation based on an independent
> BeanPostProcessor which I then invoke with adding
> <!-- logger annotation implementation -->
> <bean class="org.apache.cocoon.common.LoggerInjector"/>
>
> Basically the class is doing:
> if (field.getAnnotation(Logger.class) != null) {
> Log log = LogFactory.getLog(bean.getClass());
> field.set(bean, log);
> }
>
> I saw SpringRESTController and I wonder whether we should add it there
> in getController as populateLogger(configuration, unpackedController,
> annotatedFields);
>
> or to leave it independent to allow usages as well in REST independent
> components such as generators, etc.
Injection logger instances is already supported. You can use the
org.apache.cocoon.rest.controller.annotation.Inject annotation on a
field of type org.apache.commons.logging.Log.
BTW, in the beta phase we should move our codebase to slf4j ...
--
Reinhard Pötz Founder & Managing Director, Indoqa and Deepsearch
http://www.indoqa.com/people/reinhard-poetz.html
Member of the Apache Software Foundation
Apache Cocoon Committer, PMC member reinhard@apache.org
________________________________________________________________________
Furthermore, I think Oracle has to honor the JSPA agreement.
http://s.apache.org/JCPIsDead http://s.apache.org/tck-trap