//get Current TCL
ClassLoader oldTCL = Thread.currentThread().getContextClassLoader();
final String fAppName = appInfo.getName();
invocationManager.pushAppEnvironment(new ApplicationEnvironment() {
@Override
public String getName() {
return fAppName;
}
});
try {
bootstrap.startExtensions(deploymentImpl.getExtensions());
bootstrap.startContainer(Environments.SERVLET, deploymentImpl/*, new ConcurrentHashMapBeanStore()*/);
bootstrap.startInitialization();
fireProcessInjectionTargetEvents(bootstrap, deploymentImpl);
bootstrap.deployBeans();
} catch (Throwable t) {
try {
doBootstrapShutdown(appInfo);
} finally {
// ignore.
}
String msgPrefix = getDeploymentErrorMsgPrefix( t );
DeploymentException de = new DeploymentException(msgPrefix + t.getMessage());
de.initCause(t);
throw(de);
} finally {
invocationManager.popAppEnvironment();
//The TCL is originally the EAR classloader
//and is reset during Bean deployment to the
//corresponding module classloader in BeanDeploymentArchiveImpl.getBeans
//for Bean classloading to succeed. The TCL is reset
//to its old value here.
Thread.currentThread().setContextClassLoader(oldTCL);
}
}
} else if ( event.is(org.glassfish.internal.deployment.Deployment.APPLICATION_STARTED) ) {
ApplicationInfo appInfo = (ApplicationInfo)event.hook();
WeldBootstrap bootstrap = appInfo.getTransientAppMetaData(WELD_BOOTSTRAP,
WeldBootstrap.class);
if( bootstrap != null ) {
final String fAppName = appInfo.getName();
invocationManager.pushAppEnvironment(new ApplicationEnvironment() {
@Override
public String getName() {
return fAppName;
}
});
try {
bootstrap.validateBeans();
bootstrap.endInitialization();
} catch (Throwable t) {
try {
doBootstrapShutdown(appInfo);
} finally {
// ignore.
}
String msgPrefix = getDeploymentErrorMsgPrefix( t );
DeploymentException de = new DeploymentException( msgPrefix + t.getMessage());
de.initCause(t);
throw(de);
}
finally {
invocationManager.popAppEnvironment();
}
}
} else if ( event.is(org.glassfish.internal.deployment.Deployment.APPLICATION_STOPPED) ||
event.is(org.glassfish.internal.deployment.Deployment.APPLICATION_UNLOADED) ||
event.is(org.glassfish.internal.deployment.Deployment.APPLICATION_DISABLED)) {
ApplicationInfo appInfo = (ApplicationInfo)event.hook();
Application app = appInfo.getMetaData(Application.class);
if( app != null ) {
for(BundleDescriptor next : app.getBundleDescriptors()) {
if( next instanceof EjbBundleDescriptor || next instanceof WebBundleDescriptor ) {
bundleToBeanDeploymentArchive.remove(next);
}
}
appToBootstrap.remove(app);
}
String shutdown = appInfo.getTransientAppMetaData(WELD_SHUTDOWN, String.class);
if (Boolean.valueOf(shutdown).equals(Boolean.TRUE)) {
return;
}
ClassLoader currentContextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(appInfo.getAppClassLoader());
try {
WeldBootstrap bootstrap = appInfo.getTransientAppMetaData(WELD_BOOTSTRAP, WeldBootstrap.class);
if (bootstrap != null) {
final String fAppName = appInfo.getName();
invocationManager.pushAppEnvironment(new ApplicationEnvironment() {
@Override
public String getName() {
return fAppName;
}
});