use of org.glassfish.internal.deployment.analysis.StructuredDeploymentTracing 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 Collections.emptyList();
}
URI uri;
try {
uri = new URI(source);
} catch (URISyntaxException e) {
logger.log(Level.SEVERE, KernelLoggerInfo.cantDetermineLocation, e.getLocalizedMessage());
return Collections.emptyList();
}
List<Deployment.ApplicationDeployment> appDeployments = new ArrayList<>();
File sourceFile = new File(uri);
if (sourceFile.exists()) {
try {
ReadableArchive archive = null;
try {
StructuredDeploymentTracing structuredTracing = deploymentTracingEnabled != null ? StructuredDeploymentTracing.create(app.getName()) : StructuredDeploymentTracing.createDisabled(app.getName());
DeploymentTracing tracing = null;
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();
tracing = structuredTracing.register(depContext);
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);
}
appDeployments.removeIf(t -> t == null);
return appDeployments;
}
Aggregations