1 |
torben |
2517 |
package dk.thoerup.webservice;
|
2 |
|
|
|
3 |
|
|
import java.util.logging.Level;
|
4 |
|
|
import java.util.logging.Logger;
|
5 |
|
|
|
6 |
|
|
import org.glassfish.jersey.server.monitoring.ApplicationEvent;
|
7 |
|
|
import org.glassfish.jersey.server.monitoring.ApplicationEventListener;
|
8 |
|
|
import org.glassfish.jersey.server.monitoring.RequestEvent;
|
9 |
|
|
import org.glassfish.jersey.server.monitoring.RequestEventListener;
|
10 |
|
|
|
11 |
|
|
public class ExceptionListener implements ApplicationEventListener {
|
12 |
|
|
|
13 |
|
|
@Override
|
14 |
|
|
public void onEvent(ApplicationEvent event) {
|
15 |
|
|
|
16 |
|
|
}
|
17 |
|
|
|
18 |
|
|
@Override
|
19 |
|
|
public RequestEventListener onRequest(RequestEvent requestEvent) {
|
20 |
|
|
return new ExceptionRequestEventListener();
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
public static class ExceptionRequestEventListener implements RequestEventListener{
|
24 |
|
|
private final Logger logger;
|
25 |
|
|
|
26 |
|
|
public ExceptionRequestEventListener(){
|
27 |
|
|
logger = Logger.getLogger(getClass().getName());
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
@Override
|
31 |
|
|
public void onEvent(RequestEvent event) {
|
32 |
|
|
switch (event.getType()){
|
33 |
|
|
case ON_EXCEPTION:
|
34 |
|
|
Throwable t = event.getException();
|
35 |
|
|
//logger.error("Found exception for requestType: "+event.getType(), t);
|
36 |
|
|
logger.log(Level.WARNING, "Found exception for requestType: " + event.getType(), t);
|
37 |
|
|
}
|
38 |
|
|
}
|
39 |
|
|
}
|
40 |
|
|
} |