You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by sgjava <sg...@gmail.com> on 2015/08/06 22:00:12 UTC

ContainerResponseFilter for logging

I have a ClientRequestFilter I use for logging entity info using:

// Set up web client with logging filter
final Client client =
ClientBuilder.newClient().register(ClientRequestLoggingFilter.class);

How do you register your ContainerResponseFilter on the server side? Is
there a difference with tomee-ebedded?




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/ContainerResponseFilter-for-logging-tp4675772.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: ContainerResponseFilter for logging

Posted by Romain Manni-Bucau <rm...@gmail.com>.
well some container doesnt treat provider as cdi beans - just support
injections. But veto shoud ensure it is not a CDI bean. That said dependent
should behave as a simple not managed instance.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-07 8:47 GMT-07:00 Steve Goldsmith <sg...@gmail.com>:

> So, is this not relevant? I try to make things cross container, but if it's
> global then I'd like to use final methods when I don't want the bean's
> methods extended.
>
>
> http://stackoverflow.com/questions/20681981/why-cdi-beans-dont-support-final-methods
>
> On Fri, Aug 7, 2015 at 11:39 AM, Romain Manni-Bucau <rmannibucau@gmail.com
> >
> wrote:
>
> > Le 7 août 2015 08:04, "Steve Goldsmith" <sg...@gmail.com> a écrit :
> > >
> > > Since CDI beans do not support final methods could I make filter final
> by
> > > using @Vetoed?
> > >
> >
> > Yes but cdi does support it if the bean is dependent ;)
> >
> > > On Fri, Aug 7, 2015 at 10:54 AM, Romain Manni-Bucau <
> > rmannibucau@gmail.com
> > >
> > > wrote:
> > >
> > > > just curiosity: remove @Singleton and making the class @Vetoed should
> > > > ensure it is not a CDI bean or an EJB so it would be a bit faster for
> > this
> > > > particular impl.
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <http://rmannibucau.wordpress.com> | Github <
> > > > https://github.com/rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > <http://www.tomitribe.com>
> > > >
> > > > 2015-08-07 7:48 GMT-07:00 sgjava <sg...@gmail.com>:
> > > >
> > > > > This is what I ended up with:
> > > > >
> > > > > @Singleton
> > > > > @Provider
> > > > > public class ServerResponseLoggingFilter implements
> > > > ContainerResponseFilter
> > > > > {
> > > > >
> > > > >     /**
> > > > >      * Logger.
> > > > >      */
> > > > >     //CHECKSTYLE:OFF ConstantName
> > > > >     private static final Logger log = LoggerFactory.
> > > > >             getLogger(ServerResponseLoggingFilter.class);
> > > > >     //CHECKSTYLE:ON ConstantName
> > > > >
> > > > >    @Override
> > > > >     public void filter(final ContainerRequestContext
> requestContext,
> > > > >             final ContainerResponseContext responseContext) {
> > > > >         log.debug(String.format("Entity: %s",
> > > > > responseContext.getEntity()));
> > > > >     }
> > > > > }
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > View this message in context:
> > > > >
> > > >
> >
> >
> http://tomee-openejb.979440.n4.nabble.com/ContainerResponseFilter-for-logging-tp4675772p4675778.html
> > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> >
>
>
>
> --
> Steven P. Goldsmith
>

Re: ContainerResponseFilter for logging

Posted by Steve Goldsmith <sg...@gmail.com>.
So, is this not relevant? I try to make things cross container, but if it's
global then I'd like to use final methods when I don't want the bean's
methods extended.

http://stackoverflow.com/questions/20681981/why-cdi-beans-dont-support-final-methods

