Java Reference
In-Depth Information
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
public class LoggingInterceptor {
private static final Logger logger = Logger.getLogger(
public Object logMethodCall(InvocationContext invocationContext)
throws Exception {
logger.log(Level.INFO, new StringBuilder("entering ").append(
" method").toString());
Object retVal = invocationContext.proceed();
logger.log(Level.INFO, new StringBuilder("leaving ").append(
" method").toString());
return retVal;
As we can see, other than being annotated with our interceptor binding type, the
above class is a standard interceptor, just like the ones we use with EJB session beans
(refer to Chapter 7 for details).
In order for our interceptor binding type to work properly, we need to register the
above interceptor in beans.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""
Search WWH ::

Custom Search