use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.
the class AsynchronousHandler method postProcessAnnotation.
/**
* Set the default value (from class type annotation) on all
* methods that don't have a value.
* Class type annotation applies to all EJB 3.x Local/Remote/no-interface
* views in which that business method is exposed for that bean.
*/
public void postProcessAnnotation(AnnotationInfo ainfo, EjbContext ejbContext) throws AnnotationProcessorException {
EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
Class classAn = (Class) ainfo.getAnnotatedElement();
Method[] methods = classAn.getDeclaredMethods();
for (Method m0 : methods) {
setAsynchronous(m0, ejbDesc);
}
}
use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.
the class AsynchronousHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
for (EjbContext ejbContext : ejbContexts) {
EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
if (ElementType.TYPE.equals(ainfo.getElementType())) {
ejbContext.addPostProcessInfo(ainfo, this);
} else {
Method annMethod = (Method) ainfo.getAnnotatedElement();
setAsynchronous(annMethod, ejbDesc);
}
}
return getDefaultProcessedResult();
}
use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor 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 org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.
the class TransactionAttributeHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
TransactionAttribute taAn = (TransactionAttribute) ainfo.getAnnotation();
for (EjbContext ejbContext : ejbContexts) {
EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
ContainerTransaction containerTransaction = getContainerTransaction(taAn.value());
if (ElementType.TYPE.equals(ainfo.getElementType())) {
ejbContext.addPostProcessInfo(ainfo, this);
} else {
Method annMethod = (Method) ainfo.getAnnotatedElement();
Set txBusMethods = ejbDesc.getTxBusinessMethodDescriptors();
for (Object next : txBusMethods) {
MethodDescriptor nextDesc = (MethodDescriptor) next;
Method m = nextDesc.getMethod(ejbDesc);
if (TypeUtil.sameMethodSignature(m, annMethod) && ejbDesc.getContainerTransactionFor(nextDesc) == null) {
// override by xml
ejbDesc.setContainerTransactionFor(nextDesc, containerTransaction);
}
}
if (ejbDesc instanceof EjbSessionDescriptor) {
EjbSessionDescriptor sd = (EjbSessionDescriptor) ejbDesc;
if (sd.isStateful() || sd.isSingleton()) {
ClassLoader loader = ejbDesc.getEjbBundleDescriptor().getClassLoader();
Set<LifecycleCallbackDescriptor> lcds = ejbDesc.getLifecycleCallbackDescriptors();
for (LifecycleCallbackDescriptor lcd : lcds) {
if (lcd.getLifecycleCallbackClass().equals(ejbDesc.getEjbClassName()) && lcd.getLifecycleCallbackMethod().equals(annMethod.getName())) {
try {
Method m = lcd.getLifecycleCallbackMethodObject(loader);
MethodDescriptor md = new MethodDescriptor(m, MethodDescriptor.LIFECYCLE_CALLBACK);
if (TypeUtil.sameMethodSignature(m, annMethod) && ejbDesc.getContainerTransactionFor(md) == null) {
// stateful lifecycle callback txn attr type EJB spec
if (sd.isStateful() && containerTransaction != null) {
String txAttr = containerTransaction.getTransactionAttribute();
if (txAttr != null && !txAttr.equals(ContainerTransaction.REQUIRES_NEW) && !txAttr.equals(ContainerTransaction.NOT_SUPPORTED)) {
logger.log(Level.WARNING, localStrings.getLocalString("enterprise.deployment.annotation.handlers.sfsblifecycletxnattrtypewarn", "Stateful session bean {0} lifecycle callback method {1} has transaction " + "attribute {2} with container-managed transaction demarcation. " + "The transaction attribute should be either REQUIRES_NEW or NOT_SUPPORTED", new Object[] { (sd.getName() == null ? "" : sd.getName()), m.getName(), txAttr }));
}
}
// override by xml
ejbDesc.setContainerTransactionFor(md, containerTransaction);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Found matching callback method {0}<>{1} : {2}", new Object[] { ejbDesc.getEjbClassName(), md, containerTransaction });
}
}
} catch (Exception e) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Transaction attribute for a lifecycle callback annotation processing error", e);
}
}
}
}
}
}
}
}
return getDefaultProcessedResult();
}
use of org.glassfish.ejb.deployment.descriptor.EjbDescriptor in project Payara by payara.
the class ScheduleHandler method processSchedule.
protected HandlerProcessingResult processSchedule(Schedule sch, AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
for (EjbContext ejbContext : ejbContexts) {
EjbDescriptor ejbDesc = (EjbDescriptor) ejbContext.getDescriptor();
if (ElementType.METHOD.equals(ainfo.getElementType())) {
Method annMethod = (Method) ainfo.getAnnotatedElement();
// .xml-defined timer method overrides @Schedule
if (!ejbDesc.hasScheduledTimerMethodFromDD(annMethod)) {
ScheduledTimerDescriptor sd = new ScheduledTimerDescriptor();
sd.setSecond(sch.second());
sd.setMinute(sch.minute());
sd.setHour(sch.hour());
sd.setDayOfMonth(sch.dayOfMonth());
sd.setMonth(sch.month());
sd.setDayOfWeek(sch.dayOfWeek());
sd.setYear(sch.year());
sd.setTimezone(sch.timezone());
sd.setPersistent(sch.persistent());
sd.setInfo(sch.info());
sd.setTimeoutMethod(new MethodDescriptor(annMethod));
ejbDesc.addScheduledTimerDescriptor(sd);
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "@@@ Found Schedule on {0}", annMethod);
logger.log(Level.FINE, "@@@ TimerConfig : {0} # {1}", new Object[] { (sd.getInfo() != null && !sd.getInfo().equals("")) ? sd.getInfo() : null, sd.getPersistent() });
}
}
}
}
return getDefaultProcessedResult();
}
Aggregations