On Fri, Aug 7, 2015 at 11:39 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Le 7 août 2015 08:04, "Steve Goldsmith" <sg...@gmail.com> a écrit :
> >
> > Since CDI beans do not support final methods could I make filter final by
> > using @Vetoed?
> >
>
> Yes but cdi does support it if the bean is dependent ;)
>
> > On Fri, Aug 7, 2015 at 10:54 AM, Romain Manni-Bucau <
> rmannibucau@gmail.com
> >
> > wrote:
> >
> > > just curiosity: remove @Singleton and making the class @Vetoed should
> > > ensure it is not a CDI bean or an EJB so it would be a bit faster for
> this
> > > particular impl.
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com>
> > >
> > > 2015-08-07 7:48 GMT-07:00 sgjava <sg...@gmail.com>:
> > >
> > > > This is what I ended up with:
> > > >
> > > > @Singleton
> > > > @Provider
> > > > public class ServerResponseLoggingFilter implements
> > > ContainerResponseFilter
> > > > {
> > > >
> > > >     /**
> > > >      * Logger.
> > > >      */
> > > >     //CHECKSTYLE:OFF ConstantName
> > > >     private static final Logger log = LoggerFactory.
> > > >             getLogger(ServerResponseLoggingFilter.class);
> > > >     //CHECKSTYLE:ON ConstantName
> > > >
> > > >    @Override
> > > >     public void filter(final ContainerRequestContext requestContext,
> > > >             final ContainerResponseContext responseContext) {
> > > >         log.debug(String.format("Entity: %s",
> > > > responseContext.getEntity()));
> > > >     }
> > > > }
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > > >
> > >
>
> http://tomee-openejb.979440.n4.nabble.com/ContainerResponseFilter-for-logging-tp4675772p4675778.html
> > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > >
> > >
> >
> >
> >
> > --
> > Steven P. Goldsmith
>



-- 
Steven P. Goldsmith

Re: ContainerResponseFilter for logging

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le 7 août 2015 08:04, "Steve Goldsmith" <sg...@gmail.com> a écrit :
>
> Since CDI beans do not support final methods could I make filter final by
> using @Vetoed?
>

Yes but cdi does support it if the bean is dependent ;)

> On Fri, Aug 7, 2015 at 10:54 AM, Romain Manni-Bucau <rmannibucau@gmail.com
>
> wrote:
>
> > just curiosity: remove @Singleton and making the class @Vetoed should
> > ensure it is not a CDI bean or an EJB so it would be a bit faster for
this
> > particular impl.
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-08-07 7:48 GMT-07:00 sgjava <sg...@gmail.com>:
> >
> > > This is what I ended up with:
> > >
> > > @Singleton
> > > @Provider
> > > public class ServerResponseLoggingFilter implements
> > ContainerResponseFilter
> > > {
> > >
> > >     /**
> > >      * Logger.
> > >      */
> > >     //CHECKSTYLE:OFF ConstantName
> > >     private static final Logger log = LoggerFactory.
> > >             getLogger(ServerResponseLoggingFilter.class);
> > >     //CHECKSTYLE:ON ConstantName
> > >
> > >    @Override
> > >     public void filter(final ContainerRequestContext requestContext,
> > >             final ContainerResponseContext responseContext) {
> > >         log.debug(String.format("Entity: %s",
> > > responseContext.getEntity()));
> > >     }
> > > }
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
http://tomee-openejb.979440.n4.nabble.com/ContainerResponseFilter-for-logging-tp4675772p4675778.html
> > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > >
> >
>
>
>
> --
> Steven P. Goldsmith

Re: ContainerResponseFilter for logging

Posted by Steve Goldsmith <sg...@gmail.com>.
Since CDI beans do not support final methods could I make filter final by
using @Vetoed?

