Search in sources :

Example 56 with DeployCommandParameters

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;
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) ActionReport(org.glassfish.api.ActionReport) DoNothingActionReporter(com.sun.enterprise.admin.report.DoNothingActionReporter)

Example 57 with DeployCommandParameters

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;
}
Also used : IOException(java.io.IOException) ActionReport(org.glassfish.api.ActionReport) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) PropertyVetoException(java.beans.PropertyVetoException) IOException(java.io.IOException) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) PlainTextActionReporter(com.sun.enterprise.admin.report.PlainTextActionReporter) File(java.io.File)

Example 58 with DeployCommandParameters

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;
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) VersioningSyntaxException(org.glassfish.deployment.versioning.VersioningSyntaxException)

Example 59 with DeployCommandParameters

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";
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) VersioningSyntaxException(org.glassfish.deployment.versioning.VersioningSyntaxException)

Example 60 with DeployCommandParameters

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;
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) ApplicationHolder(org.glassfish.javaee.core.deployment.ApplicationHolder) SAXParseException(org.xml.sax.SAXParseException) ApplicationArchivist(com.sun.enterprise.deployment.archivist.ApplicationArchivist) IOException(java.io.IOException)

Aggregations

DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)69 IOException (java.io.IOException)25 File (java.io.File)24 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)24 ActionReport (org.glassfish.api.ActionReport)23 DeploymentContext (org.glassfish.api.deployment.DeploymentContext)16 Application (com.sun.enterprise.deployment.Application)14 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)13 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)13 Logger (java.util.logging.Logger)12 Properties (java.util.Properties)10 DeploymentContextImpl (org.glassfish.deployment.common.DeploymentContextImpl)10 DeploymentException (org.glassfish.deployment.common.DeploymentException)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 ArchiveHandler (org.glassfish.api.deployment.archive.ArchiveHandler)9 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)9 Deployment (org.glassfish.internal.deployment.Deployment)9 PropertyVetoException (java.beans.PropertyVetoException)8 URI (java.net.URI)8 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)8