use of org.apache.openejb.assembler.classic.event.ContainerSystemPostCreate in project tomee by apache.
the class Assembler method buildContainerSystem.
/////////////////////////////////////////////////////////////////////
////
//// Public Methods Used for Assembly
////
/////////////////////////////////////////////////////////////////////
/**
* When given a complete OpenEjbConfiguration graph this method
* will construct an entire container system and return a reference to that
* container system, as ContainerSystem instance.
* <p/>
* This method leverage the other assemble and apply methods which
* can be used independently.
* <p/>
* Assembles and returns the {@link CoreContainerSystem} using the
* information from the {@link OpenEjbConfiguration} object passed in.
* <pre>
* This method performs the following actions(in order):
*
* 1 Assembles ProxyFactory
* 2 Assembles External JNDI Contexts
* 3 Assembles TransactionService
* 4 Assembles SecurityService
* 5 Assembles ConnectionManagers
* 6 Assembles Connectors
* 7 Assembles Containers
* 8 Assembles Applications
* </pre>
*
* @param configInfo OpenEjbConfiguration
* @throws Exception if there was a problem constructing the ContainerSystem.
* @see OpenEjbConfiguration
*/
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
public void buildContainerSystem(final OpenEjbConfiguration configInfo) throws Exception {
final SystemInstance systemInstance = SystemInstance.get();
if (systemInstance.getOptions().get(OPENEJB_JPA_DEPLOY_TIME_ENHANCEMENT_PROP, false)) {
systemInstance.addObserver(new DeployTimeEnhancer());
}
if (hasBatchEE()) {
systemInstance.addObserver(new BatchEEServiceManager());
}
for (final ServiceInfo serviceInfo : configInfo.facilities.services) {
createService(serviceInfo);
}
final ContainerSystemInfo containerSystemInfo = configInfo.containerSystem;
if (configInfo.facilities.intraVmServer != null) {
createProxyFactory(configInfo.facilities.intraVmServer);
}
for (final JndiContextInfo contextInfo : configInfo.facilities.remoteJndiContexts) {
createExternalContext(contextInfo);
}
createTransactionManager(configInfo.facilities.transactionService);
createSecurityService(configInfo.facilities.securityService);
final Set<String> reservedResourceIds = new HashSet<>(configInfo.facilities.resources.size());
for (final AppInfo appInfo : containerSystemInfo.applications) {
reservedResourceIds.addAll(appInfo.resourceIds);
}
final Set<String> rIds = new HashSet<>(configInfo.facilities.resources.size());
for (final ResourceInfo resourceInfo : configInfo.facilities.resources) {
createResource(configInfo.facilities.services, resourceInfo);
rIds.add(resourceInfo.id);
}
rIds.removeAll(reservedResourceIds);
final ContainerSystem component = systemInstance.getComponent(ContainerSystem.class);
if (component != null) {
postConstructResources(rIds, ParentClassLoaderFinder.Helper.get(), component.getJNDIContext(), null);
} else {
throw new RuntimeException("ContainerSystem has not been initialzed");
}
// Containers
for (final ContainerInfo serviceInfo : containerSystemInfo.containers) {
createContainer(serviceInfo);
}
// before any deployment bind global to be able to share the same context
createJavaGlobal();
for (final AppInfo appInfo : containerSystemInfo.applications) {
try {
createApplication(appInfo, createAppClassLoader(appInfo));
} catch (final DuplicateDeploymentIdException e) {
// already logged.
} catch (final Throwable e) {
logger.error("appNotDeployed", e, appInfo.path);
final DeploymentExceptionManager exceptionManager = systemInstance.getComponent(DeploymentExceptionManager.class);
if (exceptionManager != null && e instanceof Exception) {
exceptionManager.saveDeploymentException(appInfo, (Exception) e);
}
}
}
systemInstance.fireEvent(new ContainerSystemPostCreate());
}
Aggregations