users@jersey.java.net

[Jersey] Re: ApplicationEventListener's in Jersey

From: Miroslav Fuksa <miroslav.fuksa_at_oracle.com>
Date: Tue, 10 Sep 2013 13:40:26 +0200

Hi,

please see my comments below.


On 09/09/2013 01:14 PM, Nikita Sheremet wrote:
>
> Hello I am trying to write ApplicationEventListener for jersey
> application. But it does not work. I see in log file that class
> implements ApplicationEventListener actual loaded, but code inside it
> does not run. (I added System.out.prinln() to onEvent method and
> nothing writes to the log)
>
> I use glassfish 3.1.2.2 with jersey implementation is 1.11. Is the
> problem that ApplicationEventListener is Jersey 2.2 feature? Is it
> possible to use ApplicationEventListener in glassfish 3.1.2.2 and how?
>
org.glassfish.jersey.server.monitoring.ApplicationEventListener is
Jersey 2.x feature and it will not work with Jersey 1.x. Jersey 1.x has
not support for this feature. In Jersey 1.x there is support for
interfaces in the package com.sun.jersey.spi.monitoring in the
jersey-server module (for example RequestListener). The functionality of
event listeners from Jersey 1.x and 2.x 1:1. Event listeners support in
Jersey 2.x is more detailed (you can listen to more events) and it
provides more features (calculation of monitoring statistics, more
details about application and request processing, mbeans exposure and
others).

> Also could you provide an explanation with maven dependencies with
> Jersey? If I use only:
>
> <dependency>
>
> <groupId>javax.ws.rs</groupId>
>
> <artifactId>javax.ws.rs-api</artifactId>
>
> <version>2.0</version>
>
> <scope>provided</scope>
>
> </dependency>
>
> I could not package my application with maven, because there is no
> ApplicationEventListener interface in it. I can add
>
> <dependency>
>
> <groupId>org.glassfish.jersey.core</groupId>
>
> <artifactId>jersey-server</artifactId>
>
> <version>2.2</version>
>
> </dependency>
>
> After that I can compile my application but it does not work.
>
Jersey 2.x will not work with Glassfish 3.x. Glassfish 4 contains Jersey
2 already integrated. Can you use Glassfish 4?
>
> I will be much obliged to you if you provide one simple completed
> example with ApplicationEventListener, maven dependencies and
> container (glassfish 3.1.2.2, not simple jdk with main function), that
> can be compiled and deployed.
>
We currently don't have a sample for event listeners. We cannot add a
sample for GF 3 as explained above but we could have a sample for
Glassfish 4.x. We might add such a sample later on but we do not plan it
now. A contribution from Jersey users of such a sample to Jersey code
would be welcome.

> Regards,
>
> Nikita Sheremet
>

Regards
Mira