use of org.glassfish.apf.impl.ComponentDefinition in project Payara by payara.
the class InterceptorsHandler method processInterceptorClass.
private void processInterceptorClass(Class interceptorClass, EjbBundleDescriptorImpl ejbBundle, AnnotationInfo ainfo) throws AnnotationProcessorException {
Set<LifecycleCallbackDescriptor> aroundInvokeDescriptors = new HashSet<LifecycleCallbackDescriptor>();
Set<LifecycleCallbackDescriptor> aroundTimeoutDescriptors = new HashSet<LifecycleCallbackDescriptor>();
Set<LifecycleCallbackDescriptor> postActivateDescriptors = new HashSet<LifecycleCallbackDescriptor>();
Set<LifecycleCallbackDescriptor> prePassivateDescriptors = new HashSet<LifecycleCallbackDescriptor>();
ComponentDefinition cdef = new ComponentDefinition(interceptorClass);
for (Method m : cdef.getMethods()) {
if (m.getAnnotation(AroundInvoke.class) != null) {
aroundInvokeDescriptors.add(getLifecycleCallbackDescriptor(m, true));
}
if (m.getAnnotation(AroundTimeout.class) != null) {
aroundTimeoutDescriptors.add(getLifecycleCallbackDescriptor(m, true));
}
if (m.getAnnotation(PostActivate.class) != null) {
postActivateDescriptors.add(getLifecycleCallbackDescriptor(m, false));
}
if (m.getAnnotation(PrePassivate.class) != null) {
prePassivateDescriptors.add(getLifecycleCallbackDescriptor(m, false));
}
}
EjbInterceptor interceptor = ejbBundle.getInterceptorByClassName(interceptorClass.getName());
if (interceptor == null) {
interceptor = new EjbInterceptor();
interceptor.setInterceptorClassName(interceptorClass.getName());
// Add interceptor to the set of all interceptors in the ejb-jar
ejbBundle.addInterceptor(interceptor);
}
if (aroundInvokeDescriptors.size() > 0) {
interceptor.addAroundInvokeDescriptors(aroundInvokeDescriptors);
}
if (aroundTimeoutDescriptors.size() > 0) {
interceptor.addAroundTimeoutDescriptors(aroundTimeoutDescriptors);
}
if (postActivateDescriptors.size() > 0) {
interceptor.addCallbackDescriptors(CallbackType.POST_ACTIVATE, postActivateDescriptors);
}
if (prePassivateDescriptors.size() > 0) {
interceptor.addCallbackDescriptors(CallbackType.PRE_PASSIVATE, prePassivateDescriptors);
}
// process resource related annotations
EjbInterceptorContext ejbInterceptorContext = new EjbInterceptorContext(interceptor);
ProcessingContext procContext = ainfo.getProcessingContext();
procContext.pushHandler(ejbInterceptorContext);
procContext.getProcessor().process(procContext, new Class[] { interceptorClass });
return;
}
Aggregations