Com a annotation funciona mas ao interceptar via arquivo xml não funcionou. Nenhum log de erro aparece no console. Alguma dica de como eu posso investigar?
arquivo ejb-jar.xml
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1">
<interceptors>
<interceptor>
<interceptor-class>
br.com.caelum.livraria.interceptor.LogInterceptador
</interceptor-class>
</interceptor>
</interceptors>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>AutorDao</ejb-name>
<interceptor-class>
br.com.caelum.livraria.interceptor.LogInterceptador
</interceptor-class>
</interceptor-binding>
<interceptor-binding>
<ejb-name>AutorService</ejb-name>
<interceptor-class>
br.com.caelum.livraria.interceptor.LogInterceptador
</interceptor-class>
</interceptor-binding>
</assembly-descriptor>
</ejb-jar>
LogInterceptador.java
package br.com.caelum.livraria.interceptor;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
public class LogInterceptador {
@AroundInvoke
public Object tempoDeAcessoAoBanco(InvocationContext ic) throws Exception{
long tempoInicial = System.currentTimeMillis();
Object proceed = ic.proceed();
String metodo = ic.getMethod().getName();
String classe = ic.getTarget().getClass().getSimpleName();
long tempoFinal = System.currentTimeMillis();
System.out.println("["+classe+":"+metodo+"] Tempo decorrido: " + (tempoFinal-tempoInicial));
return proceed;
}
}