}
private EjbInterceptor createSystemLevelCDIInterceptor() {
EjbInterceptor interceptor = new EjbInterceptor();
Class<SessionBeanInterceptor> interceptorClass = SessionBeanInterceptor.class;
String interceptorName = interceptorClass.getName();
interceptor.setInterceptorClass(interceptorClass);
// @@@ SessionBeanInterceptor.class no longer has @AroundInvoke annotation so
// we have to look for method explicitly.
try {
Method aroundInvokeMethod = interceptorClass.getMethod("aroundInvoke", InvocationContext.class);
if( aroundInvokeMethod != null ) {
LifecycleCallbackDescriptor aroundInvokeDesc = new LifecycleCallbackDescriptor();
aroundInvokeDesc.setLifecycleCallbackClass(interceptorName);
aroundInvokeDesc.setLifecycleCallbackMethod(aroundInvokeMethod.getName());
interceptor.addAroundInvokeDescriptor(aroundInvokeDesc);
// TODO BUG -- Existing SessionBeanInterceptor does not define an @AroundTimeout method.
// Until that's fixed, work around it by adding the method marked @AroundInvoke as an
// @AroundTimeout.
LifecycleCallbackDescriptor aroundTimeoutDesc = new LifecycleCallbackDescriptor();
aroundTimeoutDesc.setLifecycleCallbackClass(interceptorName);
aroundTimeoutDesc.setLifecycleCallbackMethod(aroundInvokeMethod.getName());
interceptor.addAroundTimeoutDescriptor(aroundTimeoutDesc);
// SessionBeanInterceptor does not define an @PostConstruct method so use the aroundInvoke method
LifecycleCallbackDescriptor postConstructDesc = new LifecycleCallbackDescriptor();
postConstructDesc.setLifecycleCallbackClass(interceptorName);
postConstructDesc.setLifecycleCallbackMethod(aroundInvokeMethod.getName());
interceptor.addPostConstructDescriptor(postConstructDesc);
}
} catch(NoSuchMethodException nsme) {
throw new RuntimeException("Cannot find weld EJB interceptor aroundInvoke method");
}