use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor 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.LifecycleCallbackDescriptor in project Payara by payara.
the class BeanMethodCalculatorImpl method getTransactionalMethodsFor.
/**
* @return a collection of MethodDescriptor for all the methods of my
* ejb which are elligible to have a particular transaction setting.
*/
public Collection getTransactionalMethodsFor(com.sun.enterprise.deployment.EjbDescriptor desc, ClassLoader loader) throws ClassNotFoundException, NoSuchMethodException {
EjbDescriptor ejbDescriptor = (EjbDescriptor) desc;
// only set if desc is a stateful session bean. NOTE that
// !statefulSessionBean does not imply stateless session bean
boolean statefulSessionBean = false;
Vector methods = new Vector();
if (ejbDescriptor instanceof EjbSessionDescriptor) {
statefulSessionBean = ((EjbSessionDescriptor) ejbDescriptor).isStateful();
boolean singletonSessionBean = ((EjbSessionDescriptor) ejbDescriptor).isSingleton();
// Session Beans
if (ejbDescriptor.isRemoteInterfacesSupported()) {
Collection disallowedMethods = extractDisallowedMethodsFor(javax.ejb.EJBObject.class, sessionBeanMethodsDisallowed);
Collection potentials = getTransactionMethodsFor(loader, ejbDescriptor.getRemoteClassName(), disallowedMethods);
transformAndAdd(potentials, MethodDescriptor.EJB_REMOTE, methods);
}
if (ejbDescriptor.isRemoteBusinessInterfacesSupported()) {
for (String intfName : ejbDescriptor.getRemoteBusinessClassNames()) {
Class businessIntf = loader.loadClass(intfName);
Method[] busIntfMethods = businessIntf.getMethods();
for (Method next : busIntfMethods) {
methods.add(new MethodDescriptor(next, MethodDescriptor.EJB_REMOTE));
}
}
}
if (ejbDescriptor.isLocalInterfacesSupported()) {
Collection disallowedMethods = extractDisallowedMethodsFor(javax.ejb.EJBLocalObject.class, sessionLocalBeanMethodsDisallowed);
Collection potentials = getTransactionMethodsFor(loader, ejbDescriptor.getLocalClassName(), disallowedMethods);
transformAndAdd(potentials, MethodDescriptor.EJB_LOCAL, methods);
}
if (ejbDescriptor.isLocalBusinessInterfacesSupported()) {
for (String intfName : ejbDescriptor.getLocalBusinessClassNames()) {
Class businessIntf = loader.loadClass(intfName);
Method[] busIntfMethods = businessIntf.getMethods();
for (Method next : busIntfMethods) {
methods.add(new MethodDescriptor(next, MethodDescriptor.EJB_LOCAL));
}
}
}
if (ejbDescriptor.isLocalBean()) {
String intfName = ejbDescriptor.getEjbClassName();
Class businessIntf = loader.loadClass(intfName);
Method[] busIntfMethods = businessIntf.getMethods();
for (Method next : busIntfMethods) {
methods.add(new MethodDescriptor(next, MethodDescriptor.EJB_LOCAL));
}
}
if (ejbDescriptor.hasWebServiceEndpointInterface()) {
Class webServiceClass = loader.loadClass(ejbDescriptor.getWebServiceEndpointInterfaceName());
Method[] webMethods = webServiceClass.getMethods();
for (int i = 0; i < webMethods.length; i++) {
methods.add(new MethodDescriptor(webMethods[i], MethodDescriptor.EJB_WEB_SERVICE));
}
}
// SFSB and Singleton can have lifecycle callbacks transactional
if (statefulSessionBean || singletonSessionBean) {
Set<LifecycleCallbackDescriptor> lcds = ejbDescriptor.getLifecycleCallbackDescriptors();
for (LifecycleCallbackDescriptor lcd : lcds) {
try {
Method m = lcd.getLifecycleCallbackMethodObject(loader);
MethodDescriptor md = new MethodDescriptor(m, MethodDescriptor.LIFECYCLE_CALLBACK);
methods.add(md);
} catch (Exception e) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Lifecycle callback processing error", e);
}
}
}
}
} else {
// entity beans local interfaces
String homeIntf = ejbDescriptor.getHomeClassName();
if (homeIntf != null) {
Class home = loader.loadClass(homeIntf);
Collection potentials = getTransactionMethodsFor(javax.ejb.EJBHome.class, home);
transformAndAdd(potentials, MethodDescriptor.EJB_HOME, methods);
String remoteIntf = ejbDescriptor.getRemoteClassName();
Class remote = loader.loadClass(remoteIntf);
potentials = getTransactionMethodsFor(javax.ejb.EJBObject.class, remote);
transformAndAdd(potentials, MethodDescriptor.EJB_REMOTE, methods);
}
// enity beans remote interfaces
String localHomeIntf = ejbDescriptor.getLocalHomeClassName();
if (localHomeIntf != null) {
Class home = loader.loadClass(localHomeIntf);
Collection potentials = getTransactionMethodsFor(javax.ejb.EJBLocalHome.class, home);
transformAndAdd(potentials, MethodDescriptor.EJB_LOCALHOME, methods);
String remoteIntf = ejbDescriptor.getLocalClassName();
Class remote = loader.loadClass(remoteIntf);
potentials = getTransactionMethodsFor(javax.ejb.EJBLocalObject.class, remote);
transformAndAdd(potentials, MethodDescriptor.EJB_LOCAL, methods);
}
}
if (!statefulSessionBean) {
if (ejbDescriptor.isTimedObject()) {
if (ejbDescriptor.getEjbTimeoutMethod() != null) {
methods.add(ejbDescriptor.getEjbTimeoutMethod());
}
for (ScheduledTimerDescriptor schd : ejbDescriptor.getScheduledTimerDescriptors()) {
methods.add(schd.getTimeoutMethod());
}
}
}
return methods;
}
use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor 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