use of org.glassfish.internal.deployment.DeploymentTracing in project Payara by payara.
the class ApplicationLifecycle method prepareModule.
@Override
public ModuleInfo prepareModule(List<EngineInfo> sortedEngineInfos, String moduleName, DeploymentContext context, ProgressTracker tracker) throws Exception {
ActionReport report = context.getActionReport();
List<EngineRef> addedEngines = new ArrayList<EngineRef>();
DeploymentTracing tracing = context.getModuleMetaData(DeploymentTracing.class);
if (tracing != null) {
tracing.addModuleMark(DeploymentTracing.ModuleMark.PREPARE, moduleName);
}
for (EngineInfo engineInfo : sortedEngineInfos) {
// get the deployer
Deployer deployer = engineInfo.getDeployer();
try {
if (tracing != null) {
tracing.addContainerMark(DeploymentTracing.ContainerMark.PREPARE, engineInfo.getSniffer().getModuleType());
}
deployer.prepare(context);
if (tracing != null) {
tracing.addContainerMark(DeploymentTracing.ContainerMark.PREPARED, engineInfo.getSniffer().getModuleType());
}
// construct an incomplete EngineRef which will be later
// filled in at loading time
EngineRef engineRef = new EngineRef(engineInfo, null);
addedEngines.add(engineRef);
tracker.add("prepared", EngineRef.class, engineRef);
tracker.add(Deployer.class, deployer);
} catch (Exception e) {
report.failure(logger, "Exception while invoking " + deployer.getClass() + " prepare method", e);
throw e;
}
}
if (tracing != null) {
tracing.addModuleMark(DeploymentTracing.ModuleMark.PREPARE_EVENTS, moduleName);
}
if (events != null) {
events.send(new Event<DeploymentContext>(Deployment.MODULE_PREPARED, context), false);
}
if (tracing != null) {
tracing.addModuleMark(DeploymentTracing.ModuleMark.PREPARED, moduleName);
}
// I need to create the application info here from the context, or something like this.
// and return the application info from this method for automatic registration in the caller.
// set isComposite property on module props so we know whether to persist
// module level properties inside ModuleInfo
String isComposite = context.getAppProps().getProperty(ServerTags.IS_COMPOSITE);
if (isComposite != null) {
context.getModuleProps().setProperty(ServerTags.IS_COMPOSITE, isComposite);
}
ModuleInfo mi = new ModuleInfo(events, moduleName, addedEngines, context.getModuleProps());
/*
* Save the application config that is potentially attached to each
* engine in the corresponding EngineRefs that have already created.
*
* Later, in registerAppInDomainXML, the appInfo is saved, which in
* turn saves the moduleInfo children and their engineRef children.
* Saving the engineRef assigns the application config to the Engine
* which corresponds directly to the <engine> element in the XML.
* A long way to get this done.
*/
// Application existingApp = applications.getModule(Application.class, moduleName);
// if (existingApp != null) {
ApplicationConfigInfo savedAppConfig = new ApplicationConfigInfo(context.getAppProps());
for (EngineRef er : mi.getEngineRefs()) {
ApplicationConfig c = savedAppConfig.get(mi.getName(), er.getContainerInfo().getSniffer().getModuleType());
if (c != null) {
er.setApplicationConfig(c);
}
}
// }
return mi;
}
use of org.glassfish.internal.deployment.DeploymentTracing in project Payara by payara.
the class ApplicationInfo method load.
public void load(ExtendedDeploymentContext context, ProgressTracker tracker) throws Exception {
Logger logger = context.getLogger();
if (isLoaded) {
logger.fine("Application is already loaded.");
return;
}
context.setPhase(ExtendedDeploymentContext.Phase.LOAD);
DeploymentTracing tracing = context.getModuleMetaData(DeploymentTracing.class);
if (tracing != null) {
tracing.addMark(DeploymentTracing.Mark.LOAD);
}
super.load(context, tracker);
appClassLoader = context.getClassLoader();
for (ModuleInfo module : modules) {
if (tracing != null) {
tracing.addModuleMark(DeploymentTracing.ModuleMark.LOAD, module.getName());
}
module.load(getSubContext(module, context), tracker);
if (tracing != null) {
tracing.addModuleMark(DeploymentTracing.ModuleMark.LOADED, module.getName());
}
}
populateApplicationServiceLocator();
isLoaded = true;
if (tracing != null) {
tracing.addMark(DeploymentTracing.Mark.LOAD_EVENTS);
}
if (events != null) {
events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_LOADED, this), false);
}
if (tracing != null) {
tracing.addMark(DeploymentTracing.Mark.LOADED);
}
}
use of org.glassfish.internal.deployment.DeploymentTracing in project Payara by payara.
the class ModuleInfo method load.
public void load(ExtendedDeploymentContext context, ProgressTracker tracker) throws Exception {
Logger logger = context.getLogger();
context.setPhase(ExtendedDeploymentContext.Phase.LOAD);
DeploymentTracing tracing = context.getModuleMetaData(DeploymentTracing.class);
if (tracing != null) {
tracing.addMark(DeploymentTracing.Mark.LOAD);
}
moduleClassLoader = context.getClassLoader();
Set<EngineRef> filteredEngines = new LinkedHashSet<EngineRef>();
LinkedList<EngineRef> filteredReversedEngines = new LinkedList<EngineRef>();
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(context.getClassLoader());
for (EngineRef engine : _getEngineRefs()) {
final EngineInfo engineInfo = engine.getContainerInfo();
if (tracing != null) {
tracing.addContainerMark(DeploymentTracing.ContainerMark.LOAD, engineInfo.getSniffer().getModuleType());
}
// get the container.
Deployer deployer = engineInfo.getDeployer();
try {
ApplicationContainer appCtr = deployer.load(engineInfo.getContainer(), context);
if (appCtr == null) {
String msg = "Cannot load application in " + engineInfo.getContainer().getName() + " container";
logger.fine(msg);
continue;
}
engine.load(context, tracker);
engine.setApplicationContainer(appCtr);
filteredEngines.add(engine);
filteredReversedEngines.addFirst(engine);
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception while invoking " + deployer.getClass() + " load method", e);
throw e;
}
if (tracing != null) {
tracing.addContainerMark(DeploymentTracing.ContainerMark.LOADED, engineInfo.getSniffer().getModuleType());
}
}
engines = filteredEngines;
reversedEngines = filteredReversedEngines;
if (tracing != null) {
tracing.addMark(DeploymentTracing.Mark.LOAD_EVENTS);
}
if (events != null) {
events.send(new Event<ModuleInfo>(Deployment.MODULE_LOADED, this), false);
}
if (tracing != null) {
tracing.addMark(DeploymentTracing.Mark.LOADED);
}
} finally {
Thread.currentThread().setContextClassLoader(currentClassLoader);
}
}
Aggregations