On Fri, Aug 7, 2015 at 10:54 AM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> just curiosity: remove @Singleton and making the class @Vetoed should
> ensure it is not a CDI bean or an EJB so it would be a bit faster for this
> particular impl.
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-07 7:48 GMT-07:00 sgjava <sg...@gmail.com>:
>
> > This is what I ended up with:
> >
> > @Singleton
> > @Provider
> > public class ServerResponseLoggingFilter implements
> ContainerResponseFilter
> > {
> >
> >     /**
> >      * Logger.
> >      */
> >     //CHECKSTYLE:OFF ConstantName
> >     private static final Logger log = LoggerFactory.
> >             getLogger(ServerResponseLoggingFilter.class);
> >     //CHECKSTYLE:ON ConstantName
> >
> >    @Override
> >     public void filter(final ContainerRequestContext requestContext,
> >             final ContainerResponseContext responseContext) {
> >         log.debug(String.format("Entity: %s",
> > responseContext.getEntity()));
> >     }
> > }
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/ContainerResponseFilter-for-logging-tp4675772p4675778.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>



-- 
Steven P. Goldsmith

Re: ContainerResponseFilter for logging

Posted by Romain Manni-Bucau <rm...@gmail.com>.
just curiosity: remove @Singleton and making the class @Vetoed should
ensure it is not a CDI bean or an EJB so it would be a bit faster for this
particular impl.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-07 7:48 GMT-07:00 sgjava <sg...@gmail.com>:

> This is what I ended up with:
>
> @Singleton
> @Provider
> public class ServerResponseLoggingFilter implements ContainerResponseFilter
> {
>
>     /**
>      * Logger.
>      */
>     //CHECKSTYLE:OFF ConstantName
>     private static final Logger log = LoggerFactory.
>             getLogger(ServerResponseLoggingFilter.class);
>     //CHECKSTYLE:ON ConstantName
>
>    @Override
>     public void filter(final ContainerRequestContext requestContext,
>             final ContainerResponseContext responseContext) {
>         log.debug(String.format("Entity: %s",
> responseContext.getEntity()));
>     }
> }
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/ContainerResponseFilter-for-logging-tp4675772p4675778.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: ContainerResponseFilter for logging

Posted by sgjava <sg...@gmail.com>.
This is what I ended up with:

@Singleton
@Provider
public class ServerResponseLoggingFilter implements ContainerResponseFilter
{

    /**
     * Logger.
     */
    //CHECKSTYLE:OFF ConstantName
    private static final Logger log = LoggerFactory.
            getLogger(ServerResponseLoggingFilter.class);
    //CHECKSTYLE:ON ConstantName

   @Override
    public void filter(final ContainerRequestContext requestContext,
            final ContainerResponseContext responseContext) {
        log.debug(String.format("Entity: %s", responseContext.getEntity()));
    }
}



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/ContainerResponseFilter-for-logging-tp4675772p4675778.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: ContainerResponseFilter for logging

Posted by Steve Goldsmith <sg...@gmail.com>.
Thanks, I'll try that in the morning.

On Thu, Aug 6, 2015 at 6:37 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> Hi
>
> if the jar is scanned then @Provider is enough, if not then openejb-jar.xml
> is the way to go
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com>
>
> 2015-08-06 13:00 GMT-07:00 sgjava <sg...@gmail.com>:
>
> > I have a ClientRequestFilter I use for logging entity info using:
> >
> > // Set up web client with logging filter
> > final Client client =
> > ClientBuilder.newClient().register(ClientRequestLoggingFilter.class);
> >
> > How do you register your ContainerResponseFilter on the server side? Is
> > there a difference with tomee-ebedded?
> >
> >
> >
> >
> > --
> > View this message in context:
> >
> http://tomee-openejb.979440.n4.nabble.com/ContainerResponseFilter-for-logging-tp4675772.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
>



-- 
Steven P. Goldsmith

Re: ContainerResponseFilter for logging

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

if the jar is scanned then @Provider is enough, if not then openejb-jar.xml
is the way to go


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-08-06 13:00 GMT-07:00 sgjava <sg...@gmail.com>:

> I have a ClientRequestFilter I use for logging entity info using:
>
> // Set up web client with logging filter
> final Client client =
> ClientBuilder.newClient().register(ClientRequestLoggingFilter.class);
>
> How do you register your ContainerResponseFilter on the server side? Is
> there a difference with tomee-ebedded?
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/ContainerResponseFilter-for-logging-tp4675772.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>