use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor 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 org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor 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 org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class ConcurrencyManagementHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
ConcurrencyManagement cmAn = (ConcurrencyManagement) ainfo.getAnnotation();
ConcurrencyManagementType cmType = cmAn.value();
for (EjbContext ejbContext : ejbContexts) {
EjbDescriptor ejbDesc = ejbContext.getDescriptor();
if (ejbDesc instanceof EjbSessionDescriptor) {
EjbSessionDescriptor.ConcurrencyManagementType descCMType;
switch(cmType) {
case CONTAINER:
descCMType = EjbSessionDescriptor.ConcurrencyManagementType.Container;
break;
case BEAN:
descCMType = EjbSessionDescriptor.ConcurrencyManagementType.Bean;
break;
default:
throw new AnnotationProcessorException("Unsupported concurrency management " + "type = " + cmType);
}
EjbSessionDescriptor sDesc = (EjbSessionDescriptor) ejbDesc;
// Set value on descriptor unless it has been set by .xml
sDesc.setConcurrencyManagementTypeIfNotSet(descCMType);
}
}
return getDefaultProcessedResult();
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class PostActivateHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
for (EjbContext next : ejbContexts) {
EjbSessionDescriptor ejbSessionDescriptor = (EjbSessionDescriptor) next.getDescriptor();
ejbSessionDescriptor.addPostActivateDescriptor(getPostActivateDescriptor(ainfo));
}
return getDefaultProcessedResult();
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class RemoveHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
Remove remove = (Remove) ainfo.getAnnotation();
for (EjbContext next : ejbContexts) {
EjbSessionDescriptor sessionDescriptor = (EjbSessionDescriptor) next.getDescriptor();
Method m = (Method) ainfo.getAnnotatedElement();
MethodDescriptor removeMethod = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
EjbRemovalInfo removalInfo = sessionDescriptor.getRemovalInfo(removeMethod);
if (removalInfo == null) {
// if this element is not defined in xml
// use all information from annotation
removalInfo = new EjbRemovalInfo();
removalInfo.setRemoveMethod(removeMethod);
removalInfo.setRetainIfException(remove.retainIfException());
sessionDescriptor.addRemoveMethod(removalInfo);
} else {
// is not defined in xml
if (!removalInfo.isRetainIfExceptionSet()) {
removalInfo.setRetainIfException(remove.retainIfException());
}
}
}
return getDefaultProcessedResult();
}
Aggregations