Search in sources :

Example 6 with HTMLActionReporter

use of com.sun.enterprise.v3.common.HTMLActionReporter in project Payara by payara.

the class ApplicationConfigListener method enableApplication.

private void enableApplication(String appName) {
    Application app = applications.getApplication(appName);
    ApplicationRef appRef = domain.getApplicationRefInServer(server.getName(), appName);
    // by the current server instance, do not load
    if (app == null || appRef == null) {
        return;
    }
    // if the application is not in enable state, do not load
    if (!deployment.isAppEnabled(app)) {
        return;
    }
    ApplicationInfo appInfo = appRegistry.get(appName);
    if (appInfo == null || appInfo.isLoaded()) {
        return;
    }
    long operationStartTime = Calendar.getInstance().getTimeInMillis();
    try {
        ActionReport report = new HTMLActionReporter();
        deployment.enable(server.getName(), app, appRef, report, logger);
        if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) {
            logger.log(Level.INFO, KernelLoggerInfo.loadingApplicationTime, new Object[] { appName, (Calendar.getInstance().getTimeInMillis() - operationStartTime) });
        } else if (report.getActionExitCode().equals(ActionReport.ExitCode.WARNING)) {
            logger.log(Level.WARNING, KernelLoggerInfo.loadingApplicationWarning, new Object[] { appName, report.getMessage() });
        } else if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) {
            throw new Exception(report.getMessage());
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, KernelLoggerInfo.loadingApplicationErrorEnable, e);
        throw new RuntimeException(e);
    }
}
Also used : HTMLActionReporter(com.sun.enterprise.v3.common.HTMLActionReporter) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ActionReport(org.glassfish.api.ActionReport) Application(com.sun.enterprise.config.serverbeans.Application) ApplicationRef(com.sun.enterprise.config.serverbeans.ApplicationRef)

Example 7 with HTMLActionReporter

use of com.sun.enterprise.v3.common.HTMLActionReporter in project Payara by payara.

the class ApplicationLoaderService method processApplication.

public List<Deployment.ApplicationDeployment> processApplication(Application app, ApplicationRef appRef) {
    long operationStartTime = Calendar.getInstance().getTimeInMillis();
    initializeRuntimeDependencies();
    String source = app.getLocation();
    final String appName = app.getName();
    // lifecycle modules are loaded separately
    if (Boolean.valueOf(app.getDeployProperties().getProperty(ServerTags.IS_LIFECYCLE))) {
        return ImmutableList.of();
    }
    URI uri;
    try {
        uri = new URI(source);
    } catch (URISyntaxException e) {
        logger.log(Level.SEVERE, KernelLoggerInfo.cantDetermineLocation, e.getLocalizedMessage());
        return ImmutableList.of();
    }
    List<Deployment.ApplicationDeployment> appDeployments = new ArrayList<>();
    File sourceFile = new File(uri);
    if (sourceFile.exists()) {
        try {
            ReadableArchive archive = null;
            try {
                DeploymentTracing tracing = null;
                if (deploymentTracingEnabled != null) {
                    tracing = new DeploymentTracing();
                }
                DeployCommandParameters deploymentParams = app.getDeployParameters(appRef);
                deploymentParams.target = server.getName();
                deploymentParams.origin = DeployCommandParameters.Origin.load;
                deploymentParams.command = DeployCommandParameters.Command.startup_server;
                if (domain.isAppReferencedByPaaSTarget(appName)) {
                    if (server.isDas()) {
                        // for loading PaaS application on DAS
                        // we set it to the real PaaS target
                        deploymentParams.target = deployment.getDefaultTarget(appName, deploymentParams.origin, deploymentParams._classicstyle);
                    }
                }
                archive = archiveFactoryProvider.get().openArchive(sourceFile, deploymentParams);
                ActionReport report = new HTMLActionReporter();
                ExtendedDeploymentContext depContext = deployment.getBuilder(logger, deploymentParams, report).source(archive).build();
                if (tracing != null) {
                    depContext.addModuleMetaData(tracing);
                }
                depContext.getAppProps().putAll(app.getDeployProperties());
                depContext.setModulePropsMap(app.getModulePropertiesMap());
                new ApplicationConfigInfo(app).store(depContext.getAppProps());
                appDeployments.add(deployment.prepare(deployment.getSniffersFromApp(app), depContext));
                appDeployments.addAll(loadApplicationForTenants(app, appRef, report));
                if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) {
                    if (tracing != null) {
                        tracing.print(System.out);
                    }
                    logger.log(Level.INFO, KernelLoggerInfo.loadingApplicationTime, new Object[] { appName, (Calendar.getInstance().getTimeInMillis() - operationStartTime) });
                } else {
                    logger.log(Level.SEVERE, KernelLoggerInfo.deployFail, report.getMessage());
                }
            } finally {
                if (archive != null) {
                    try {
                        archive.close();
                    } catch (IOException e) {
                        logger.log(Level.FINE, KernelLoggerInfo.deployException, e);
                    }
                }
            }
        } catch (IOException e) {
            logger.log(Level.SEVERE, KernelLoggerInfo.exceptionOpenArtifact, e);
        }
    } else {
        logger.log(Level.SEVERE, KernelLoggerInfo.notFoundInOriginalLocation, source);
    }
    return FluentIterable.from(appDeployments).filter(Predicates.notNull()).toList();
}
Also used : URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) ActionReport(org.glassfish.api.ActionReport) URI(java.net.URI) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) HTMLActionReporter(com.sun.enterprise.v3.common.HTMLActionReporter) ApplicationConfigInfo(org.glassfish.deployment.common.ApplicationConfigInfo) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) File(java.io.File)

