use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class UpgradeStartup method redeployApp.
private boolean redeployApp(Application app) {
// we don't need to redeploy any v3 type application
if (app.getModule().size() > 0) {
logger.log(Level.INFO, "Skip redeploying v3 type application " + app.getName());
return true;
}
// populate the params and properties from application element first
DeployCommandParameters deployParams = app.getDeployParameters(null);
// we should not have to repackage for any upgrade from v3
if (!Boolean.valueOf(app.getDirectoryDeployed())) {
File repackagedFile = null;
try {
repackagedFile = repackageArchive(app);
} catch (IOException ioe) {
logger.log(Level.SEVERE, "Repackaging of application " + app.getName() + " failed: " + ioe.getMessage(), ioe);
return false;
}
if (repackagedFile == null) {
logger.log(Level.SEVERE, "Repackaging of application " + app.getName() + " failed.");
return false;
}
logger.log(Level.INFO, "Repackaged application " + app.getName() + " at " + repackagedFile.getPath());
deployParams.path = repackagedFile;
}
deployParams.properties = app.getDeployProperties();
// remove the marker properties so they don't get carried over
// through redeployment
deployParams.properties.remove(MODULE_TYPE);
// add the compatibility property so the applications are
// upgraded/redeployed in a backward compatible way
deployParams.properties.setProperty(DeploymentProperties.COMPATIBILITY, "v2");
// now override the ones needed for the upgrade
deployParams.enabled = null;
deployParams.force = true;
deployParams.dropandcreatetables = false;
deployParams.createtables = false;
deployParams.target = DOMAIN_TARGET;
ActionReport report = new DoNothingActionReporter();
commandRunner.getCommandInvocation("deploy", report, kernelIdentity.getSubject()).parameters(deployParams).execute();
if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
logger.log(Level.SEVERE, "Redeployment of application " + app.getName() + " failed: " + report.getMessage() + "\nPlease redeploy " + app.getName() + " manually.", report.getFailureCause());
return false;
}
return true;
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class EmbeddedDeployerImpl method deploy.
@Override
public String deploy(ReadableArchive archive, DeployCommandParameters params) {
// ensure server is started. start it if not started.
try {
server.start();
} catch (LifecycleException e) {
throw new RuntimeException(e);
}
ActionReport report = new PlainTextActionReporter();
if (params == null) {
params = new DeployCommandParameters();
}
ExtendedDeploymentContext initialContext = new DeploymentContextImpl(report, archive, params, env);
ArchiveHandler archiveHandler = null;
try {
archiveHandler = deployment.getArchiveHandler(archive);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (archiveHandler == null) {
throw new RuntimeException("Cannot find archive handler for source archive");
}
if (params.name == null) {
params.name = archiveHandler.getDefaultApplicationName(archive, initialContext);
}
ExtendedDeploymentContext context = null;
try {
context = deployment.getBuilder(logger, params, report).source(archive).archiveHandler(archiveHandler).build(initialContext);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (params.property != null) {
context.getAppProps().putAll(params.property);
}
if (params.properties != null) {
context.getAppProps().putAll(params.properties);
}
ApplicationInfo appInfo = null;
try {
appInfo = deployment.deploy(context);
} catch (Exception e) {
logger.log(Level.SEVERE, KernelLoggerInfo.deployException, e);
}
if (appInfo != null) {
boolean isDirectory = new File(archive.getURI().getPath()).isDirectory();
EmbeddedDeployedInfo info = new EmbeddedDeployedInfo(appInfo, context.getModulePropsMap(), context.getAppProps(), isDirectory);
deployedApps.put(appInfo.getName(), info);
return appInfo.getName();
}
return null;
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class AppClientGroupFacadeGenerator method earDirUserURIText.
private String earDirUserURIText(final DeploymentContext dc) {
final DeployCommandParameters deployParams = dc.getCommandParameters(DeployCommandParameters.class);
final String appName = deployParams.name();
try {
return VersioningUtils.getUntaggedName(appName) + "Client/";
} catch (VersioningSyntaxException ex) {
Logger.getLogger(JavaWebStartInfo.APPCLIENT_SERVER_MAIN_LOGGER, JavaWebStartInfo.APPCLIENT_SERVER_LOGMESSAGE_RESOURCE).log(Level.SEVERE, null, ex);
}
return appName;
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class StandaloneAppClientDeployerHelper method facadeNameOnly.
/**
* Returns the name (no path, no type) of the facade JAR. This is used
* in both creating the full name and URI of the facade as well as for
* the name of a subdirectory in the user's download directory.
*
* @param dc
* @return
*/
private String facadeNameOnly(DeploymentContext dc) {
DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
final String appName = params.name();
try {
return VersioningUtils.getUntaggedName(appName) + "Client";
} catch (VersioningSyntaxException ex) {
logger.log(Level.SEVERE, ex.getMessage(), ex);
}
return appName + "Client";
}
use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.
the class EarHandler method getApplicationHolder.
private ApplicationHolder getApplicationHolder(ReadableArchive source, DeploymentContext context, boolean isDirectory) {
ApplicationHolder holder = context.getModuleMetaData(ApplicationHolder.class);
if (holder == null || holder.app == null) {
try {
DeployCommandParameters params = context.getCommandParameters(DeployCommandParameters.class);
if (params != null && params.altdd != null) {
source.addArchiveMetaData(DeploymentProperties.ALT_DD, params.altdd);
}
long start = System.currentTimeMillis();
ApplicationArchivist archivist = habitat.getService(ApplicationArchivist.class);
archivist.setAnnotationProcessingRequested(true);
String xmlValidationLevel = dasConfig.getDeployXmlValidation();
archivist.setXMLValidationLevel(xmlValidationLevel);
if (xmlValidationLevel.equals("none")) {
archivist.setXMLValidation(false);
}
holder = new ApplicationHolder(archivist.createApplication(source, isDirectory));
_logger.log(FINE, "time to read application.xml {0}", System.currentTimeMillis() - start);
} catch (IOException | SAXParseException e) {
throw new RuntimeException(e);
}
context.addModuleMetaData(holder);
}
if (holder.app == null) {
throw new RuntimeException(strings.get("errReadMetadata"));
}
return holder;
}
Aggregations