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;
}
Aggregations