Search in sources :

Example 36 with EjbSessionDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.

the class StatefulHandler method setEjbDescriptorInfo.

/**
 * Set Annotation information to Descriptor.
 * This method will also be invoked for an existing descriptor with
 * annotation as user may not specific a complete xml.
 * @param ejbDesc
 * @param ainfo
 * @return HandlerProcessingResult
 */
protected HandlerProcessingResult setEjbDescriptorInfo(EjbDescriptor ejbDesc, AnnotationInfo ainfo) throws AnnotationProcessorException {
    EjbSessionDescriptor ejbSessionDesc = (EjbSessionDescriptor) ejbDesc;
    // set session bean type in case it wasn't set in a sparse ejb-jar.xml.
    if (!ejbSessionDesc.isSessionTypeSet()) {
        ejbSessionDesc.setSessionType(EjbSessionDescriptor.STATEFUL);
    }
    Stateful sful = (Stateful) ainfo.getAnnotation();
    doDescriptionProcessing(sful.description(), ejbDesc);
    doMappedNameProcessing(sful.mappedName(), ejbDesc);
    // set passivation capable property in case it wasn't set in ejb-jar.xml
    if (!ejbSessionDesc.isPassivationCapableSet()) {
        ejbSessionDesc.setPassivationCapable(sful.passivationCapable());
    }
    return setBusinessAndHomeInterfaces(ejbDesc, ainfo);
}
Also used : Stateful(javax.ejb.Stateful) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)

Example 37 with EjbSessionDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.

the class StatelessHandler method setEjbDescriptorInfo.

/**
 * Set Annotation information to Descriptor.
 * This method will also be invoked for an existing descriptor with
 * annotation as user may not specific a complete xml.
 * @param ejbDesc
 * @param ainfo
 * @return HandlerProcessingResult
 */
protected HandlerProcessingResult setEjbDescriptorInfo(EjbDescriptor ejbDesc, AnnotationInfo ainfo) throws AnnotationProcessorException {
    EjbSessionDescriptor ejbSessionDesc = (EjbSessionDescriptor) ejbDesc;
    // set session bean type in case it wasn't set in a sparse ejb-jar.xml.
    if (!ejbSessionDesc.isSessionTypeSet()) {
        ejbSessionDesc.setSessionType(EjbSessionDescriptor.STATELESS);
    }
    Stateless sless = (Stateless) ainfo.getAnnotation();
    doDescriptionProcessing(sless.description(), ejbDesc);
    doMappedNameProcessing(sless.mappedName(), ejbDesc);
    return setBusinessAndHomeInterfaces(ejbDesc, ainfo);
}
Also used : Stateless(javax.ejb.Stateless) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)

Example 38 with EjbSessionDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.

the class StatelessHandler method createEjbDescriptor.

/**
 * Create a new EjbDescriptor for a given elementName and AnnotationInfo.
 * @param elementName
 * @param ainfo
 * @return a new EjbDescriptor
 */
protected EjbDescriptor createEjbDescriptor(String elementName, AnnotationInfo ainfo) throws AnnotationProcessorException {
    AnnotatedElement ae = ainfo.getAnnotatedElement();
    Class ejbClass = (Class) ae;
    EjbSessionDescriptor newDescriptor = new EjbSessionDescriptor();
    newDescriptor.setName(elementName);
    newDescriptor.setEjbClassName(ejbClass.getName());
    newDescriptor.setSessionType(EjbSessionDescriptor.STATELESS);
    return newDescriptor;
}
Also used : AnnotatedElement(java.lang.reflect.AnnotatedElement) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)

Example 39 with EjbSessionDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.

the class EjbApplication method loadContainers.

/**
 * Initial phase of continer initialization.  This creates the concrete container
 * instance for each EJB component, registers JNDI entries, etc.  However, no
 * EJB bean instances or invocations occur during this phase.  Those must be
 * delayed until start() is called.
 * @param startupContext
 * @return
 */
boolean loadContainers(ApplicationContext startupContext) {
    DeploymentContext dc = (DeploymentContext) startupContext;
    String dcMapToken = "org.glassfish.ejb.startup.SingletonLCM";
    singletonLCM = dc.getTransientAppMetaData(dcMapToken, SingletonLifeCycleManager.class);
    if (singletonLCM == null) {
        singletonLCM = new SingletonLifeCycleManager(initializeInOrder);
        dc.addTransientAppMetaData(dcMapToken, singletonLCM);
    }
    if (!initializeInOrder) {
        dc.addTransientAppMetaData(EJB_APP_MARKED_AS_STARTED_STATUS, Boolean.FALSE);
        List<EjbApplication> ejbAppList = dc.getTransientAppMetaData(CONTAINER_LIST_KEY, List.class);
        if (ejbAppList == null) {
            ejbAppList = new ArrayList<EjbApplication>();
            dc.addTransientAppMetaData(CONTAINER_LIST_KEY, ejbAppList);
        }
        ejbAppList.add(this);
    }
    try {
        policyLoader.loadPolicy();
        for (EjbDescriptor desc : ejbs) {
            // Initialize each ejb container (setup component environment, register JNDI objects, etc.)
            // Any instance instantiation , timer creation/restoration, message inflow is delayed until
            // start phase.
            ContainerFactory ejbContainerFactory = services.getService(ContainerFactory.class, desc.getContainerFactoryQualifier());
            if (ejbContainerFactory == null) {
                String errMsg = localStrings.getLocalString("invalid.container.module", "Container module is not available", desc.getEjbTypeForDisplay());
                throw new RuntimeException(errMsg);
            }
            Container container = ejbContainerFactory.createContainer(desc, ejbAppClassLoader, dc);
            containers.add(container);
            if (desc instanceof EjbSessionDescriptor && ((EjbSessionDescriptor) desc).isSingleton()) {
                singletonLCM.addSingletonContainer(this, (AbstractSingletonContainer) container);
            }
        }
    } catch (Throwable t) {
        abortInitializationAfterException();
        throw new RuntimeException("EJB Container initialization error", t);
    } finally {
        // clean up the thread local current classloader after codegen to ensure it isn't
        // referencing the deployed application
        CurrentClassLoader.set(this.getClass().getClassLoader());
        Wrapper._clear();
    }
    return true;
}
Also used : DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) Container(com.sun.ejb.Container) AbstractSingletonContainer(com.sun.ejb.containers.AbstractSingletonContainer) ApplicationContainer(org.glassfish.api.deployment.ApplicationContainer) ContainerFactory(com.sun.ejb.ContainerFactory) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Example 40 with EjbSessionDescriptor

use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.

the class SingletonLifeCycleManager method doStartup.

void doStartup(EjbApplication ejbApp) {
    Collection<EjbDescriptor> ejbs = ejbApp.getEjbBundleDescriptor().getEjbs();
    for (EjbDescriptor desc : ejbs) {
        if (desc instanceof EjbSessionDescriptor) {
            EjbSessionDescriptor sdesc = (EjbSessionDescriptor) desc;
            if ((sdesc.isSingleton())) {
                if (sdesc.getInitOnStartup()) {
                    String normalizedSingletonName = normalizeSingletonName(sdesc.getName(), sdesc);
                    initializeSingleton(name2Container.get(normalizedSingletonName));
                }
            }
        }
    }
}
Also used : EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

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