use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class CreateApplicationRefCommand method handleLifecycleModule.
private void handleLifecycleModule(AdminCommandContext context, Transaction t) {
final ActionReport report = context.getActionReport();
final Logger logger = context.getLogger();
Application app = applications.getApplication(name);
// create a dummy context to hold params and props
DeployCommandParameters commandParams = new DeployCommandParameters();
commandParams.name = name;
commandParams.target = target;
commandParams.virtualservers = virtualservers;
commandParams.enabled = enabled;
ExtendedDeploymentContext lifecycleContext = new DeploymentContextImpl(report, null, commandParams, null);
try {
deployment.registerAppInDomainXML(null, lifecycleContext, t, true);
} catch (Exception e) {
report.failure(logger, e.getMessage());
}
if (!DeploymentUtils.isDASTarget(target)) {
final ParameterMap paramMap = new ParameterMap();
paramMap.add("DEFAULT", name);
paramMap.add(DeploymentProperties.TARGET, target);
paramMap.add(DeploymentProperties.ENABLED, enabled.toString());
if (virtualservers != null) {
paramMap.add(DeploymentProperties.VIRTUAL_SERVERS, virtualservers);
}
// pass the applicationInfo props so we have the information to persist in the
// domain.xml
Properties appProps = app.getDeployProperties();
paramMap.set(DeploymentProperties.APP_PROPS, DeploymentUtils.propertiesValue(appProps, ':'));
final List<String> targets = new ArrayList<String>();
targets.add(target);
ClusterOperationUtil.replicateCommand("_lifecycle", FailurePolicy.Error, FailurePolicy.Warn, FailurePolicy.Ignore, targets, context, paramMap, habitat);
}
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class WebServicesApplication method start.
@Override
public boolean start(ApplicationContext startupContext) throws Exception {
cl = startupContext.getClassLoader();
app = deploymentCtx.getModuleMetaData(Application.class);
DeployCommandParameters commandParams = ((DeploymentContext) startupContext).getCommandParameters(DeployCommandParameters.class);
virtualServers = commandParams.virtualservers;
createEndpoints();
grizzlyRestartListener.addListener(this);
return true;
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class MetroContainer method deployWsTxServices.
public void deployWsTxServices(String target) {
synchronized (lock) {
if (wstxServicesDeployed.get() || !wstxServicesDeploying.compareAndSet(false, true)) {
return;
}
Deployment deployment = serviceLocator.getService(Deployment.class);
boolean isRegistered = deployment.isRegistered(WSTX_SERVICES_APP_NAME);
if (isRegistered) {
logger.log(WARNING, WSTX_SERVICE_DEPLOYED_EXPLICITLY);
} else {
logger.log(INFO, WSTX_SERVICE_LOADING);
File root = serverContext.getInstallRoot();
File app = null;
try {
app = FileUtils.getManagedFile(WSTX_SERVICES_APP_NAME + ".war", new File(root, METRO_APPS_INSTALL_ROOT));
} catch (Exception e) {
logger.log(WARNING, WSTX_SERVICE_UNEXPECTED_EXCEPTION, e);
}
if (app == null || !app.exists()) {
// TODO
logger.log(WARNING, format(WSTX_SERVICE_CANNOT_DEPLOY, "Required WAR file (" + WSTX_SERVICES_APP_NAME + ".war) is not installed"));
} else {
ActionReport report = serviceLocator.getService(ActionReport.class, "plain");
DeployCommandParameters params = new DeployCommandParameters(app);
String appName = WSTX_SERVICES_APP_NAME;
params.name = appName;
try {
File rootScratchDir = env.getApplicationStubPath();
File appScratchDir = new File(rootScratchDir, appName);
if (isDas() && appScratchDir.createNewFile()) {
params.origin = OpsParams.Origin.deploy;
if (target != null) {
params.target = target;
}
} else {
params.origin = OpsParams.Origin.load;
params.target = env.getInstanceName();
}
ExtendedDeploymentContext dc = deployment.getBuilder(logger, params, report).source(app).build();
Properties appProps = dc.getAppProps();
appProps.setProperty(OBJECT_TYPE, SYSTEM_ALL);
deployment.deploy(dc);
if (report.getActionExitCode() != ActionReport.ExitCode.SUCCESS) {
logger.log(WARNING, format(WSTX_SERVICE_CANNOT_DEPLOY, report.getMessage()), report.getFailureCause());
}
logger.log(INFO, WSTX_SERVICE_STARTED);
} catch (Exception ex) {
logger.log(WARNING, format(WSTX_SERVICE_CANNOT_DEPLOY, ex.getLocalizedMessage()), ex);
}
}
}
wstxServicesDeployed.set(true);
wstxServicesDeploying.set(false);
}
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class ApplicationLifecycle method prepareInstanceDeployParamMap.
@Override
public ParameterMap prepareInstanceDeployParamMap(DeploymentContext dc) throws Exception {
final DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
final Collection<String> excludedParams = new ArrayList<>();
excludedParams.add(DeploymentProperties.PATH);
excludedParams.add(DeploymentProperties.DEPLOYMENT_PLAN);
excludedParams.add(DeploymentProperties.ALT_DD);
excludedParams.add(DeploymentProperties.RUNTIME_ALT_DD);
// We'll force it to true ourselves.
excludedParams.add(DeploymentProperties.UPLOAD);
final ParameterMap paramMap;
final ParameterMapExtractor extractor = new ParameterMapExtractor(params);
paramMap = extractor.extract(excludedParams);
prepareGeneratedContent(dc, paramMap);
// set the path and plan params
// get the location properties from the application so the token
// will be resolved
Application application = applications.getApplication(params.name);
Properties appProperties = application.getDeployProperties();
String archiveLocation = appProperties.getProperty(Application.APP_LOCATION_PROP_NAME);
final File archiveFile = new File(new URI(archiveLocation));
paramMap.set("DEFAULT", archiveFile.getAbsolutePath());
String planLocation = appProperties.getProperty(Application.DEPLOYMENT_PLAN_LOCATION_PROP_NAME);
if (planLocation != null) {
final File actualPlan = new File(new URI(planLocation));
paramMap.set(DeployCommandParameters.ParameterNames.DEPLOYMENT_PLAN, actualPlan.getAbsolutePath());
}
String altDDLocation = appProperties.getProperty(Application.ALT_DD_LOCATION_PROP_NAME);
if (altDDLocation != null) {
final File altDD = new File(new URI(altDDLocation));
paramMap.set(DeployCommandParameters.ParameterNames.ALT_DD, altDD.getAbsolutePath());
}
String runtimeAltDDLocation = appProperties.getProperty(Application.RUNTIME_ALT_DD_LOCATION_PROP_NAME);
if (runtimeAltDDLocation != null) {
final File runtimeAltDD = new File(new URI(runtimeAltDDLocation));
paramMap.set(DeployCommandParameters.ParameterNames.RUNTIME_ALT_DD, runtimeAltDD.getAbsolutePath());
}
// always upload the archives to the instance side
// but not directories. Note that we prepare a zip file containing
// the generated directories and pass that as a single parameter so it
// will be uploaded even though a deployment directory is not.
paramMap.set(DeploymentProperties.UPLOAD, "true");
// redeployment
if (params.previousContextRoot != null) {
paramMap.set(DeploymentProperties.PRESERVED_CONTEXT_ROOT, params.previousContextRoot);
}
// pass the app props so we have the information to persist in the
// domain.xml
Properties appProps = dc.getAppProps();
appProps.remove(DeploymentProperties.APP_CONFIG);
paramMap.set(DeploymentProperties.APP_PROPS, extractor.propertiesValue(appProps, ':'));
Properties previousVirtualServers = dc.getTransientAppMetaData(DeploymentProperties.PREVIOUS_VIRTUAL_SERVERS, Properties.class);
if (previousVirtualServers != null) {
paramMap.set(DeploymentProperties.PREVIOUS_VIRTUAL_SERVERS, extractor.propertiesValue(previousVirtualServers, ':'));
}
Properties previousEnabledAttributes = dc.getTransientAppMetaData(DeploymentProperties.PREVIOUS_ENABLED_ATTRIBUTES, Properties.class);
if (previousEnabledAttributes != null) {
paramMap.set(DeploymentProperties.PREVIOUS_ENABLED_ATTRIBUTES, extractor.propertiesValue(previousEnabledAttributes, ':'));
}
return paramMap;
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class ApplicationLifecycle method prepareAppConfigChanges.
// prepare application config change for later registering
// in the domain.xml
@Override
public Transaction prepareAppConfigChanges(final DeploymentContext context) throws TransactionFailure {
final Properties appProps = context.getAppProps();
final DeployCommandParameters deployParams = context.getCommandParameters(DeployCommandParameters.class);
Transaction tx = null;
Application app_w = null;
if (deployParams.hotDeploy) {
app_w = applications.getApplication(deployParams.name);
}
if (app_w == null) {
try {
tx = new Transaction();
// prepare the application element
ConfigBean newBean = ((ConfigBean) Dom.unwrap(applications)).allocate(Application.class);
Application app = newBean.createProxy();
app_w = tx.enroll(app);
setInitialAppAttributes(app_w, deployParams, appProps, context);
} catch (TransactionFailure e) {
tx.rollback();
throw e;
} catch (Exception e) {
tx.rollback();
throw new TransactionFailure(e.getMessage(), e);
}
}
context.addTransientAppMetaData(ServerTags.APPLICATION, app_w);
return tx;
}
Aggregations