use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class SingletonContainerFactory method createContainer.
@Override
public Container createContainer(EjbDescriptor ejbDescriptor, ClassLoader loader, DeploymentContext deployContext) throws Exception {
// hence we can always cast
assert ejbDescriptor instanceof EjbSessionDescriptor;
EjbSessionDescriptor sd = (EjbSessionDescriptor) ejbDescriptor;
AbstractSingletonContainer container;
SecurityManager sm = getSecurityManager(ejbDescriptor);
if (sd.hasContainerManagedConcurrency()) {
container = new CMCSingletonContainer(ejbDescriptor, loader, sm);
} else {
container = new BMCSingletonContainer(ejbDescriptor, loader, sm);
}
container.initializeHome();
return container;
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class AsynchronousTask method initSessionSyncMethods.
private void initSessionSyncMethods() throws Exception {
if (SessionSynchronization.class.isAssignableFrom(ejbClass)) {
try {
afterBeginMethod = ejbClass.getMethod("afterBegin", null);
beforeCompletionMethod = ejbClass.getMethod("beforeCompletion", null);
afterCompletionMethod = ejbClass.getMethod("afterCompletion", Boolean.TYPE);
} catch (Exception e) {
_logger.log(Level.WARNING, EXCEPTION_WHILE_INITIALIZING_SESSION_SYNCHRONIZATION, e);
}
} else {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDescriptor;
MethodDescriptor afterBeginMethodDesc = sessionDesc.getAfterBeginMethod();
if (afterBeginMethodDesc != null) {
afterBeginMethod = afterBeginMethodDesc.getDeclaredMethod(sessionDesc);
processSessionSynchMethod(afterBeginMethod);
}
MethodDescriptor beforeCompletionMethodDesc = sessionDesc.getBeforeCompletionMethod();
if (beforeCompletionMethodDesc != null) {
beforeCompletionMethod = beforeCompletionMethodDesc.getDeclaredMethod(sessionDesc);
processSessionSynchMethod(beforeCompletionMethod);
}
MethodDescriptor afterCompletionMethodDesc = sessionDesc.getAfterCompletionMethod();
if (afterCompletionMethodDesc != null) {
afterCompletionMethod = afterCompletionMethodDesc.getDeclaredMethod(sessionDesc);
if (afterCompletionMethod == null) {
afterCompletionMethod = afterCompletionMethodDesc.getDeclaredMethod(sessionDesc, new Class[] { Boolean.TYPE });
}
processSessionSynchMethod(afterCompletionMethod);
}
}
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class BeanCallbackInterceptor method initEjbCallbackIndices.
private void initEjbCallbackIndices() throws ClassNotFoundException, Exception {
int size = CallbackType.values().length;
ArrayList[] callbacks = new ArrayList[size];
boolean scanFor2xLifecycleMethods = true;
int numPostConstructFrameworkCallbacks = 0;
for (CallbackType eventType : CallbackType.values()) {
int index = eventType.ordinal();
callbacks[index] = new ArrayList<CallbackInterceptor>();
boolean scanForCallbacks = true;
if (!(ejbDesc instanceof EjbSessionDescriptor)) {
if ((eventType == CallbackType.PRE_PASSIVATE) || (eventType == CallbackType.POST_ACTIVATE)) {
scanForCallbacks = false;
}
}
if (scanForCallbacks) {
// Make sure any framework interceptors are first
for (InterceptorDescriptor callback : frameworkInterceptors) {
if (callback.hasCallbackDescriptor(eventType)) {
Class interceptorClass = callback.getInterceptorClass();
ClassLoader classLoaderToUse = (interceptorClass != null) ? interceptorClass.getClassLoader() : loader;
List<CallbackInterceptor> inters = createCallbackInterceptors(eventType, callback, classLoaderToUse);
for (CallbackInterceptor inter : inters) {
callbacks[index].add(inter);
if (eventType == CallbackType.POST_CONSTRUCT) {
numPostConstructFrameworkCallbacks++;
}
}
}
}
List<EjbInterceptor> callbackList = ejbDesc.getCallbackInterceptors(eventType);
// to scan for the old 2.x style lifecycle methods
if (callbackList.size() > 0) {
scanFor2xLifecycleMethods = false;
}
for (EjbInterceptor callback : callbackList) {
List<CallbackInterceptor> inters = createCallbackInterceptors(eventType, callback);
for (CallbackInterceptor inter : inters) {
callbacks[index].add(inter);
}
}
}
}
if (scanFor2xLifecycleMethods) {
load2xLifecycleMethods(callbacks);
}
// The next set of lines are to handle the case where
// the app doesn't have a @PostConstruct or it
// doesn't implement the EntrerpriseBean interface
// In this case we scan for ejbCreate() for MDBs and SLSBs
boolean lookForEjbCreateMethod = container.scanForEjbCreateMethod();
if (lookForEjbCreateMethod) {
loadOnlyEjbCreateMethod(callbacks, numPostConstructFrameworkCallbacks);
}
callbackChain = new CallbackChainImpl[size];
for (CallbackType eventType : CallbackType.values()) {
int index = eventType.ordinal();
CallbackInterceptor[] interceptors = (CallbackInterceptor[]) callbacks[index].toArray(new CallbackInterceptor[callbacks[index].size()]);
callbackChain[index] = new CallbackChainImpl(interceptors);
}
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class AccessTimeoutHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
AccessTimeout timeout = (AccessTimeout) ainfo.getAnnotation();
for (EjbContext ejbContext : ejbContexts) {
if (ejbContext.getDescriptor() instanceof EjbSessionDescriptor) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
if (sessionDesc.isStateless()) {
continue;
}
if (ElementType.TYPE.equals(ainfo.getElementType())) {
// Delay processing Class-level default until after methods are processed
ejbContext.addPostProcessInfo(ainfo, this);
} else {
Method annMethod = (Method) ainfo.getAnnotatedElement();
// are overridden and applies the correct .xml overriding semantics.
if (!matchesExistingAccessTimeoutMethod(annMethod, sessionDesc)) {
MethodDescriptor newMethodDesc = new MethodDescriptor(annMethod);
sessionDesc.addAccessTimeoutMethod(newMethodDesc, timeout.value(), timeout.unit());
}
}
}
}
return getDefaultProcessedResult();
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class AfterBeginHandler 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 AfterBegin method " + annMethod);
}
ejbDesc.setAfterBeginMethodIfNotSet(new MethodDescriptor(annMethod));
}
return getDefaultProcessedResult();
}
Aggregations