use of com.sun.enterprise.deployment.EjbInterceptor 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.EjbInterceptor in project Payara by payara.
the class EjbDescriptor method getConstructorInterceptors.
/**
* Return bean constructor for AroundConstruct interceptors
*/
private List<EjbInterceptor> getConstructorInterceptors(ClassLoader classLoader) {
List<EjbInterceptor> callbackInterceptors = null;
String shortClassName = ejbClassName;
int i = ejbClassName.lastIndexOf('.');
if (i > -1) {
shortClassName = ejbClassName.substring(i + 1);
}
JCDIService jcdiService = (sl == null) ? null : sl.getService(JCDIService.class);
if (jcdiService != null && jcdiService.isJCDIEnabled(getEjbBundleDescriptor())) {
try {
Class beanClass = classLoader.loadClass(getEjbClassName());
Constructor<?>[] ctors = beanClass.getDeclaredConstructors();
String[] parameterClassNames = null;
MethodDescriptor dummy = new MethodDescriptor();
for (Constructor<?> ctor : ctors) {
if (ctor.getAnnotation(Inject.class) != null) {
// @Inject constructor
Class[] ctorParamTypes = ctor.getParameterTypes();
parameterClassNames = dummy.getParameterClassNamesFor(null, ctorParamTypes);
callbackInterceptors = getClassOrMethodInterceptors(new MethodDescriptor(shortClassName, null, parameterClassNames, MethodDescriptor.EJB_BEAN));
break;
}
}
} catch (Throwable t) {
_logger.log(Level.SEVERE, "enterprise.deployment.backend.methodClassLoadFailure", new Object[] { this.getEjbClassName() });
throw new RuntimeException(t);
}
}
if (callbackInterceptors == null) {
// non-CDI or no @Inject constructor - use no-arg constructor
callbackInterceptors = getClassOrMethodInterceptors(new MethodDescriptor(shortClassName, null, new String[0], MethodDescriptor.EJB_BEAN));
}
return callbackInterceptors;
}
use of com.sun.enterprise.deployment.EjbInterceptor in project Payara by payara.
the class EjbDescriptor method addMethodLevelChain.
@Override
public void addMethodLevelChain(List<EjbInterceptor> chain, Method m, boolean aroundInvoke) {
if (chain.size() == 0) {
return;
}
MethodDescriptor methodDesc = new MethodDescriptor(m);
List<EjbInterceptor> existingChain = null;
for (MethodDescriptor next : methodInterceptorsMap.keySet()) {
if (next.implies(methodDesc)) {
existingChain = methodInterceptorsMap.get(methodDesc);
break;
}
}
if (existingChain != null) {
existingChain.addAll(chain);
} else {
List<EjbInterceptor> newChain = new LinkedList<EjbInterceptor>();
for (EjbInterceptor interceptor : interceptorChain) {
boolean include = aroundInvoke ? interceptor.hasAroundInvokeDescriptor() : interceptor.hasAroundTimeoutDescriptor();
if (include) {
newChain.add(interceptor);
}
}
newChain.addAll(chain);
methodInterceptorsMap.put(methodDesc, newChain);
}
}
use of com.sun.enterprise.deployment.EjbInterceptor in project Payara by payara.
the class EjbDescriptor method getAroundTimeoutInterceptors.
/**
* Return the ordered list of interceptor info for AroundTimeout behavior
* of a particular business method. This list *does* include the info
* on any bean class interceptor. If present, this would always be the
* last element in the list because of the precedence defined by the spec.
* @param businessMethod
* @return
*/
public List<EjbInterceptor> getAroundTimeoutInterceptors(MethodDescriptor businessMethod) {
LinkedList<EjbInterceptor> aroundTimeoutInterceptors = new LinkedList<EjbInterceptor>();
List<EjbInterceptor> classOrMethodInterceptors = getClassOrMethodInterceptors(businessMethod);
for (EjbInterceptor next : classOrMethodInterceptors) {
if (next.getAroundTimeoutDescriptors().size() > 0) {
aroundTimeoutInterceptors.add(next);
}
}
if (hasAroundTimeoutMethod()) {
EjbInterceptor interceptorInfo = new EjbInterceptor();
interceptorInfo.setFromBeanClass(true);
interceptorInfo.addAroundTimeoutDescriptors(getAroundTimeoutDescriptors());
interceptorInfo.setInterceptorClassName(getEjbImplClassName());
aroundTimeoutInterceptors.add(interceptorInfo);
}
return aroundTimeoutInterceptors;
}
use of com.sun.enterprise.deployment.EjbInterceptor in project Payara by payara.
the class EjbDescriptor method applyInterceptors.
/**
* Derive all interceptors that are applicable to this bean.
* @param bindingTranslator
*/
public void applyInterceptors(InterceptorBindingTranslator bindingTranslator) {
// Apply this ejb to the ordered set of all interceptor bindings
// for this ejb-jar. The results will contain all interceptor
// information that applies to the ejb. There is no notion of
// default interceptors within the results. Default interceptors
// are used during the translation process but once we derive
// the per-ejb interceptor information there is only a notion of
// class-level ordering and method-level ordering. Any applicable
// default interceptors will have been applied to the class-level.
TranslationResults results = bindingTranslator.apply(getName());
allInterceptorClasses.clear();
allInterceptorClasses.addAll(results.allInterceptorClasses);
interceptorChain.clear();
interceptorChain.addAll(results.classInterceptorChain);
methodInterceptorsMap.clear();
methodInterceptorsMap.putAll(results.methodInterceptorsMap);
for (EjbInterceptor interceptor : allInterceptorClasses) {
for (Object ejbRefObj : interceptor.getEjbReferenceDescriptors()) {
addEjbReferenceDescriptor((EjbReference) ejbRefObj);
}
for (Object msgDestRefObj : interceptor.getMessageDestinationReferenceDescriptors()) {
addMessageDestinationReferenceDescriptor((MessageDestinationReferenceDescriptor) msgDestRefObj);
}
for (Object envPropObj : interceptor.getEnvironmentProperties()) {
addOrMergeEnvironmentProperty((EnvironmentProperty) envPropObj);
}
for (Object servRefObj : interceptor.getServiceReferenceDescriptors()) {
addServiceReferenceDescriptor((ServiceReferenceDescriptor) servRefObj);
}
for (Object resRefObj : interceptor.getResourceReferenceDescriptors()) {
addResourceReferenceDescriptor((ResourceReferenceDescriptor) resRefObj);
}
for (Object resourceEnvRefObj : interceptor.getResourceEnvReferenceDescriptors()) {
addResourceEnvReferenceDescriptor((ResourceEnvReferenceDescriptor) resourceEnvRefObj);
}
for (EntityManagerFactoryReferenceDescriptor entMgrFacRef : interceptor.getEntityManagerFactoryReferenceDescriptors()) {
addEntityManagerFactoryReferenceDescriptor(entMgrFacRef);
}
for (EntityManagerReferenceDescriptor entMgrRef : interceptor.getEntityManagerReferenceDescriptors()) {
addEntityManagerReferenceDescriptor(entMgrRef);
}
}
}
Aggregations