无需定义自己的Annotation,可以在EE Container
as explained here中使用@Interceptors Annotation.
@Interceptors(LoggingInterceptor.class)
在Interceptor中,您将获得包含您的Parameters的Context
public class LoggingInterceptor {
...
@AroundInvoke
public Object modifyGreeting(InvocationContext ctx) throws Exception {
....
Object[] parameters = ctx.getParameters();
try {
return ctx.proceed();
} catch (Exception e) {
logger.warning("Error calling ctx.proceed in modifyGreeting()");
return null;
}
}
}
另一个例子:here