use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class InterceptorBindingTranslator method apply.
public TranslationResults apply(String ejbName) {
if (isEmpty) {
return new TranslationResults();
}
defaultInterceptorChain.clear();
classInterceptorChain.clear();
hasTotalClassLevelOrdering = false;
totalClassLevelOrdering.clear();
methodInterceptorsMap.clear();
// Do a pass through default interceptor bindings.
for (InterceptorBindingDescriptor binding : interceptorBindings) {
if (binding.getBindingType() == BindingType.DEFAULT) {
defaultInterceptorChain.addAll(binding.getInterceptorClasses());
}
}
// Do a pass through Class level bindings.
for (InterceptorBindingDescriptor binding : interceptorBindings) {
if (binding.getBindingType() == BindingType.CLASS) {
if (binding.getEjbName().equals(ejbName)) {
processClassLevelBinding(binding);
}
}
}
// Now do method-level bindings.
Map<MethodDescriptor, List<InterceptorBindingDescriptor>> methodBindings = new HashMap<MethodDescriptor, List<InterceptorBindingDescriptor>>();
// bindings.
for (InterceptorBindingDescriptor binding : interceptorBindings) {
if ((binding.getEjbName().equals(ejbName)) && (binding.getBindingType() == BindingType.METHOD)) {
MethodDescriptor method = binding.getBusinessMethod();
List<InterceptorBindingDescriptor> methodBindingDescs = methodBindings.get(method);
if (methodBindingDescs == null) {
methodBindingDescs = new LinkedList<InterceptorBindingDescriptor>();
}
methodBindingDescs.add(binding);
methodBindings.put(method, methodBindingDescs);
}
}
for (Map.Entry<MethodDescriptor, List<InterceptorBindingDescriptor>> next : methodBindings.entrySet()) {
processMethod(next.getKey(), next.getValue());
}
TranslationResults results = buildResults();
return results;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class AccessTimeoutHandler method postProcessAnnotation.
/**
* Set the default value (from class type annotation) on all
* methods that don't have a value.
*/
public void postProcessAnnotation(AnnotationInfo ainfo, EjbContext ejbContext) throws AnnotationProcessorException {
EjbSessionDescriptor ejbDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
// At this point, all method-level specific annotations have been processed.
// For non-private methods, find the ones from the EjbContext's
// component definition view that are declared on this class. This will correctly
// eliminate any overridden methods and provide the most-derived version of each.
// Use the Class's declared methods list to get the private methods.
Class classAn = (Class) ainfo.getAnnotatedElement();
AccessTimeout timeoutAnn = (AccessTimeout) ainfo.getAnnotation();
List<Method> toProcess = new ArrayList<Method>();
for (Method m : ejbContext.getComponentDefinitionMethods()) {
if (classAn.equals(m.getDeclaringClass())) {
toProcess.add(m);
}
}
for (Method m : classAn.getDeclaredMethods()) {
if (Modifier.isPrivate(m.getModifiers())) {
toProcess.add(m);
}
}
for (Method m : toProcess) {
// descriptor, set it.
if (!matchesExistingAccessTimeoutMethod(m, ejbDesc)) {
MethodDescriptor newMethodDesc = new MethodDescriptor(m);
ejbDesc.addAccessTimeoutMethod(newMethodDesc, timeoutAnn.value(), timeoutAnn.unit());
}
}
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class AsynchronousHandler method setAsynchronous.
/**
* Designate a method as asynchronous in the deployment descriptor
* @param methodIntf null if processed on bean class / superclass. Otherwise,
* set to the remote/local client view of the associated interface
* @throws AnnotationProcessorException
*/
private void setAsynchronous(Method m0, EjbDescriptor ejbDesc, String methodIntf) throws AnnotationProcessorException {
if (!ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {
throw new AnnotationProcessorException("Invalid asynchronous method " + m0 + "@Asynchronous is only permitted for session beans");
}
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
MethodDescriptor methodDesc = (methodIntf == null) ? new MethodDescriptor(m0) : new MethodDescriptor(m0, methodIntf);
if (logger.isLoggable(Level.FINE)) {
logger.fine("Adding asynchronous method " + methodDesc);
}
// There is no way to "turn off" the asynchronous designation in the
// deployment descriptor, so we don't need to do any override checks
// here. Just always add any async methods.
sessionDesc.addAsynchronousMethod(methodDesc);
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class ExcludeDefaultInterceptorsHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
EjbBundleDescriptorImpl ejbBundle = ((EjbDescriptor) ejbContexts[0].getDescriptor()).getEjbBundleDescriptor();
for (EjbContext next : ejbContexts) {
EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
// Create binding information.
InterceptorBindingDescriptor binding = new InterceptorBindingDescriptor();
binding.setEjbName(ejbDescriptor.getName());
binding.setExcludeDefaultInterceptors(true);
if (ElementType.METHOD.equals(ainfo.getElementType())) {
Method m = (Method) ainfo.getAnnotatedElement();
MethodDescriptor md = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
binding.setBusinessMethod(md);
} else if (ElementType.CONSTRUCTOR.equals(ainfo.getElementType())) {
Constructor c = (Constructor) ainfo.getAnnotatedElement();
Class cl = c.getDeclaringClass();
Class[] ctorParamTypes = c.getParameterTypes();
String[] parameterClassNames = (new MethodDescriptor()).getParameterClassNamesFor(null, ctorParamTypes);
MethodDescriptor md = new MethodDescriptor(cl.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN);
binding.setBusinessMethod(md);
}
ejbBundle.prependInterceptorBinding(binding);
}
return getDefaultProcessedResult();
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class InitHandler method addInitMethod.
private void addInitMethod(EjbSessionDescriptor descriptor, Method beanMethod, String adaptedCreateMethodName, boolean local) throws Exception {
String homeIntfName = local ? descriptor.getLocalHomeClassName() : descriptor.getHomeClassName();
ClassLoader cl = descriptor.getEjbBundleDescriptor().getClassLoader();
Class homeIntf = cl.loadClass(homeIntfName);
Method createMethod = null;
if ((adaptedCreateMethodName == null) || (adaptedCreateMethodName.equals(""))) {
// signature.
for (Method next : homeIntf.getMethods()) {
if (next.getName().startsWith("create") && TypeUtil.sameParamTypes(next, beanMethod)) {
createMethod = next;
break;
}
}
if (createMethod == null) {
throw new NoSuchMethodException("No matching adapted home " + "method found for @Init " + " method " + beanMethod);
}
} else {
createMethod = homeIntf.getMethod(adaptedCreateMethodName, beanMethod.getParameterTypes());
}
MethodDescriptor beanMethodDescriptor = new MethodDescriptor(beanMethod, MethodDescriptor.EJB_BEAN);
MethodDescriptor createMethodDescriptor = new MethodDescriptor(createMethod, (local ? MethodDescriptor.EJB_HOME : MethodDescriptor.EJB_LOCALHOME));
EjbInitInfo initInfo = new EjbInitInfo();
initInfo.setBeanMethod(beanMethodDescriptor);
initInfo.setCreateMethod(createMethodDescriptor);
descriptor.addInitMethod(initInfo);
}
Aggregations