Search in sources :

Example 26 with EjbSessionDescriptor

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;
}
Also used : SecurityManager(com.sun.enterprise.security.SecurityManager) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)

Example 27 with EjbSessionDescriptor

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);
        }
    }
}
Also used : EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) CheckpointAtEndOfMethodDescriptor(org.glassfish.ejb.deployment.descriptor.runtime.CheckpointAtEndOfMethodDescriptor) IllegalLoopbackException(javax.ejb.IllegalLoopbackException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoveException(javax.ejb.RemoveException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) SystemException(javax.transaction.SystemException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException)

Example 28 with EjbSessionDescriptor

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);
    }
}
Also used : ArrayList(java.util.ArrayList) EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor) InterceptorDescriptor(com.sun.enterprise.deployment.InterceptorDescriptor) CallbackType(com.sun.enterprise.deployment.LifecycleCallbackDescriptor.CallbackType) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)

Example 29 with EjbSessionDescriptor

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();
}
Also used : AccessTimeout(javax.ejb.AccessTimeout) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Example 30 with EjbSessionDescriptor

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();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor)

Aggregations

EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)78 Result (com.sun.enterprise.tools.verifier.Result)28 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)28 Method (java.lang.reflect.Method)25 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)23 EjbEntityDescriptor (org.glassfish.ejb.deployment.descriptor.EjbEntityDescriptor)18 VerifierTestContext (com.sun.enterprise.tools.verifier.VerifierTestContext)11 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)10 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)7 Iterator (java.util.Iterator)6 ContainerTransaction (org.glassfish.ejb.deployment.descriptor.ContainerTransaction)6 Set (java.util.Set)5 EJBException (javax.ejb.EJBException)4 Container (com.sun.ejb.Container)3 EjbInterceptor (com.sun.enterprise.deployment.EjbInterceptor)3 LifecycleCallbackDescriptor (com.sun.enterprise.deployment.LifecycleCallbackDescriptor)3 AnnotatedElement (java.lang.reflect.AnnotatedElement)3 ArrayList (java.util.ArrayList)3 Enumeration (java.util.Enumeration)3 NoSuchEJBException (javax.ejb.NoSuchEJBException)3