use of com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.
the class BeforeCompletionHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
for (EjbContext ejbContext : ejbContexts) {
EjbSessionDescriptor ejbDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
Method annMethod = (Method) ainfo.getAnnotatedElement();
checkValid(annMethod);
if (logger.isLoggable(Level.FINE)) {
logger.fine("Setting BeforeCompletion method " + annMethod);
}
ejbDesc.setBeforeCompletionMethodIfNotSet(new MethodDescriptor(annMethod));
}
return getDefaultProcessedResult();
}
use of com.sun.enterprise.deployment.annotation.context.EjbContext 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.annotation.context.EjbContext in project Payara by payara.
the class InitHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
Init init = (Init) ainfo.getAnnotation();
for (EjbContext next : ejbContexts) {
EjbSessionDescriptor sessionDescriptor = (EjbSessionDescriptor) next.getDescriptor();
Method m = (Method) ainfo.getAnnotatedElement();
// Check for matching method on home and/or local home interface.
int numMatches = 0;
String adaptedCreateMethodName = init.value();
try {
if (sessionDescriptor.isRemoteInterfacesSupported()) {
addInitMethod(sessionDescriptor, m, adaptedCreateMethodName, false);
numMatches++;
}
} catch (Exception e) {
}
try {
if (sessionDescriptor.isLocalInterfacesSupported()) {
addInitMethod(sessionDescriptor, m, adaptedCreateMethodName, true);
numMatches++;
}
} catch (Exception e) {
}
if (numMatches == 0) {
log(Level.SEVERE, ainfo, localStrings.getLocalString("enterprise.deployment.annotation.handlers.notmatchcreate", "Unable to find matching Home create method for Init method {0} on bean {1}.", new Object[] { m, sessionDescriptor.getName() }));
return getDefaultFailedResult();
}
}
return getDefaultProcessedResult();
}
use of com.sun.enterprise.deployment.annotation.context.EjbContext 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 com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.
the class PrePassivateHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
for (EjbContext next : ejbContexts) {
EjbSessionDescriptor ejbSessionDescriptor = (EjbSessionDescriptor) next.getDescriptor();
ejbSessionDescriptor.addPrePassivateDescriptor(getPrePassivateDescriptor(ainfo));
}
return getDefaultProcessedResult();
}
Aggregations