return true;
}
public boolean stop(ApplicationContext stopContext) {
DeploymentContext depc = (DeploymentContext) stopContext;
OpsParams params = depc.getCommandParameters(OpsParams.class);
boolean keepState = false;
//calculate keepstate value for undeploy only. For failed deploy,
//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());
// for undeploy and failed deploy, store the keepstate in ApplicationInfo
// 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));