use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.
the class EjbApplication method stop.
public boolean stop(ApplicationContext stopContext) {
DeploymentContext depc = (DeploymentContext) stopContext;
OpsParams params = depc.getCommandParameters(OpsParams.class);
boolean keepState = false;
// keepstate remains the default value (false).
if (params.origin.isUndeploy()) {
keepState = resolveKeepStateOptions(depc, false, ejbBundle);
if (keepState) {
Properties appProps = depc.getAppProps();
Object appId = appProps.get(EjbDeployer.APP_UNIQUE_ID_PROP);
Properties actionReportProps = null;
if (ejbBundle.getApplication().isVirtual()) {
actionReportProps = depc.getActionReport().getExtraProperties();
} else {
// the application is EAR
ExtendedDeploymentContext exdc = (ExtendedDeploymentContext) depc;
actionReportProps = exdc.getParentContext().getActionReport().getExtraProperties();
}
actionReportProps.put(EjbDeployer.APP_UNIQUE_ID_PROP, appId);
actionReportProps.put(EjbApplication.KEEP_STATE, String.valueOf(true));
_logger.log(Level.INFO, "keepstate options resolved to true, saving appId {0} for application {1}.", new Object[] { appId, params.name() });
}
}
// If true we're shutting down b/c of an undeploy or a fatal error during
// deployment. If false, it's a shutdown where the application will remain
// deployed.
boolean undeploy = (params.origin.isUndeploy() || params.origin.isDeploy());
// and Application. For failed deploy, keepstate is the default value (false).
if (undeploy) {
// store keepstate in ApplicationInfo to make it available to
// EjbDeployer.clean(). A different instance of DeploymentContext
// is passed to EjbDeployer.clean so we cannot use anything in DC (e.g.
// appProps, transientData) to store keepstate.
ApplicationRegistry appRegistry = services.getService(ApplicationRegistry.class);
ApplicationInfo appInfo = appRegistry.get(params.name());
appInfo.addTransientAppMetaData(KEEP_STATE, keepState);
// store keepState in Application to make it available to subsequent
// undeploy-related methods.
ejbBundle.getApplication().setKeepStateResolved(String.valueOf(keepState));
}
// First, shutdown any singletons that were initialized based
// on a particular ordering dependency.
// TODO Make sure this covers both eagerly and lazily initialized
// Singletons.
singletonLCM.doShutdown();
for (Container container : containers) {
if (undeploy) {
container.undeploy();
} else {
container.onShutdown();
}
if (container.getSecurityManager() != null) {
container.getSecurityManager().destroy();
}
}
containers.clear();
return true;
}
use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.
the class ServerConfigLookup method getAsyncReplicationFromConfig.
public boolean getAsyncReplicationFromConfig(WebModule ctx) {
boolean asyncReplication = true;
DeploymentContext dc = ctx.getWebModuleConfig().getDeploymentContext();
if (dc != null) {
DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
if (params != null) {
asyncReplication = params.asyncreplication;
}
}
return asyncReplication;
}
use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.
the class WebApplication method start.
@Override
public boolean start(ApplicationContext appContext) throws Exception {
webModules.clear();
Properties props = null;
if (appContext != null) {
wmInfo.setAppClassLoader(appContext.getClassLoader());
if (appContext instanceof DeploymentContext) {
DeploymentContext deployContext = (DeploymentContext) appContext;
wmInfo.setDeploymentContext(deployContext);
if (isKeepState(deployContext, true)) {
props = deployContext.getAppProps();
}
}
applyApplicationConfig(appContext);
}
List<Result<WebModule>> results = container.loadWebModule(wmInfo, "null", props);
// release DeploymentContext in memory
wmInfo.setDeploymentContext(null);
if (results.size() == 0) {
logger.log(Level.SEVERE, "webApplication.unknownError");
return false;
}
boolean isFailure = false;
StringBuilder sb = null;
for (Result<WebModule> result : results) {
if (result.isFailure()) {
if (sb == null) {
sb = new StringBuilder(result.exception().toString());
} else {
sb.append(result.exception().toString());
}
logger.log(Level.WARNING, result.exception().toString(), result.exception());
isFailure = true;
} else {
webModules.add(result.result());
}
}
if (isFailure) {
webModules.clear();
throw new Exception(sb.toString());
}
if (logger.isLoggable(Level.INFO)) {
logger.log(Level.INFO, LogFacade.LOADING_APP, new Object[] { wmInfo.getDescriptor().getName(), wmInfo.getDescriptor().getContextRoot() });
}
return true;
}
use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.
the class WebApplication method stop.
@Override
public boolean stop(ApplicationContext stopContext) {
if (stopContext instanceof DeploymentContext) {
DeploymentContext deployContext = (DeploymentContext) stopContext;
Properties props = null;
boolean keepSessions = isKeepState(deployContext, false);
if (keepSessions) {
props = new Properties();
}
container.unloadWebModule(getDescriptor().getContextRoot(), getDescriptor().getApplication().getRegistrationName(), wmInfo.getVirtualServers(), props);
if (keepSessions) {
Properties actionReportProps = getActionReportProperties(deployContext);
// should not be null here
if (actionReportProps != null) {
actionReportProps.putAll(props);
}
}
}
stopCoherenceWeb();
return true;
}
use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.
the class WebComponentInjectionManager method decorate.
@SuppressWarnings("unchecked")
@Override
public void decorate(T webComponent, WebModule wm) {
if (wm.getWebBundleDescriptor().hasExtensionProperty(WeldDeployer.WELD_EXTENSION)) {
DeploymentContext deploymentContext = wm.getWebModuleConfig().getDeploymentContext();
WeldBootstrap weldBootstrap = deploymentContext.getTransientAppMetaData(WeldDeployer.WELD_BOOTSTRAP, org.jboss.weld.bootstrap.WeldBootstrap.class);
DeploymentImpl deploymentImpl = deploymentContext.getTransientAppMetaData(WeldDeployer.WELD_DEPLOYMENT, DeploymentImpl.class);
Collection<BeanDeploymentArchive> deployments = deploymentImpl.getBeanDeploymentArchives();
BeanDeploymentArchive beanDeploymentArchive = deployments.iterator().next();
BeanManager beanManager = weldBootstrap.getManager(beanDeploymentArchive);
// PENDING : Not available in this Web Beans Release
CreationalContext<T> ccontext = beanManager.createCreationalContext(null);
@SuppressWarnings("rawtypes") Class<T> clazz = (Class<T>) webComponent.getClass();
AnnotatedType<T> annotatedType = beanManager.createAnnotatedType(clazz);
InjectionTarget<T> injectionTarget = beanManager.createInjectionTarget(annotatedType);
injectionTarget.inject(webComponent, ccontext);
}
}
Aggregations