Example 8 with HTMLActionReporter

use of com.sun.enterprise.v3.common.HTMLActionReporter in project Payara by payara.

the class ApplicationLoaderService method stopApplication.

private void stopApplication(Application app, ApplicationInfo appInfo) {
    final ActionReport dummy = new HTMLActionReporter();
    if (appInfo != null) {
        UndeployCommandParameters parameters = new UndeployCommandParameters(appInfo.getName());
        parameters.origin = UndeployCommandParameters.Origin.unload;
        parameters.command = UndeployCommandParameters.Command.shutdown_server;
        try {
            deployment.disable(parameters, app, appInfo, dummy, logger);
        } catch (Exception e) {
            logger.log(Level.SEVERE, KernelLoggerInfo.loadingApplicationErrorDisable, e);
        }
        unloadApplicationForTenants(app, dummy);
        appRegistry.remove(appInfo.getName());
    }
}
Also used : UndeployCommandParameters(org.glassfish.api.deployment.UndeployCommandParameters) HTMLActionReporter(com.sun.enterprise.v3.common.HTMLActionReporter) ActionReport(org.glassfish.api.ActionReport) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Aggregations

HTMLActionReporter (com.sun.enterprise.v3.common.HTMLActionReporter)8 ActionReport (org.glassfish.api.ActionReport)7 IOException (java.io.IOException)5 File (java.io.File)4 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)4 URISyntaxException (java.net.URISyntaxException)3 ArchiveHandler (org.glassfish.api.deployment.archive.ArchiveHandler)3 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)3 Application (com.sun.enterprise.config.serverbeans.Application)2 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)2 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)2 DeploymentContextImpl (org.glassfish.deployment.common.DeploymentContextImpl)2 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)2 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)2 SAXParseException (org.xml.sax.SAXParseException)2 FileArchive (com.sun.enterprise.deploy.shared.FileArchive)1 Application (com.sun.enterprise.deployment.Application)1 Archivist (com.sun.enterprise.deployment.archivist.Archivist)1 InputJarArchive (com.sun.enterprise.deployment.deploy.shared.InputJarArchive)1 ApplicationValidator (com.sun.enterprise.deployment.util.ApplicationValidator)1