Search in sources :

Example 16 with ExtendedDeploymentContext

use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.

the class DisableCommand method execute.

/**
 * Entry point from the framework into the command execution
 * @param context context for the command.
 */
public void execute(AdminCommandContext context) {
    if (origin == Origin.unload && command == Command.disable) {
        // we should only validate this for the disable command
        deployment.validateSpecifiedTarget(target);
    }
    InterceptorNotifier notifier = new InterceptorNotifier(habitat, null);
    final DeployCommandSupplementalInfo suppInfo = new DeployCommandSupplementalInfo();
    suppInfo.setAccessChecks(accessChecks);
    report.setResultType(DeployCommandSupplementalInfo.class, suppInfo);
    if (env.isDas() && DeploymentUtils.isDomainTarget(target)) {
        // for each distinct enabled version in all known targets
        Iterator it = enabledVersionsInTargets.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            appName = (String) entry.getKey();
            List<String> targets = new ArrayList<String>((Set<String>) entry.getValue());
            // replicate command to all referenced targets
            try {
                ParameterMapExtractor extractor = new ParameterMapExtractor(this);
                ParameterMap paramMap = extractor.extract(Collections.EMPTY_LIST);
                paramMap.set("DEFAULT", appName);
                notifier.ensureBeforeReported(ExtendedDeploymentContext.Phase.REPLICATION);
                ClusterOperationUtil.replicateCommand("disable", FailurePolicy.Error, FailurePolicy.Warn, FailurePolicy.Ignore, targets, context, paramMap, habitat);
            } catch (Exception e) {
                report.failure(logger, e.getMessage());
                return;
            }
        }
    } else if (isVersionExpressionWithWildcard) {
        try {
            if (matchedVersions == Collections.EMPTY_LIST) {
                // no version matched by the expression
                // nothing to do : success
                report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                return;
            }
            String enabledVersion = versioningService.getEnabledVersion(appName, target);
            if (matchedVersions.contains(enabledVersion)) {
                // the enabled version is matched by the expression
                appName = enabledVersion;
            } else {
                // the enabled version is not matched by the expression
                // nothing to do : success
                report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
                return;
            }
        } catch (VersioningException e) {
            report.failure(logger, e.getMessage());
            return;
        }
    }
    if (target == null) {
        target = deployment.getDefaultTarget(appName, origin, _classicstyle);
    }
    if (env.isDas() || !isundeploy) {
        // on instance side for partial deployment case
        if (!deployment.isRegistered(appName)) {
            if (env.isDas()) {
                // let's only do this check for DAS to be more
                // tolerable of the partial deployment case
                report.setMessage(localStrings.getLocalString("application.notreg", "Application {0} not registered", appName));
                report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            }
            return;
        }
        if (!DeploymentUtils.isDomainTarget(target)) {
            ApplicationRef ref = domain.getApplicationRefInTarget(appName, target);
            if (ref == null) {
                if (env.isDas()) {
                    // let's only do this check for DAS to be more
                    // tolerable of the partial deployment case
                    report.setMessage(localStrings.getLocalString("ref.not.referenced.target", "Application {0} is not referenced by target {1}", appName, target));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                }
                return;
            }
        }
    }
    /*
         * If the target is a cluster instance, the DAS will broadcast the command
         * to all instances in the cluster so they can all update their configs.
         */
    if (env.isDas()) {
        try {
            notifier.ensureBeforeReported(ExtendedDeploymentContext.Phase.REPLICATION);
            DeploymentCommandUtils.replicateEnableDisableToContainingCluster("disable", domain, target, appName, habitat, context, this);
        } catch (Exception e) {
            report.failure(logger, e.getMessage());
            return;
        }
    }
    try {
        Application app = applications.getApplication(appName);
        this.name = appName;
        // SHOULD CHECK THAT WE ARE THE CORRECT TARGET BEFORE DISABLING
        String serverName = server.getName();
        if (serverName.equals(target) || (server.getCluster() != null && server.getCluster().getName().equals(target))) {
            // wait until all applications are loaded. Otherwise we get "Application not registered"
            startupProvider.get();
            ApplicationInfo appInfo = deployment.get(appName);
            final DeploymentContext basicDC = deployment.disable(this, app, appInfo, report, logger);
            suppInfo.setDeploymentContext((ExtendedDeploymentContext) basicDC);
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error during disabling: ", e);
        if (env.isDas() || !isundeploy) {
            // we should let undeployment go through
            // on instance side for partial deployment case
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            report.setMessage(e.getMessage());
        }
    }
    if (enabledVersionsToDisable == Collections.EMPTY_SET) {
        enabledVersionsToDisable = new HashSet<String>();
        enabledVersionsToDisable.add(appName);
    }
    // iterating all the distinct enabled versions in all targets
    Iterator it = enabledVersionsToDisable.iterator();
    while (it.hasNext()) {
        appName = (String) it.next();
        if (!isundeploy && !report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
            try {
                deployment.updateAppEnabledAttributeInDomainXML(appName, target, false);
            } catch (TransactionFailure e) {
                logger.warning("failed to set enable attribute for " + appName);
            }
        }
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ArrayList(java.util.ArrayList) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ParameterMap(org.glassfish.api.admin.ParameterMap) VersioningException(org.glassfish.deployment.versioning.VersioningException) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) ParameterMapExtractor(org.glassfish.common.util.admin.ParameterMapExtractor) Iterator(java.util.Iterator) VersioningException(org.glassfish.deployment.versioning.VersioningException) Map(java.util.Map) ParameterMap(org.glassfish.api.admin.ParameterMap) HashMap(java.util.HashMap)

Example 17 with ExtendedDeploymentContext

use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.

the class EnableCommand method execute.

/**
 * Entry point from the framework into the command execution
 * @param context context for the command.
 */
public void execute(AdminCommandContext context) {
    deployment.validateSpecifiedTarget(target);
    InterceptorNotifier notifier = new InterceptorNotifier(habitat, null);
    DeployCommandSupplementalInfo suppInfo = new DeployCommandSupplementalInfo();
    suppInfo.setDeploymentContext(notifier.dc());
    suppInfo.setAccessChecks(accessChecks);
    report.setResultType(DeployCommandSupplementalInfo.class, suppInfo);
    if (!deployment.isRegistered(name())) {
        report.setMessage(localStrings.getLocalString("application.notreg", "Application {0} not registered", name()));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (!DeploymentUtils.isDomainTarget(target)) {
        ApplicationRef applicationRef = domain.getApplicationRefInTarget(name(), target);
        if (applicationRef == null) {
            report.setMessage(localStrings.getLocalString("ref.not.referenced.target", "Application {0} is not referenced by target {1}", name(), target));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    }
    // return if the application is already in enabled state
    if (domain.isAppEnabledInTarget(name(), target)) {
        logger.fine("The application is already enabled");
        return;
    }
    if (env.isDas()) {
        // try to disable the enabled version, if exist
        try {
            versioningService.handleDisable(name(), target, report, context.getSubject());
        } catch (VersioningSyntaxException e) {
            report.failure(logger, e.getMessage());
            return;
        }
        if (DeploymentUtils.isDomainTarget(target)) {
            List<String> targets = domain.getAllReferencedTargetsForApplication(name());
            // replicate command to all referenced targets
            try {
                ParameterMapExtractor extractor = new ParameterMapExtractor(this);
                ParameterMap paramMap = extractor.extract(Collections.EMPTY_LIST);
                paramMap.set("DEFAULT", name());
                notifier.ensureBeforeReported(Phase.REPLICATION);
                ClusterOperationUtil.replicateCommand("enable", FailurePolicy.Error, FailurePolicy.Warn, FailurePolicy.Ignore, targets, context, paramMap, habitat);
            } catch (Exception e) {
                report.failure(logger, e.getMessage());
                return;
            }
        }
        try {
            notifier.ensureBeforeReported(Phase.REPLICATION);
            DeploymentCommandUtils.replicateEnableDisableToContainingCluster("enable", domain, target, name(), habitat, context, this);
        } catch (Exception e) {
            report.failure(logger, e.getMessage());
            return;
        }
    }
    try {
        Application app = applications.getApplication(name());
        ApplicationRef appRef = domain.getApplicationRefInServer(server.getName(), name());
        // application is enabled.
        try {
            deployment.updateAppEnabledAttributeInDomainXML(name(), target, true);
        } catch (TransactionFailure e) {
            logger.log(Level.WARNING, "failed to set enable attribute for " + name(), e);
        }
        DeploymentContext dc = deployment.enable(target, app, appRef, report, logger);
        suppInfo.setDeploymentContext((ExtendedDeploymentContext) dc);
        if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
            // update the domain.xml
            try {
                deployment.updateAppEnabledAttributeInDomainXML(name(), target, false);
            } catch (TransactionFailure e) {
                logger.log(Level.WARNING, "failed to set enable attribute for " + name(), e);
            }
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Error during enabling: ", e);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(e.getMessage());
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) ParameterMapExtractor(org.glassfish.common.util.admin.ParameterMapExtractor) ParameterMap(org.glassfish.api.admin.ParameterMap) VersioningSyntaxException(org.glassfish.deployment.versioning.VersioningSyntaxException) VersioningSyntaxException(org.glassfish.deployment.versioning.VersioningSyntaxException)

Example 18 with ExtendedDeploymentContext

use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.

the class ApplicationLifecycle method disable.

@Override
public ExtendedDeploymentContext disable(UndeployCommandParameters commandParams, Application app, ApplicationInfo appInfo, ActionReport report, Logger logger) throws Exception {
    if (appInfo == null) {
        report.failure(logger, "Application not registered", null);
        return null;
    }
    // when it's on DAS, there is some necessary clean up we need to do
    if (!env.isDas() && !appInfo.isLoaded()) {
        return null;
    }
    if (app != null) {
        commandParams._type = app.archiveType();
    }
    final ExtendedDeploymentContext deploymentContext = getBuilder(logger, commandParams, report).source(appInfo.getSource()).build();
    if (app != null) {
        deploymentContext.getAppProps().putAll(app.getDeployProperties());
        deploymentContext.setModulePropsMap(app.getModulePropertiesMap());
    }
    if (commandParams.properties != null) {
        deploymentContext.getAppProps().putAll(commandParams.properties);
    }
    unload(appInfo, deploymentContext);
    return deploymentContext;
}
Also used : ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext)

Example 19 with ExtendedDeploymentContext

use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.

the class ApplicationLifecycle method prepare.

@Override
public ApplicationDeployment prepare(Collection<? extends Sniffer> sniffers, final ExtendedDeploymentContext context) {
    events.send(new Event<>(Deployment.DEPLOYMENT_START, context), false);
    currentDeploymentContext.get().push(context);
    final ActionReport report = context.getActionReport();
    final DeployCommandParameters commandParams = context.getCommandParameters(DeployCommandParameters.class);
    final String appName = commandParams.name();
    ApplicationInfo appInfo;
    final ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
    ProgressTracker tracker = new ProgressTracker() {

        @Override
        public void actOn(Logger logger) {
            // loaded but may not be started. Issue 18263
            for (EngineRef module : get("loaded", EngineRef.class)) {
                try {
                    module.stop(context);
                } catch (Exception e) {
                // ignore
                }
            }
            try {
                PreDestroy.class.cast(context).preDestroy();
            } catch (Exception e) {
            // ignore
            }
            for (EngineRef module : get("loaded", EngineRef.class)) {
                try {
                    module.unload(context);
                } catch (Exception e) {
                // ignore
                }
            }
            try {
                ApplicationInfo appInfo = appRegistry.get(appName);
                if (appInfo != null) {
                    // send the event to close necessary resources
                    events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_DISABLED, appInfo));
                }
            } catch (Exception e) {
            // ignore
            }
            for (EngineRef module : get("prepared", EngineRef.class)) {
                try {
                    module.clean(context);
                } catch (Exception e) {
                // ignore
                }
            }
            if (!commandParams.keepfailedstubs) {
                try {
                    context.clean();
                } catch (Exception e) {
                // ignore
                }
            }
            appRegistry.remove(appName);
        }
    };
    try {
        if (commandParams.origin == OpsParams.Origin.deploy && appRegistry.get(appName) != null) {
            report.setMessage(localStrings.getLocalString("appnamenotunique", "Application name {0} is already in use. Please pick a different name.", appName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return null;
        }
        // defined virtual servers minus __asadmin on that target
        if (commandParams.virtualservers == null) {
            commandParams.virtualservers = DeploymentUtils.getVirtualServers(commandParams.target, env, domain);
        }
        if (commandParams.enabled == null) {
            commandParams.enabled = Boolean.TRUE;
        }
        if (commandParams.altdd != null) {
            context.getSource().addArchiveMetaData(DeploymentProperties.ALT_DD, commandParams.altdd);
        }
        if (commandParams.runtimealtdd != null) {
            context.getSource().addArchiveMetaData(DeploymentProperties.RUNTIME_ALT_DD, commandParams.runtimealtdd);
        }
        context.addTransientAppMetaData(ExtendedDeploymentContext.TRACKER, tracker);
        context.setPhase(DeploymentContextImpl.Phase.PREPARE);
        ArchiveHandler handler = context.getArchiveHandler();
        if (handler == null) {
            handler = getArchiveHandler(context.getSource(), commandParams.type);
            context.setArchiveHandler(handler);
        }
        if (handler == null) {
            report.setMessage(localStrings.getLocalString("unknownarchivetype", "Archive type of {0} was not recognized", context.getSourceDir()));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return null;
        }
        DeploymentTracing tracing = context.getModuleMetaData(DeploymentTracing.class);
        if (tracing != null) {
            tracing.addMark(DeploymentTracing.Mark.ARCHIVE_HANDLER_OBTAINED);
        }
        if (handler.requiresAnnotationScanning(context.getSource())) {
            getDeployableTypes(context);
        }
        if (tracing != null) {
            tracing.addMark(DeploymentTracing.Mark.PARSING_DONE);
        }
        // is that some container do not support to be restarted.
        if (sniffers != null && logger.isLoggable(Level.FINE)) {
            for (Sniffer sniffer : sniffers) {
                logger.fine("Before Sorting" + sniffer.getModuleType());
            }
        }
        sniffers = getSniffers(handler, sniffers, context);
        ClassLoaderHierarchy clh = habitat.getService(ClassLoaderHierarchy.class);
        if (tracing != null) {
            tracing.addMark(DeploymentTracing.Mark.CLASS_LOADER_HIERARCHY);
        }
        context.createDeploymentClassLoader(clh, handler);
        events.send(new Event<DeploymentContext>(Deployment.AFTER_DEPLOYMENT_CLASSLOADER_CREATION, context), false);
        if (tracing != null) {
            tracing.addMark(DeploymentTracing.Mark.CLASS_LOADER_CREATED);
        }
        Thread.currentThread().setContextClassLoader(context.getClassLoader());
        List<EngineInfo> sortedEngineInfos = setupContainerInfos(handler, sniffers, context);
        if (tracing != null) {
            tracing.addMark(DeploymentTracing.Mark.CONTAINERS_SETUP_DONE);
        }
        if (logger.isLoggable(Level.FINE)) {
            for (EngineInfo info : sortedEngineInfos) {
                logger.fine("After Sorting " + info.getSniffer().getModuleType());
            }
        }
        if (sortedEngineInfos == null || sortedEngineInfos.isEmpty()) {
            report.failure(logger, localStrings.getLocalString("unknowncontainertype", "There is no installed container capable of handling this application {0}", context.getSource().getName()));
            tracker.actOn(logger);
            return null;
        }
        // create a temporary application info to hold metadata
        // so the metadata could be accessed at classloader
        // construction time through ApplicationInfo
        ApplicationInfo tempAppInfo = new ApplicationInfo(events, context.getSource(), appName);
        for (Object m : context.getModuleMetadata()) {
            tempAppInfo.addMetaData(m);
        }
        tempAppInfo.setIsJavaEEApp(sortedEngineInfos);
        // set the flag on the archive to indicate whether it's
        // a JavaEE archive or not
        context.getSource().setExtraData(Boolean.class, tempAppInfo.isJavaEEApp());
        appRegistry.add(appName, tempAppInfo);
        try {
            notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.PREPARE, context);
        } catch (Throwable interceptorException) {
            report.failure(logger, "Exception while invoking the lifecycle interceptor", null);
            report.setFailureCause(interceptorException);
            logger.log(Level.SEVERE, KernelLoggerInfo.lifecycleException, interceptorException);
            tracker.actOn(logger);
            return null;
        }
        events.send(new Event<DeploymentContext>(Deployment.DEPLOYMENT_BEFORE_CLASSLOADER_CREATION, context), false);
        context.createApplicationClassLoader(clh, handler);
        events.send(new Event<DeploymentContext>(Deployment.AFTER_APPLICATION_CLASSLOADER_CREATION, context), false);
        if (tracing != null) {
            tracing.addMark(DeploymentTracing.Mark.CLASS_LOADER_CREATED);
        }
        // this is a first time deployment as opposed as load following an unload event,
        // we need to create the application info
        // todo : we should come up with a general Composite API solution
        ModuleInfo moduleInfo = null;
        try {
            moduleInfo = prepareModule(sortedEngineInfos, appName, context, tracker);
            // Now that the prepare phase is done, any artifacts
            // should be available.  Go ahead and create the
            // downloadable client JAR.  We want to do this now, or
            // at least before the load and start phases, because
            // (for example) the app client deployer start phase
            // needs to find all generated files when it runs.
            final ClientJarWriter cjw = new ClientJarWriter(context);
            cjw.run();
        } catch (Throwable prepareException) {
            report.failure(logger, "Exception while preparing the app", null);
            report.setFailureCause(prepareException);
            logger.log(Level.SEVERE, KernelLoggerInfo.lifecycleException, prepareException);
            tracker.actOn(logger);
            return null;
        }
        // the deployer did not take care of populating the application info, this
        // is not a composite module.
        appInfo = context.getModuleMetaData(ApplicationInfo.class);
        if (appInfo == null) {
            appInfo = new ApplicationInfo(events, context.getSource(), appName);
            appInfo.addModule(moduleInfo);
            for (Object m : context.getModuleMetadata()) {
                moduleInfo.addMetaData(m);
                appInfo.addMetaData(m);
            }
        } else {
            for (EngineRef ref : moduleInfo.getEngineRefs()) {
                appInfo.add(ref);
            }
        }
        // remove the temp application info from the registry
        // first, then register the real one
        appRegistry.remove(appName);
        appInfo.setIsJavaEEApp(sortedEngineInfos);
        appRegistry.add(appName, appInfo);
        notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.PREPARE, context);
        if (tracing != null) {
            tracing.addMark(DeploymentTracing.Mark.PREPARED);
        }
        // send the APPLICATION_PREPARED event
        // set the phase and thread context classloader properly
        // before sending the event
        context.setPhase(DeploymentContextImpl.Phase.PREPARED);
        Thread.currentThread().setContextClassLoader(context.getClassLoader());
        appInfo.setAppClassLoader(context.getClassLoader());
        events.send(new Event<DeploymentContext>(Deployment.APPLICATION_PREPARED, context), false);
        if (loadOnCurrentInstance(context)) {
            appInfo.setLibraries(commandParams.libraries());
            try {
                notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.LOAD, context);
                appInfo.load(context, tracker);
                notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.LOAD, context);
            } catch (Throwable loadException) {
                logger.log(Level.SEVERE, KernelLoggerInfo.lifecycleException, loadException);
                report.failure(logger, "Exception while loading the app", null);
                report.setFailureCause(loadException);
                tracker.actOn(logger);
                return null;
            }
        }
    } catch (Exception e) {
        report.failure(logger, localStrings.getLocalString("error.deploying.app", "Exception while deploying the app [{0}]", appName), null);
        report.setFailureCause(e);
        logger.log(Level.SEVERE, KernelLoggerInfo.lifecycleException, e);
        tracker.actOn(logger);
        return null;
    } finally {
        Thread.currentThread().setContextClassLoader(currentCL);
        if (report.getActionExitCode() != ActionReport.ExitCode.SUCCESS) {
            context.postDeployClean(false);
            events.send(new Event<>(Deployment.DEPLOYMENT_FAILURE, context));
        }
    }
    ApplicationDeployment depl = new ApplicationDeployment(appInfo, context);
    appRegistry.addTransient(depl);
    return depl;
}
Also used : Logger(java.util.logging.Logger) Sniffer(org.glassfish.api.container.Sniffer) PropertyVetoException(java.beans.PropertyVetoException) RetryableException(org.jvnet.hk2.config.RetryableException) MultiException(org.glassfish.hk2.api.MultiException) VersioningSyntaxException(org.glassfish.deployment.versioning.VersioningSyntaxException) IOException(java.io.IOException) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) PreDestroy(org.glassfish.hk2.api.PreDestroy) DeploymentTracing(org.glassfish.internal.deployment.DeploymentTracing)

