Search in sources :

Example 21 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class EjbApplication method stop.

public boolean stop(ApplicationContext stopContext) {
    DeploymentContext depc = (DeploymentContext) stopContext;
    OpsParams params = depc.getCommandParameters(OpsParams.class);
    boolean keepState = false;
    // keepstate remains the default value (false).
    if (params.origin.isUndeploy()) {
        keepState = resolveKeepStateOptions(depc, false, ejbBundle);
        if (keepState) {
            Properties appProps = depc.getAppProps();
            Object appId = appProps.get(EjbDeployer.APP_UNIQUE_ID_PROP);
            Properties actionReportProps = null;
            if (ejbBundle.getApplication().isVirtual()) {
                actionReportProps = depc.getActionReport().getExtraProperties();
            } else {
                // the application is EAR
                ExtendedDeploymentContext exdc = (ExtendedDeploymentContext) depc;
                actionReportProps = exdc.getParentContext().getActionReport().getExtraProperties();
            }
            actionReportProps.put(EjbDeployer.APP_UNIQUE_ID_PROP, appId);
            actionReportProps.put(EjbApplication.KEEP_STATE, String.valueOf(true));
            _logger.log(Level.INFO, "keepstate options resolved to true, saving appId {0} for application {1}.", new Object[] { appId, params.name() });
        }
    }
    // If true we're shutting down b/c of an undeploy or a fatal error during
    // deployment.  If false, it's a shutdown where the application will remain
    // deployed.
    boolean undeploy = (params.origin.isUndeploy() || params.origin.isDeploy());
    // and Application.  For failed deploy, keepstate is the default value (false).
    if (undeploy) {
        // store keepstate in ApplicationInfo to make it available to
        // EjbDeployer.clean().  A different instance of DeploymentContext
        // is passed to EjbDeployer.clean so we cannot use anything in DC (e.g.
        // appProps, transientData) to store keepstate.
        ApplicationRegistry appRegistry = services.getService(ApplicationRegistry.class);
        ApplicationInfo appInfo = appRegistry.get(params.name());
        appInfo.addTransientAppMetaData(KEEP_STATE, keepState);
        // store keepState in Application to make it available to subsequent
        // undeploy-related methods.
        ejbBundle.getApplication().setKeepStateResolved(String.valueOf(keepState));
    }
    // First, shutdown any singletons that were initialized based
    // on a particular ordering dependency.
    // TODO Make sure this covers both eagerly and lazily initialized
    // Singletons.
    singletonLCM.doShutdown();
    for (Container container : containers) {
        if (undeploy) {
            container.undeploy();
        } else {
            container.onShutdown();
        }
        if (container.getSecurityManager() != null) {
            container.getSecurityManager().destroy();
        }
    }
    containers.clear();
    return true;
}
Also used : DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) Container(com.sun.ejb.Container) AbstractSingletonContainer(com.sun.ejb.containers.AbstractSingletonContainer) ApplicationContainer(org.glassfish.api.deployment.ApplicationContainer) OpsParams(org.glassfish.api.deployment.OpsParams) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) Properties(java.util.Properties) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext)

Example 22 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class ServerConfigLookup method getAsyncReplicationFromConfig.

public boolean getAsyncReplicationFromConfig(WebModule ctx) {
    boolean asyncReplication = true;
    DeploymentContext dc = ctx.getWebModuleConfig().getDeploymentContext();
    if (dc != null) {
        DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
        if (params != null) {
            asyncReplication = params.asyncreplication;
        }
    }
    return asyncReplication;
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) DeploymentContext(org.glassfish.api.deployment.DeploymentContext)

Example 23 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class WebApplication method start.

