Search in sources :

Example 1 with ApplicationContainer

use of org.glassfish.api.deployment.ApplicationContainer 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);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Logger(java.util.logging.Logger) ApplicationContainer(org.glassfish.api.deployment.ApplicationContainer) LinkedList(java.util.LinkedList) PropertyVetoException(java.beans.PropertyVetoException) DeploymentTracing(org.glassfish.internal.deployment.DeploymentTracing) Deployer(org.glassfish.api.deployment.Deployer)

Aggregations

PropertyVetoException (java.beans.PropertyVetoException)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 Logger (java.util.logging.Logger)1 ApplicationContainer (org.glassfish.api.deployment.ApplicationContainer)1 Deployer (org.glassfish.api.deployment.Deployer)1 DeploymentTracing (org.glassfish.internal.deployment.DeploymentTracing)1