Example 20 with ExtendedDeploymentContext

use of org.glassfish.internal.deployment.ExtendedDeploymentContext in project Payara by payara.

the class MTProvisionCommand method execute.

public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    final Logger logger = context.getLogger();
    if (app == null) {
        report.setMessage("Application " + appname + " needs to be deployed first before provisioned to tenant");
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    ReadableArchive archive = null;
    DeployCommandParameters commandParams = app.getDeployParameters(appRef);
    commandParams.contextroot = contextroot;
    commandParams.target = DeploymentUtils.DAS_TARGET_NAME;
    commandParams.name = DeploymentUtils.getInternalNameForTenant(appname, tenant);
    commandParams.enabled = Boolean.TRUE;
    commandParams.origin = DeployCommandParameters.Origin.mt_provision;
    try {
        URI uri = new URI(app.getLocation());
        File file = new File(uri);
        if (!file.exists()) {
            throw new Exception(localStrings.getLocalString("fnf", "File not found", file.getAbsolutePath()));
        }
        archive = archiveFactory.openArchive(file);
        ExtendedDeploymentContext deploymentContext = deployment.getBuilder(logger, commandParams, report).source(archive).build();
        Properties appProps = deploymentContext.getAppProps();
        appProps.putAll(app.getDeployProperties());
        // app props so we also need to override that
        if (contextroot != null) {
            appProps.setProperty(ServerTags.CONTEXT_ROOT, contextroot);
        }
        deploymentContext.setModulePropsMap(app.getModulePropertiesMap());
        deploymentContext.setTenant(tenant, appname);
        expandCustomizationJar(deploymentContext.getTenantDir());
        deployment.deploy(deploymentContext);
        deployment.registerTenantWithAppInDomainXML(appname, deploymentContext);
    } catch (Throwable e) {
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(e.getMessage());
        report.setFailureCause(e);
    } finally {
        try {
            if (archive != null) {
                archive.close();
            }
        } catch (IOException e) {
        // ignore
        }
    }
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) IOException(java.io.IOException) ActionReport(org.glassfish.api.ActionReport) Logger(java.util.logging.Logger) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) Properties(java.util.Properties) URI(java.net.URI) File(java.io.File) IOException(java.io.IOException)

Aggregations

ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)39 ActionReport (org.glassfish.api.ActionReport)23 IOException (java.io.IOException)17 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)17 File (java.io.File)16 Logger (java.util.logging.Logger)11 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)11 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 Properties (java.util.Properties)9 URI (java.net.URI)7 Deployment (org.glassfish.internal.deployment.Deployment)7 DeploymentContext (org.glassfish.api.deployment.DeploymentContext)6 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)6 ArchiveHandler (org.glassfish.api.deployment.archive.ArchiveHandler)6 DeploymentContextImpl (org.glassfish.deployment.common.DeploymentContextImpl)6 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)6 Application (com.sun.enterprise.deployment.Application)5 ArrayList (java.util.ArrayList)5 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)5 VersioningException (org.glassfish.deployment.versioning.VersioningException)5