@Override
public boolean start(ApplicationContext appContext) throws Exception {
    webModules.clear();
    Properties props = null;
    if (appContext != null) {
        wmInfo.setAppClassLoader(appContext.getClassLoader());
        if (appContext instanceof DeploymentContext) {
            DeploymentContext deployContext = (DeploymentContext) appContext;
            wmInfo.setDeploymentContext(deployContext);
            if (isKeepState(deployContext, true)) {
                props = deployContext.getAppProps();
            }
        }
        applyApplicationConfig(appContext);
    }
    List<Result<WebModule>> results = container.loadWebModule(wmInfo, "null", props);
    // release DeploymentContext in memory
    wmInfo.setDeploymentContext(null);
    if (results.size() == 0) {
        logger.log(Level.SEVERE, "webApplication.unknownError");
        return false;
    }
    boolean isFailure = false;
    StringBuilder sb = null;
    for (Result<WebModule> result : results) {
        if (result.isFailure()) {
            if (sb == null) {
                sb = new StringBuilder(result.exception().toString());
            } else {
                sb.append(result.exception().toString());
            }
            logger.log(Level.WARNING, result.exception().toString(), result.exception());
            isFailure = true;
        } else {
            webModules.add(result.result());
        }
    }
    if (isFailure) {
        webModules.clear();
        throw new Exception(sb.toString());
    }
    if (logger.isLoggable(Level.INFO)) {
        logger.log(Level.INFO, LogFacade.LOADING_APP, new Object[] { wmInfo.getDescriptor().getName(), wmInfo.getDescriptor().getContextRoot() });
    }
    return true;
}
Also used : DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties) Result(com.sun.enterprise.util.Result)

Example 24 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class WebApplication method stop.

@Override
public boolean stop(ApplicationContext stopContext) {
    if (stopContext instanceof DeploymentContext) {
        DeploymentContext deployContext = (DeploymentContext) stopContext;
        Properties props = null;
        boolean keepSessions = isKeepState(deployContext, false);
        if (keepSessions) {
            props = new Properties();
        }
        container.unloadWebModule(getDescriptor().getContextRoot(), getDescriptor().getApplication().getRegistrationName(), wmInfo.getVirtualServers(), props);
        if (keepSessions) {
            Properties actionReportProps = getActionReportProperties(deployContext);
            // should not be null here
            if (actionReportProps != null) {
                actionReportProps.putAll(props);
            }
        }
    }
    stopCoherenceWeb();
    return true;
}
Also used : DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties)

Example 25 with DeploymentContext

use of org.glassfish.api.deployment.DeploymentContext in project Payara by payara.

the class WebComponentInjectionManager method decorate.

@SuppressWarnings("unchecked")
@Override
public void decorate(T webComponent, WebModule wm) {
    if (wm.getWebBundleDescriptor().hasExtensionProperty(WeldDeployer.WELD_EXTENSION)) {
        DeploymentContext deploymentContext = wm.getWebModuleConfig().getDeploymentContext();
        WeldBootstrap weldBootstrap = deploymentContext.getTransientAppMetaData(WeldDeployer.WELD_BOOTSTRAP, org.jboss.weld.bootstrap.WeldBootstrap.class);
        DeploymentImpl deploymentImpl = deploymentContext.getTransientAppMetaData(WeldDeployer.WELD_DEPLOYMENT, DeploymentImpl.class);
        Collection<BeanDeploymentArchive> deployments = deploymentImpl.getBeanDeploymentArchives();
        BeanDeploymentArchive beanDeploymentArchive = deployments.iterator().next();
        BeanManager beanManager = weldBootstrap.getManager(beanDeploymentArchive);
        // PENDING : Not available in this Web Beans Release
        CreationalContext<T> ccontext = beanManager.createCreationalContext(null);
        @SuppressWarnings("rawtypes") Class<T> clazz = (Class<T>) webComponent.getClass();
        AnnotatedType<T> annotatedType = beanManager.createAnnotatedType(clazz);
        InjectionTarget<T> injectionTarget = beanManager.createInjectionTarget(annotatedType);
        injectionTarget.inject(webComponent, ccontext);
    }
}
Also used : WeldBootstrap(org.jboss.weld.bootstrap.WeldBootstrap) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) BeanManager(javax.enterprise.inject.spi.BeanManager)

Aggregations

DeploymentContext (org.glassfish.api.deployment.DeploymentContext)27 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)11 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)6 URL (java.net.URL)5 ParameterMap (org.glassfish.api.admin.ParameterMap)5 PermsArchiveDelegate (com.sun.enterprise.security.perms.PermsArchiveDelegate)4 URI (java.net.URI)4 PrivilegedActionException (java.security.PrivilegedActionException)4 Container (com.sun.ejb.Container)3 AbstractSingletonContainer (com.sun.ejb.containers.AbstractSingletonContainer)3 Application (com.sun.enterprise.deployment.Application)3 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 ActionReport (org.glassfish.api.ActionReport)3 ApplicationContainer (org.glassfish.api.deployment.ApplicationContainer)3 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)3 ParameterMapExtractor (org.glassfish.common.util.admin.ParameterMapExtractor)3 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)3 VersioningException (org.glassfish.deployment.versioning.VersioningException)3