[jboss-user] [EJB 3.0] - Re: Permanent interceptor
jc7442
do-not-reply at jboss.com
Thu Dec 14 12:24:51 EST 2006
Hi,
I'm not sure you can simply add your own domain in the ejb3 interceptors. I just connect on existing one.
If your need is to add your own domain check AOP documentation. From what I remenber it is explain but not so simple to implement.
It looks like that :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE aop PUBLIC
"-//JBoss//DTD JBOSS AOP 1.0//EN"
"http://www.jboss.org/aop/dtd/jboss-aop_1_0.dtd">
...
<!--################################################### -->
<!--My Interceptor-->
<!--typedef name="bmx" expr="class(@javax.ejb.Remote) OR class(@javax.ejb.Local)"/-->
<!-- FIN MyInterceptor-->
<!-- ################################################### -->
<!-- ################################################### -->
<!-- My Interceptor-->
<!--interceptor-ref name="fr.biomerieux.interceptor.ExecutionTimeInterceptor"/-->
<interceptor-ref name="fr.biomerieux.interceptor.ExceptionHanlderInterceptor"/>
<!-- FIN My Interceptor-->
<!-- ################################################### -->
<interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
...
<!-- ################################################### -->
<!-- My Interceptor-->
<!--interceptor-ref name="fr.biomerieux.interceptor.ExecutionTimeInterceptor"/-->
<interceptor-ref name="fr.biomerieux.interceptor.ExceptionHanlderInterceptor"/>
<!-- FIN My Interceptor-->
<!-- ################################################### -->
<interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
...
And a intercptor:
public class ExecutionTimeInterceptor implements Interceptor {
/**
* Version number
*/
private final Logger LOGGER = Logger.getLogger(ExecutionTimeInterceptor.class
.getName());
/**
* Log the elapsed time of the execution of a method
*/
public Object invoke(Invocation invocation) throws Throwable {
long start = System.currentTimeMillis();
try {
return invocation.invokeNext();
} finally {
long end = System.currentTimeMillis();
MethodInvocation methodInvocation = (MethodInvocation) invocation;
Method m = methodInvocation.getMethod();
LOGGER.fine(MessageFormat.format(MESSAGE.METHOD_EXECUTION,
new Object[] { m.getDeclaringClass().getName(), m.getName(),
((end - start) / 1000.) }));
}
}
/**
* Return the name of the interceptor
*/
public String getName() {
return ExecutionTimeInterceptor.class.getName();
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993954#3993954
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993954
More information about the jboss-user
mailing list