use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.
the class EjbNode method writeAroundTimeoutDescriptors.
protected static void writeAroundTimeoutDescriptors(Node parentNode, Iterator aroundTimeoutDescs) {
if (aroundTimeoutDescs == null || !aroundTimeoutDescs.hasNext())
return;
AroundTimeoutNode subNode = new AroundTimeoutNode();
for (; aroundTimeoutDescs.hasNext(); ) {
LifecycleCallbackDescriptor next = (LifecycleCallbackDescriptor) aroundTimeoutDescs.next();
subNode.writeDescriptor(parentNode, EjbTagNames.AROUND_TIMEOUT_METHOD, next);
}
}
use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.
the class EjbBundleValidator method getAllPrePassivatePostActivateCallbackInfo.
private String getAllPrePassivatePostActivateCallbackInfo(EjbSessionDescriptor sessionDesc) {
List<LifecycleCallbackDescriptor> descriptors = new ArrayList<LifecycleCallbackDescriptor>();
descriptors.addAll(sessionDesc.getPrePassivateDescriptors());
descriptors.addAll(sessionDesc.getPostActivateDescriptors());
for (EjbInterceptor interceptor : sessionDesc.getInterceptorClasses()) {
descriptors.addAll(interceptor.getCallbackDescriptors(LifecycleCallbackDescriptor.CallbackType.PRE_PASSIVATE));
descriptors.addAll(interceptor.getCallbackDescriptors(LifecycleCallbackDescriptor.CallbackType.POST_ACTIVATE));
}
StringBuilder result = new StringBuilder();
for (LifecycleCallbackDescriptor each : descriptors) {
result.append(each.getLifecycleCallbackClass());
result.append(".");
result.append(each.getLifecycleCallbackMethod());
result.append(", ");
}
if (result.length() > 2) {
return result.substring(0, result.length() - 2);
} else {
return result.toString();
}
}
use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor in project Payara by payara.
the class BeanCallbackInterceptor method addAroundInvokeInterceptors.
private void addAroundInvokeInterceptors(List<AroundInvokeInterceptor> interceptors, InterceptorDescriptor interceptor, List<LifecycleCallbackDescriptor> orderedInterceptors, String className, ClassLoader classLoaderToUse) {
// if interceptor already has the class loaded use its classloader
if (interceptor.getInterceptorClass() != null) {
classLoaderToUse = interceptor.getInterceptorClass().getClassLoader();
}
for (LifecycleCallbackDescriptor desc : orderedInterceptors) {
Method method = null;
try {
method = desc.getLifecycleCallbackMethodObject(classLoaderToUse);
} catch (Exception e) {
throw new IllegalStateException("No callback method of name " + desc.getLifecycleCallbackMethod() + " found on class " + className, e);
}
if (interceptor.getFromBeanClass()) {
interceptors.add(new BeanAroundInvokeInterceptor(method));
} else {
Integer bigInt = instanceIndexMap.get(className);
int index = (bigInt == null) ? -1 : bigInt;
if (index == -1) {
throw new IllegalStateException(getInternalErrorString(className));
}
Class clazz = interceptorClasses[index];
_logger.log(Level.FINE, "*[md.getDeclaredMethod() => " + method + " FOR CLAZZ: " + clazz);
interceptors.add(new AroundInvokeInterceptor(index, method));
}
}
}
use of com.sun.enterprise.deployment.LifecycleCallbackDescriptor 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.LifecycleCallbackDescriptor 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;
}
Aggregations