use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class ExcludeClassInterceptorsHandler 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.setExcludeClassInterceptors(true);
// Annotation can be defined at a method level or constructor level.
MethodDescriptor md = null;
if (ElementType.METHOD.equals(ainfo.getElementType())) {
Method m = (Method) ainfo.getAnnotatedElement();
md = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
} 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);
md = new MethodDescriptor(cl.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN);
}
// else throw Exception?
binding.setBusinessMethod(md);
ejbBundle.prependInterceptorBinding(binding);
}
return getDefaultProcessedResult();
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class LockHandler 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();
Class classAn = (Class) ainfo.getAnnotatedElement();
Lock lockAnn = (Lock) ainfo.getAnnotation();
// 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.
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 (!matchesExistingReadOrWriteLockMethod(m, ejbDesc)) {
MethodDescriptor newMethodDesc = new MethodDescriptor(m);
if (lockAnn.value() == LockType.WRITE) {
ejbDesc.addWriteLockMethod(newMethodDesc);
} else {
ejbDesc.addReadLockMethod(newMethodDesc);
}
}
}
}
use of com.sun.enterprise.deployment.MethodDescriptor 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<>();
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.MethodDescriptor in project Payara by payara.
the class EjbDescriptor method getMethodPermissions.
private Set<MethodPermission> getMethodPermissions(MethodDescriptor methodDescriptor) {
Set<MethodPermission> methodPermissionsForMethod = new HashSet<>();
for (Iterator<MethodPermission> e = this.getPermissionedMethodsByPermission().keySet().iterator(); e.hasNext(); ) {
MethodPermission nextPermission = e.next();
Set<MethodDescriptor> permissionedMethods = this.getPermissionedMethodsByPermission().get(nextPermission);
for (Iterator<MethodDescriptor> itr = permissionedMethods.iterator(); itr.hasNext(); ) {
MethodDescriptor md = itr.next();
if (md.equals(methodDescriptor)) {
methodPermissionsForMethod.add(nextPermission);
}
}
}
return methodPermissionsForMethod;
}
use of com.sun.enterprise.deployment.MethodDescriptor in project Payara by payara.
the class EjbDescriptor method setMethodContainerTransactions.
/**
* Sets the container transactions for all the method descriptors of this ejb. The Hashtable is keyed by method
* descriptor and the values are the corresponding container transaction objects.. Throws an Illegal argument if this
* ejb has transaction type BEAN_TRANSACTION_TYPE.
*
* @param methodContainerTransactions
*/
public void setMethodContainerTransactions(Hashtable<MethodDescriptor, ContainerTransaction> methodContainerTransactions) {
if (methodContainerTransactions != null) {
for (Enumeration<MethodDescriptor> e = methodContainerTransactions.keys(); e.hasMoreElements(); ) {
MethodDescriptor methodDescriptor = e.nextElement();
ContainerTransaction containerTransaction = methodContainerTransactions.get(methodDescriptor);
setContainerTransactionFor(methodDescriptor, containerTransaction);
}
}
}
Aggregations