use of com.sun.enterprise.deployment.EjbInterceptor in project Payara by payara.
the class EjbServicesImpl method makeInterceptorChain.
private List<EjbInterceptor> makeInterceptorChain(InterceptionType interceptionType, List<Interceptor<?>> lifecycleList, com.sun.enterprise.deployment.EjbDescriptor ejbDesc) {
List<EjbInterceptor> ejbInterceptorList = new LinkedList<EjbInterceptor>();
if (lifecycleList == null) {
return ejbInterceptorList;
}
for (Interceptor<?> next : lifecycleList) {
EjbInterceptor ejbInt = makeEjbInterceptor(next, ejbDesc.getEjbBundleDescriptor());
Class<?> interceptorClass = next.getBeanClass();
while (interceptorClass != null && !interceptorClass.equals(Object.class)) {
String methodName = getInterceptorMethod(interceptorClass, getInterceptorAnnotationType(interceptionType));
if (methodName != null) {
LifecycleCallbackDescriptor lifecycleDesc = new LifecycleCallbackDescriptor();
lifecycleDesc.setLifecycleCallbackClass(interceptorClass.getName());
lifecycleDesc.setLifecycleCallbackMethod(methodName);
switch(interceptionType) {
case POST_CONSTRUCT:
ejbInt.addPostConstructDescriptor(lifecycleDesc);
break;
case PRE_DESTROY:
ejbInt.addPreDestroyDescriptor(lifecycleDesc);
break;
case PRE_PASSIVATE:
ejbInt.addPrePassivateDescriptor(lifecycleDesc);
break;
case POST_ACTIVATE:
ejbInt.addPostActivateDescriptor(lifecycleDesc);
break;
case AROUND_INVOKE:
lifecycleDesc.setRequiresInvocationContextArgument(true);
ejbInt.addAroundInvokeDescriptor(lifecycleDesc);
break;
case AROUND_TIMEOUT:
lifecycleDesc.setRequiresInvocationContextArgument(true);
ejbInt.addAroundTimeoutDescriptor(lifecycleDesc);
break;
case AROUND_CONSTRUCT:
ejbInt.addAroundConstructDescriptor(lifecycleDesc);
break;
default:
throw new IllegalArgumentException("Invalid lifecycle interception type " + interceptionType);
}
}
interceptorClass = interceptorClass.getSuperclass();
}
ejbInterceptorList.add(ejbInt);
}
return ejbInterceptorList;
}
use of com.sun.enterprise.deployment.EjbInterceptor in project Payara by payara.
the class BeanCallbackInterceptor method getAroundTimeoutChain.
public InterceptorManager.InterceptorChain getAroundTimeoutChain(MethodDescriptor mDesc, Method beanMethod) {
ArrayList<AroundInvokeInterceptor> interceptors = new ArrayList<AroundInvokeInterceptor>();
for (InterceptorDescriptor interceptor : frameworkInterceptors) {
Set<LifecycleCallbackDescriptor> aroundTimeoutDescs = interceptor.getAroundTimeoutDescriptors();
if (aroundTimeoutDescs.isEmpty()) {
continue;
}
List<LifecycleCallbackDescriptor> orderedAIInterceptors = null;
Class interceptorClass = interceptor.getInterceptorClass();
ClassLoader classLoaderToUse = (interceptorClass != null) ? interceptorClass.getClassLoader() : loader;
try {
orderedAIInterceptors = interceptor.getOrderedAroundTimeoutDescriptors(classLoaderToUse);
} catch (Exception e) {
throw new IllegalStateException("No AroundTimeoutIntercetpors found " + " on class " + interceptor.getInterceptorClassName(), e);
}
addAroundInvokeInterceptors(interceptors, interceptor, orderedAIInterceptors, interceptor.getInterceptorClassName(), classLoaderToUse);
}
List<EjbInterceptor> list = (ejbDesc != null) ? ejbDesc.getAroundTimeoutInterceptors(mDesc) : new LinkedList<EjbInterceptor>();
for (EjbInterceptor interceptor : list) {
String className = interceptor.getInterceptorClassName();
Set<LifecycleCallbackDescriptor> aroundTimeoutDescs = interceptor.getAroundTimeoutDescriptors();
if (aroundTimeoutDescs.isEmpty()) {
continue;
}
List<LifecycleCallbackDescriptor> orderedATInterceptors;
try {
orderedATInterceptors = interceptor.getOrderedAroundTimeoutDescriptors(loader);
} catch (Exception e) {
throw new IllegalStateException("No AroundTimeoutIntercetpors found " + " on class " + className, e);
}
addAroundInvokeInterceptors(interceptors, interceptor, orderedATInterceptors, className, loader);
}
AroundInvokeInterceptor[] inter = interceptors.toArray(new AroundInvokeInterceptor[interceptors.size()]);
return new AroundInvokeChainImpl(inter);
}
use of com.sun.enterprise.deployment.EjbInterceptor in project Payara by payara.
the class EjbContainerServicesImpl method isEjbManagedObject.
public boolean isEjbManagedObject(Object desc, Class c) {
String className = c.getName();
EjbDescriptor ejbDesc = (EjbDescriptor) desc;
Set<String> ejbManagedObjectClassNames = new HashSet<String>();
ejbManagedObjectClassNames.add(ejbDesc.getEjbClassName());
for (EjbInterceptor next : ejbDesc.getInterceptorClasses()) {
if (!next.isCDIInterceptor()) {
ejbManagedObjectClassNames.add(next.getInterceptorClassName());
}
}
Set<String> serializableClassNames = new HashSet<String>();
for (String next : ejbManagedObjectClassNames) {
// Add the serializable sub-class version of each name as well
serializableClassNames.add(EJBUtils.getGeneratedSerializableClassName(next));
}
boolean isEjbManagedObject = ejbManagedObjectClassNames.contains(className) || serializableClassNames.contains(className);
return isEjbManagedObject;
}
use of com.sun.enterprise.deployment.EjbInterceptor in project Payara by payara.
the class LifecycleCallbackNode method getDescriptor.
@Override
public LifecycleCallbackDescriptor getDescriptor() {
if (descriptor == null) {
descriptor = new LifecycleCallbackDescriptor();
Descriptor parentDesc = (Descriptor) getParentNode().getDescriptor();
if (parentDesc instanceof EjbDescriptor) {
EjbDescriptor ejbDesc = (EjbDescriptor) parentDesc;
descriptor.setDefaultLifecycleCallbackClass(ejbDesc.getEjbClassName());
} else if (parentDesc instanceof EjbInterceptor) {
EjbInterceptor ejbInterceptor = (EjbInterceptor) parentDesc;
descriptor.setDefaultLifecycleCallbackClass(ejbInterceptor.getInterceptorClassName());
}
// we set the default lifecycle callback class for appclient
// later in validate since the appclient Main class is not
// available at this point
}
return descriptor;
}
Aggregations