Search in sources :

Example 1 with ContainerFactory

use of com.sun.ejb.ContainerFactory in project Payara by payara.

the class EjbApplication method loadContainers.

/**
 * Initial phase of container 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<>();
            dc.addTransientAppMetaData(CONTAINER_LIST_KEY, ejbAppList);
        }
        ejbAppList.add(this);
    }
    try {
        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)

Aggregations

Container (com.sun.ejb.Container)1 ContainerFactory (com.sun.ejb.ContainerFactory)1 AbstractSingletonContainer (com.sun.ejb.containers.AbstractSingletonContainer)1 ApplicationContainer (org.glassfish.api.deployment.ApplicationContainer)1 DeploymentContext (org.glassfish.api.deployment.DeploymentContext)1 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)1 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)1 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)1