use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.
the class ContainerTransactionNode method endElement.
@Override
public boolean endElement(XMLElement element) {
boolean doneWithNode = super.endElement(element);
if (doneWithNode) {
ContainerTransaction ct = new ContainerTransaction(trans_attribute, description);
for (Iterator methodsIterator = methods.iterator(); methodsIterator.hasNext(); ) {
MethodDescriptor md = (MethodDescriptor) methodsIterator.next();
EjbBundleDescriptorImpl bundle = (EjbBundleDescriptorImpl) getParentNode().getDescriptor();
EjbDescriptor ejb = bundle.getEjbByName(md.getEjbName(), true);
ejb.getMethodContainerTransactions().put(md, ct);
}
}
return doneWithNode;
}
use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.
the class AroundTimeoutHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
for (EjbContext next : ejbContexts) {
EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
ejbDescriptor.addAroundTimeoutDescriptor(getAroundInvocationDescriptor(ainfo));
}
return getDefaultProcessedResult();
}
use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor 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 org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.
the class InterceptorsHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
Interceptors interceptors = (Interceptors) ainfo.getAnnotation();
EjbBundleDescriptorImpl ejbBundle = ((EjbDescriptor) ejbContexts[0].getDescriptor()).getEjbBundleDescriptor();
// Process each of the interceptor classes.
for (Class interceptor : interceptors.value()) {
processInterceptorClass(interceptor, ejbBundle, ainfo);
}
for (EjbContext next : ejbContexts) {
EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
// Create binding information.
InterceptorBindingDescriptor binding = new InterceptorBindingDescriptor();
binding.setEjbName(ejbDescriptor.getName());
for (Class interceptor : interceptors.value()) {
binding.appendInterceptorClass(interceptor.getName());
}
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);
}
// All binding information processed from annotations should go
// before the binding information processed from the descriptors.
// Since descriptors are processed first, always place the binding
// info at the front. The binding information from the descriptor
// is ordered, but there is no prescribed order in which the
// annotations are processed, so all that matters is that it's
// before the descriptor bindings and that the descriptor binding
// order is preserved.
ejbBundle.prependInterceptorBinding(binding);
}
return getDefaultProcessedResult();
}
use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.
the class TransactionAttributeHandler 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 {
EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
TransactionAttribute taAn = (TransactionAttribute) ainfo.getAnnotation();
ContainerTransaction containerTransaction = getContainerTransaction(taAn.value());
Class classAn = (Class) ainfo.getAnnotatedElement();
Set txBusMethods = ejbDesc.getTxBusinessMethodDescriptors();
for (Object mdObj : txBusMethods) {
MethodDescriptor md = (MethodDescriptor) mdObj;
// override by xml
if (classAn.equals(ejbContext.getDeclaringClass(md)) && ejbDesc.getContainerTransactionFor(md) == null) {
ejbDesc.setContainerTransactionFor(md, containerTransaction);
}
}
}
Aggregations