You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Nishant Chandra <ni...@gmail.com> on 2009/09/21 16:18:43 UTC

Filters

HI,

I am looking for advice on using filters for my REST based
application. I want to log start, end time and HTTP status code.
I read about CXF and JAXRS filters. I am not sure how this can be
achieved? Will servlet filter be a good idea?

Thanks,
Nishant

Re: Filters

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi

At the moment the injection is not supported for RequestHandler and ResponseHandler only - I can't recall why but there was some 
limitation initially which prevented me from implementing it. For 2.2.4 it will work, it's a one liner fix.
In meantime, please use CXF-specific API, in this case

HttpServletRequest request = (HttpServletRequest)message.get(AbstractHttpDestination.HTTP_REQUEST);

(this way you can also get to it from CXF interceptors)

or

HttpHeaders headers = new HttpHeadersImpl(m);

cheers, Sergey

----- Original Message ----- 
From: "Linus Kamb" <ka...@emsc-csem.org>
To: <us...@cxf.apache.org>
Sent: Tuesday, September 22, 2009 8:22 AM
Subject: RE: Filters


A question related to this:

I have the HttpRequest injected into my RequestHandler as a @Resource, and
it is not null, but accessing any of the values throws a NPE.

So I'm guessing trying to access the http request info in an interceptor is
an inappropriate approach.  What would be the more appropriate approach?
CXF Filter? Servlet Filter?

Thanks,
Linus


-----Message d'origine-----
De : Sergey Beryozkin [mailto:sberyozk@progress.com]
Envoyé : Monday, September 21, 2009 7:03 PM
À : users@cxf.apache.org
Objet : Re: Filters

Hi

Some information is here :
http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Logging

and

http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Filters

You can register a logging feature as shown in the docs. You can register
CXf JAX-RS filters as other JAX-RS providers.
We don't have a ServletFilter yet which can do logging - but may be we
should also ship the one with the CXF HTTP transport module -
I'll add a task for it.

cheers, Sergey

----- Original Message ----- 
From: "Nishant Chandra" <ni...@gmail.com>
To: <us...@cxf.apache.org>
Sent: Monday, September 21, 2009 3:18 PM
Subject: Filters


> HI,
>
> I am looking for advice on using filters for my REST based
> application. I want to log start, end time and HTTP status code.
> I read about CXF and JAXRS filters. I am not sure how this can be
> achieved? Will servlet filter be a good idea?
>
> Thanks,
> Nishant





RE: Filters

Posted by Linus Kamb <ka...@emsc-csem.org>.
A question related to this:

I have the HttpRequest injected into my RequestHandler as a @Resource, and
it is not null, but accessing any of the values throws a NPE.

So I'm guessing trying to access the http request info in an interceptor is
an inappropriate approach.  What would be the more appropriate approach?
CXF Filter? Servlet Filter?

Thanks,
Linus


-----Message d'origine-----
De : Sergey Beryozkin [mailto:sberyozk@progress.com] 
Envoyé : Monday, September 21, 2009 7:03 PM
À : users@cxf.apache.org
Objet : Re: Filters

Hi

Some information is here :
http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Logging

and

http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Filters

You can register a logging feature as shown in the docs. You can register
CXf JAX-RS filters as other JAX-RS providers.
We don't have a ServletFilter yet which can do logging - but may be we
should also ship the one with the CXF HTTP transport module -
I'll add a task for it.

cheers, Sergey

----- Original Message ----- 
From: "Nishant Chandra" <ni...@gmail.com>
To: <us...@cxf.apache.org>
Sent: Monday, September 21, 2009 3:18 PM
Subject: Filters


> HI,
>
> I am looking for advice on using filters for my REST based
> application. I want to log start, end time and HTTP status code.
> I read about CXF and JAXRS filters. I am not sure how this can be
> achieved? Will servlet filter be a good idea?
>
> Thanks,
> Nishant





Re: Filters

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi

Some information is here :
http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Logging

and

http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Filters

You can register a logging feature as shown in the docs. You can register CXf JAX-RS filters as other JAX-RS providers.
We don't have a ServletFilter yet which can do logging - but may be we should also ship the one with the CXF HTTP transport module -
I'll add a task for it.

cheers, Sergey

----- Original Message ----- 
From: "Nishant Chandra" <ni...@gmail.com>
To: <us...@cxf.apache.org>
Sent: Monday, September 21, 2009 3:18 PM
Subject: Filters


> HI,
>
> I am looking for advice on using filters for my REST based
> application. I want to log start, end time and HTTP status code.
> I read about CXF and JAXRS filters. I am not sure how this can be
> achieved? Will servlet filter be a good idea?
>
> Thanks,
> Nishant