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);
}
}
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();
}
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());
}
}
Aggregations