use of com.sun.enterprise.deployment.InterceptorDescriptor in project Payara by payara.
the class BeanCallbackInterceptor method initEjbCallbackIndices.
private void initEjbCallbackIndices() throws ClassNotFoundException, Exception {
int size = CallbackType.values().length;
ArrayList[] callbacks = new ArrayList[size];
boolean scanFor2xLifecycleMethods = true;
int numPostConstructFrameworkCallbacks = 0;
for (CallbackType eventType : CallbackType.values()) {
int index = eventType.ordinal();
callbacks[index] = new ArrayList<CallbackInterceptor>();
boolean scanForCallbacks = true;
if (!(ejbDesc instanceof EjbSessionDescriptor)) {
if ((eventType == CallbackType.PRE_PASSIVATE) || (eventType == CallbackType.POST_ACTIVATE)) {
scanForCallbacks = false;
}
}
if (scanForCallbacks) {
// Make sure any framework interceptors are first
for (InterceptorDescriptor callback : frameworkInterceptors) {
if (callback.hasCallbackDescriptor(eventType)) {
Class interceptorClass = callback.getInterceptorClass();
ClassLoader classLoaderToUse = (interceptorClass != null) ? interceptorClass.getClassLoader() : loader;
List<CallbackInterceptor> inters = createCallbackInterceptors(eventType, callback, classLoaderToUse);
for (CallbackInterceptor inter : inters) {
callbacks[index].add(inter);
if (eventType == CallbackType.POST_CONSTRUCT) {
numPostConstructFrameworkCallbacks++;
}
}
}
}
List<EjbInterceptor> callbackList = ejbDesc.getCallbackInterceptors(eventType);
// to scan for the old 2.x style lifecycle methods
if (callbackList.size() > 0) {
scanFor2xLifecycleMethods = false;
}
for (EjbInterceptor callback : callbackList) {
List<CallbackInterceptor> inters = createCallbackInterceptors(eventType, callback);
for (CallbackInterceptor inter : inters) {
callbacks[index].add(inter);
}
}
}
}
if (scanFor2xLifecycleMethods) {
load2xLifecycleMethods(callbacks);
}
// The next set of lines are to handle the case where
// the app doesn't have a @PostConstruct or it
// doesn't implement the EntrerpriseBean interface
// In this case we scan for ejbCreate() for MDBs and SLSBs
boolean lookForEjbCreateMethod = container.scanForEjbCreateMethod();
if (lookForEjbCreateMethod) {
loadOnlyEjbCreateMethod(callbacks, numPostConstructFrameworkCallbacks);
}
callbackChain = new CallbackChainImpl[size];
for (CallbackType eventType : CallbackType.values()) {
int index = eventType.ordinal();
CallbackInterceptor[] interceptors = (CallbackInterceptor[]) callbacks[index].toArray(new CallbackInterceptor[callbacks[index].size()]);
callbackChain[index] = new CallbackChainImpl(interceptors);
}
}
use of com.sun.enterprise.deployment.InterceptorDescriptor in project Payara by payara.
the class BeanCallbackInterceptor method buildEjbInterceptorChain.
private void buildEjbInterceptorChain() throws Exception {
Set<Class> listOfClasses = new HashSet<Class>();
for (EjbInterceptor ejbi : ejbDesc.getInterceptorClasses()) {
// PAYARA-826 if the interceptor class is available use it
Class interceptorClass = ejbi.getInterceptorClass();
if (interceptorClass == null) {
String className = ejbi.getInterceptorClassName();
interceptorClass = loader.loadClass(className);
}
listOfClasses.add(interceptorClass);
}
// class before attempting to load it via application class loader
for (InterceptorDescriptor frameworkInterceptor : frameworkInterceptors) {
Class clazz = frameworkInterceptor.getInterceptorClass();
if (clazz == null) {
clazz = loader.loadClass(frameworkInterceptor.getInterceptorClassName());
}
listOfClasses.add(clazz);
}
initInterceptorClasses(listOfClasses);
interceptorsExists = (listOfClasses.size() > 0) || ejbDesc.hasAroundInvokeMethod() || ejbDesc.hasAroundTimeoutMethod();
initEjbCallbackIndices();
}
use of com.sun.enterprise.deployment.InterceptorDescriptor in project Payara by payara.
the class BeanCallbackInterceptor method getAroundInvokeChain.
public InterceptorManager.InterceptorChain getAroundInvokeChain(MethodDescriptor mDesc, Method beanMethod) {
ArrayList<AroundInvokeInterceptor> interceptors = new ArrayList<AroundInvokeInterceptor>();
for (InterceptorDescriptor interceptor : frameworkInterceptors) {
Set<LifecycleCallbackDescriptor> aroundInvokeDescs = interceptor.getAroundInvokeDescriptors();
if (aroundInvokeDescs.isEmpty()) {
continue;
}
List<LifecycleCallbackDescriptor> orderedAIInterceptors = null;
Class interceptorClass = interceptor.getInterceptorClass();
ClassLoader classLoaderToUse = (interceptorClass != null) ? interceptorClass.getClassLoader() : loader;
try {
orderedAIInterceptors = interceptor.getOrderedAroundInvokeDescriptors(classLoaderToUse);
} catch (Exception e) {
throw new IllegalStateException("No AroundInvokeIntercetpors found " + " on class " + interceptor.getInterceptorClassName(), e);
}
addAroundInvokeInterceptors(interceptors, interceptor, orderedAIInterceptors, interceptor.getInterceptorClassName(), classLoaderToUse);
}
List<? extends InterceptorDescriptor> list = (ejbDesc != null) ? ejbDesc.getAroundInvokeInterceptors(mDesc) : interceptorInfo.getAroundInvokeInterceptors(beanMethod);
for (InterceptorDescriptor interceptor : list) {
String className = interceptor.getInterceptorClassName();
Set<LifecycleCallbackDescriptor> aroundInvokeDescs = interceptor.getAroundInvokeDescriptors();
if (aroundInvokeDescs.isEmpty()) {
continue;
}
List<LifecycleCallbackDescriptor> orderedAIInterceptors = null;
try {
orderedAIInterceptors = interceptor.getOrderedAroundInvokeDescriptors(loader);
} catch (Exception e) {
throw new IllegalStateException("No AroundInvokeIntercetpors found " + " on class " + className, e);
}
addAroundInvokeInterceptors(interceptors, interceptor, orderedAIInterceptors, className, loader);
}
AroundInvokeInterceptor[] inter = interceptors.toArray(new AroundInvokeInterceptor[interceptors.size()]);
return new AroundInvokeChainImpl(inter);
}
use of com.sun.enterprise.deployment.InterceptorDescriptor in project Payara by payara.
the class SystemInterceptorProxy method createInterceptorDesc.
public static InterceptorDescriptor createInterceptorDesc() {
InterceptorDescriptor interceptor = new InterceptorDescriptor();
Class interceptorClass = SystemInterceptorProxy.class;
String interceptorName = interceptorClass.getName();
interceptor.setInterceptorClass(interceptorClass);
{
LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
desc.setLifecycleCallbackClass(interceptorName);
desc.setLifecycleCallbackMethod("create");
interceptor.addCallbackDescriptor(CallbackType.AROUND_CONSTRUCT, desc);
}
{
LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
desc.setLifecycleCallbackClass(interceptorName);
desc.setLifecycleCallbackMethod("init");
interceptor.addCallbackDescriptor(CallbackType.POST_CONSTRUCT, desc);
}
{
LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
desc.setLifecycleCallbackClass(interceptorName);
desc.setLifecycleCallbackMethod("destroy");
interceptor.addCallbackDescriptor(CallbackType.PRE_DESTROY, desc);
}
{
LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
desc.setLifecycleCallbackClass(interceptorName);
desc.setLifecycleCallbackMethod("aroundInvoke");
interceptor.addAroundInvokeDescriptor(desc);
}
{
LifecycleCallbackDescriptor desc = new LifecycleCallbackDescriptor();
desc.setLifecycleCallbackClass(interceptorName);
desc.setLifecycleCallbackMethod("aroundTimeout");
interceptor.addAroundTimeoutDescriptor(desc);
}
return interceptor;
}
use of com.sun.enterprise.deployment.InterceptorDescriptor in project Payara by payara.
the class BeanCallbackInterceptor method buildInterceptorChain.
private void buildInterceptorChain(InterceptorInfo interceptorInfo) throws Exception {
Set<Class> listOfClasses = new HashSet<Class>();
for (String name : interceptorInfo.getInterceptorClassNames()) {
listOfClasses.add(loader.loadClass(name));
}
// class before attempting to load it via application class loader
for (InterceptorDescriptor frameworkInterceptor : frameworkInterceptors) {
Class clazz = frameworkInterceptor.getInterceptorClass();
if (clazz == null) {
clazz = loader.loadClass(frameworkInterceptor.getInterceptorClassName());
}
listOfClasses.add(clazz);
}
initInterceptorClasses(listOfClasses);
interceptorsExists = (listOfClasses.size() > 0) || interceptorInfo.getHasTargetClassAroundInvoke();
int size = CallbackType.values().length;
callbackChain = new CallbackChainImpl[size];
initCallbackIndices(interceptorInfo.getAroundConstructInterceptors(), CallbackType.AROUND_CONSTRUCT);
initCallbackIndices(interceptorInfo.getPostConstructInterceptors(), CallbackType.POST_CONSTRUCT);
initCallbackIndices(interceptorInfo.getPreDestroyInterceptors(), CallbackType.PRE_DESTROY);
}
Aggregations