use of com.sun.enterprise.deployment.EjbInterceptor in project Payara by payara.
the class InterceptorMethodTest method check.
public Result check(EjbDescriptor descriptor) {
result = getInitializedResult();
compName = getVerifierContext().getComponentNameConstructor();
testInterceptorMethods(descriptor.getAroundInvokeDescriptors(), "AroundInvoke", true);
testInterceptorMethods(descriptor.getPreDestroyDescriptors(), "PreDestroy", true);
testInterceptorMethods(descriptor.getPostConstructDescriptors(), "PostConstruct", true);
if (descriptor instanceof EjbSessionDescriptor) {
EjbSessionDescriptor sessionDescriptor = (EjbSessionDescriptor) descriptor;
testInterceptorMethods(sessionDescriptor.getPrePassivateDescriptors(), "PrePassivate", true);
testInterceptorMethods(sessionDescriptor.getPostActivateDescriptors(), "PostActivate", true);
}
descriptor.getInterceptorClasses();
for (EjbInterceptor interceptor : descriptor.getInterceptorClasses()) {
testInterceptorMethods(interceptor.getAroundInvokeDescriptors(), "AroundInvoke", false);
testInterceptorMethods(interceptor.getPreDestroyDescriptors(), "PreDestroy", false);
testInterceptorMethods(interceptor.getPostConstructDescriptors(), "PostConstruct", false);
testInterceptorMethods(interceptor.getCallbackDescriptors(LifecycleCallbackDescriptor.CallbackType.PRE_PASSIVATE), "PrePassivate", false);
testInterceptorMethods(interceptor.getCallbackDescriptors(LifecycleCallbackDescriptor.CallbackType.POST_ACTIVATE), "PostActivate", false);
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.ejb.ejb30.InterceptorMethodTest.passed", "Valid Interceptor methods."));
}
return result;
}
use of com.sun.enterprise.deployment.EjbInterceptor in project Payara by payara.
the class EjbBundleNode method writeDescriptor.
@Override
public Node writeDescriptor(Node parent, EjbBundleDescriptorImpl ejbDesc) {
Node jarNode = super.writeDescriptor(parent, ejbDesc);
Node entrepriseBeansNode = appendChild(jarNode, EjbTagNames.EJBS);
for (EjbDescriptor ejb : ejbDesc.getEjbs()) {
if (EjbSessionDescriptor.TYPE.equals(ejb.getType())) {
EjbSessionNode subNode = new EjbSessionNode();
subNode.writeDescriptor(entrepriseBeansNode, EjbTagNames.SESSION, (EjbSessionDescriptor) ejb);
} else if (EjbEntityDescriptor.TYPE.equals(ejb.getType())) {
EjbEntityNode subNode = new EjbEntityNode();
subNode.writeDescriptor(entrepriseBeansNode, EjbTagNames.ENTITY, (EjbEntityDescriptor) ejb);
} else if (EjbMessageBeanDescriptor.TYPE.equals(ejb.getType())) {
MessageDrivenBeanNode subNode = new MessageDrivenBeanNode();
subNode.writeDescriptor(entrepriseBeansNode, EjbTagNames.MESSAGE_DRIVEN, (EjbMessageBeanDescriptor) ejb);
} else {
throw new IllegalStateException("Unknown ejb type " + ejb.getType());
}
}
if (ejbDesc.hasInterceptors()) {
Node interceptorsNode = appendChild(jarNode, EjbTagNames.INTERCEPTORS);
EjbInterceptorNode interceptorNode = new EjbInterceptorNode();
for (EjbInterceptor next : ejbDesc.getInterceptors()) {
interceptorNode.writeDescriptor(interceptorsNode, EjbTagNames.INTERCEPTOR, next);
}
}
// relationships*
if (ejbDesc.hasRelationships()) {
(new RelationshipsNode()).writeDescriptor(jarNode, EjbTagNames.RELATIONSHIPS, ejbDesc);
}
// assembly-descriptor
writeAssemblyDescriptor(jarNode, ejbDesc);
appendTextChild(jarNode, EjbTagNames.EJB_CLIENT_JAR, ejbDesc.getEjbClientJarUri());
return jarNode;
}
use of com.sun.enterprise.deployment.EjbInterceptor 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.EjbInterceptor in project Payara by payara.
the class InterceptorBindingTranslator method buildResults.
private TranslationResults buildResults() {
TranslationResults results = new TranslationResults();
if (hasTotalClassLevelOrdering) {
for (String next : totalClassLevelOrdering) {
EjbInterceptor interceptor = ejbBundle.getInterceptorByClassName(next);
results.allInterceptorClasses.add(interceptor);
results.classInterceptorChain.add(interceptor);
}
} else {
for (String next : defaultInterceptorChain) {
EjbInterceptor interceptor = ejbBundle.getInterceptorByClassName(next);
results.allInterceptorClasses.add(interceptor);
results.classInterceptorChain.add(interceptor);
}
for (String next : classInterceptorChain) {
EjbInterceptor interceptor = ejbBundle.getInterceptorByClassName(next);
results.allInterceptorClasses.add(interceptor);
results.classInterceptorChain.add(interceptor);
}
}
for (MethodDescriptor nextMethod : methodInterceptorsMap.keySet()) {
List<String> interceptorClassChain = (List<String>) methodInterceptorsMap.get(nextMethod);
List<EjbInterceptor> interceptorChain = new LinkedList<EjbInterceptor>();
for (String nextClass : interceptorClassChain) {
EjbInterceptor interceptor = ejbBundle.getInterceptorByClassName(nextClass);
results.allInterceptorClasses.add(interceptor);
interceptorChain.add(interceptor);
}
results.methodInterceptorsMap.put(nextMethod, interceptorChain);
}
return results;
}
use of com.sun.enterprise.deployment.EjbInterceptor 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);
}
}
Aggregations