use of org.glassfish.api.deployment.UndeployCommandParameters in project Payara by payara.
the class EjbApplication method resolveKeepStateOptions.
/**
* Returns a consolidated keepstate value. keepstate only takes effect for
* redeploy operations where the app is already registered. If the app is
* not already registered, keepstate always resolves to false even if
* keepstate is true in CLI or descriptors. For redeploy operations, CLI
* --keepstate option has precedence over descriptor keep-state element.
* @param deployContext
* @param isDeploy
* @param bundleDesc
* @return true if keepstate is true after consolidating --keepstate CLI option
* and keep-state element in descriptors; false otherwise.
*/
private boolean resolveKeepStateOptions(DeploymentContext deployContext, boolean isDeploy, EjbBundleDescriptorImpl bundleDesc) {
Boolean isredeploy = Boolean.FALSE;
Boolean keepState = null;
if (isDeploy) {
DeployCommandParameters dcp = deployContext.getCommandParameters(DeployCommandParameters.class);
if (dcp != null) {
isredeploy = dcp.isredeploy;
keepState = dcp.keepstate;
}
} else {
UndeployCommandParameters ucp = deployContext.getCommandParameters(UndeployCommandParameters.class);
if (ucp != null) {
isredeploy = ucp.isredeploy;
keepState = ucp.keepstate;
}
}
if (!isredeploy) {
return false;
}
if (keepState == null) {
Application app = bundleDesc.getApplication();
keepState = app.getKeepState();
}
return keepState;
}
use of org.glassfish.api.deployment.UndeployCommandParameters in project Payara by payara.
the class ApplicationConfigListener method disableApplication.
private void disableApplication(String appName) {
Application app = applications.getApplication(appName);
ApplicationRef appRef = domain.getApplicationRefInServer(server.getName(), appName);
// by the current server instance, do not unload
if (app == null || appRef == null) {
return;
}
ApplicationInfo appInfo = appRegistry.get(appName);
if (appInfo == null || !appInfo.isLoaded()) {
return;
}
try {
ActionReport report = new HTMLActionReporter();
UndeployCommandParameters commandParams = new UndeployCommandParameters();
commandParams.name = appName;
commandParams.target = server.getName();
commandParams.origin = UndeployCommandParameters.Origin.unload;
commandParams.command = UndeployCommandParameters.Command.disable;
deployment.disable(commandParams, app, appInfo, report, logger);
if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
throw new Exception(report.getMessage());
}
} catch (Exception e) {
logger.log(Level.SEVERE, KernelLoggerInfo.loadingApplicationErrorDisable, e);
throw new RuntimeException(e);
}
}
use of org.glassfish.api.deployment.UndeployCommandParameters in project Payara by payara.
the class ApplicationLoaderService method unloadApplicationForTenants.
private void unloadApplicationForTenants(Application app, ActionReport report) {
if (app == null || app.getAppTenants() == null) {
return;
}
for (AppTenant tenant : app.getAppTenants().getAppTenant()) {
UndeployCommandParameters parameters = new UndeployCommandParameters();
parameters.name = DeploymentUtils.getInternalNameForTenant(app.getName(), tenant.getTenant());
parameters.origin = UndeployCommandParameters.Origin.unload;
parameters.target = server.getName();
ApplicationInfo appInfo = deployment.get(parameters.name);
if (appInfo == null) {
continue;
}
ActionReport subReport = report.addSubActionsReport();
try {
ExtendedDeploymentContext deploymentContext = deployment.getBuilder(KernelLoggerInfo.getLogger(), parameters, subReport).source(appInfo.getSource()).build();
deploymentContext.getAppProps().putAll(app.getDeployProperties());
deploymentContext.getAppProps().putAll(tenant.getDeployProperties());
deploymentContext.setModulePropsMap(app.getModulePropertiesMap());
deploymentContext.setTenant(tenant.getTenant(), app.getName());
deployment.unload(appInfo, deploymentContext);
} catch (Throwable e) {
subReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
subReport.setMessage(e.getMessage());
subReport.setFailureCause(e);
}
appRegistry.remove(appInfo.getName());
}
}
use of org.glassfish.api.deployment.UndeployCommandParameters in project Payara by payara.
the class ResourcesDeployer method preserveResources.
/**
* preserve the old application's resources so that they can be registered during deploy.
* @param dc DeploymentContext
* @param undeployCommandParameters undeploy command parameters
*/
private void preserveResources(DeploymentContext dc, UndeployCommandParameters undeployCommandParameters) {
try {
if (undeployCommandParameters.origin == OpsParams.Origin.undeploy) {
Properties properties = undeployCommandParameters.properties;
if (properties != null) {
String preserve = properties.getProperty(DeploymentProperties.PRESERVE_APP_SCOPED_RESOURCES);
if (preserve != null && Boolean.valueOf(preserve)) {
debug("Preserve app scoped resources enabled");
final UndeployCommandParameters commandParams = dc.getCommandParameters(UndeployCommandParameters.class);
String appName = commandParams.name();
Application app = applications.getApplication(appName);
preserveResources(app);
// store application info (for module information ie., sniffer type)
preservedApps.put(appName, app);
}
}
}
} catch (Exception e) {
// in the event notification infrastructure
throw new DeploymentException(e.getMessage(), e);
}
}
use of org.glassfish.api.deployment.UndeployCommandParameters in project Payara by payara.
the class ResourcesDeployer method cleanupPreservedResources.
private void cleanupPreservedResources(DeploymentContext dc, Event event) {
if (Deployment.DEPLOYMENT_FAILURE.equals(event.type())) {
final DeployCommandParameters deployCommandParameters = dc.getCommandParameters(DeployCommandParameters.class);
if (deployCommandParameters.origin == OpsParams.Origin.deploy || deployCommandParameters.origin == OpsParams.Origin.deploy_instance || deployCommandParameters.origin == OpsParams.Origin.create_application_ref) {
Properties properties = deployCommandParameters.properties;
String appName = deployCommandParameters.name();
cleanupPreservedResources(appName, properties);
}
} else if (Deployment.UNDEPLOYMENT_FAILURE.equals(event.type())) {
final UndeployCommandParameters undeployCommandParameters = dc.getCommandParameters(UndeployCommandParameters.class);
if (undeployCommandParameters.origin == OpsParams.Origin.undeploy) {
Properties properties = undeployCommandParameters.properties;
String appName = undeployCommandParameters.name();
cleanupPreservedResources(appName, properties);
}
}
}
Aggregations