Search in sources :

Example 66 with DeployCommandParameters

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

the class WarHandler method configureContextXmlAttribute.

protected void configureContextXmlAttribute(WebappClassLoader cloader, File base, DeploymentContext dc) throws XMLStreamException, IOException {
    boolean consistent = true;
    Boolean value = null;
    File warContextXml = new File(base.getAbsolutePath(), WAR_CONTEXT_XML);
    if (warContextXml.exists()) {
        ContextXmlParser parser = new ContextXmlParser(warContextXml);
        value = parser.getClearReferencesStatic();
    }
    if (value == null) {
        Boolean domainCRS = null;
        File defaultContextXml = new File(serverEnvironment.getInstanceRoot(), DEFAULT_CONTEXT_XML);
        if (defaultContextXml.exists()) {
            ContextXmlParser parser = new ContextXmlParser(defaultContextXml);
            domainCRS = parser.getClearReferencesStatic();
        }
        List<Boolean> csrs = new ArrayList<Boolean>();
        HttpService httpService = serverConfig.getHttpService();
        DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
        String vsIDs = params.virtualservers;
        List<String> vsList = StringUtils.parseStringList(vsIDs, " ,");
        if (httpService != null && vsList != null && !vsList.isEmpty()) {
            for (VirtualServer vsBean : httpService.getVirtualServer()) {
                if (vsList.contains(vsBean.getId())) {
                    Boolean csr = null;
                    Property prop = vsBean.getProperty("contextXmlDefault");
                    if (prop != null) {
                        File contextXml = new File(serverEnvironment.getInstanceRoot(), prop.getValue());
                        if (contextXml.exists()) {
                            // vs context.xml
                            ContextXmlParser parser = new ContextXmlParser(contextXml);
                            csr = parser.getClearReferencesStatic();
                        }
                    }
                    if (csr == null) {
                        csr = domainCRS;
                    }
                    csrs.add(csr);
                }
            }
            // check that it is consistent
            for (Boolean b : csrs) {
                if (b != null) {
                    if (value != null && !b.equals(value)) {
                        consistent = false;
                        break;
                    }
                    value = b;
                }
            }
        }
    }
    if (consistent) {
        if (value != null) {
            cloader.setClearReferencesStatic(value);
        }
    } else if (logger.isLoggable(Level.WARNING)) {
        logger.log(Level.WARNING, LogFacade.INCONSISTENT_CLEAR_REFERENCE_STATIC);
    }
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) HttpService(com.sun.enterprise.config.serverbeans.HttpService) ArrayList(java.util.ArrayList) JarFile(java.util.jar.JarFile) File(java.io.File) Property(org.jvnet.hk2.config.types.Property) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer)

Example 67 with DeployCommandParameters

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

the class WebDeployer method loadMetaData.

@Override
public <V> V loadMetaData(Class<V> type, DeploymentContext dc) {
    WebBundleDescriptorImpl wbd = dc.getModuleMetaData(WebBundleDescriptorImpl.class);
    if (wbd.isStandalone()) {
        // the context root should be set using the following precedence
        // for standalone web module
        // 1. User specified value through DeployCommand
        // 2. Context root value specified through sun-web.xml
        // 3. Context root from last deployment if applicable
        // 4. The default context root which is the archive name
        // minus extension
        DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
        String contextRoot = params.contextroot;
        if (contextRoot == null) {
            contextRoot = wbd.getContextRoot();
            if ("".equals(contextRoot))
                contextRoot = null;
        }
        if (contextRoot == null) {
            contextRoot = params.previousContextRoot;
        }
        // default should be application name, if available
        if (contextRoot == null && StringUtils.ok(params.name())) {
            contextRoot = params.name();
        }
        if (contextRoot == null)
            contextRoot = ((GenericHandler) dc.getArchiveHandler()).getDefaultApplicationNameFromArchiveName(dc.getOriginalSource());
        if (!contextRoot.startsWith("/")) {
            contextRoot = "/" + contextRoot;
        }
        wbd.setContextRoot(contextRoot);
        wbd.setName(params.name());
        // set the context root to deployment context props so this value
        // will be persisted in domain.xml
        dc.getAppProps().setProperty(ServerTags.CONTEXT_ROOT, contextRoot);
    }
    return null;
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) GenericHandler(org.glassfish.internal.deployment.GenericHandler) WebBundleDescriptorImpl(org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl)

Example 68 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters 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 69 with DeployCommandParameters

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

the class WeldDeployer method load.

/**
 * Processing in this method is performed for each module that is in the process of being loaded by
 * the container.
 *
 * <p>
 * This method will collect information from each archive (module) and produce
 * <code>BeanDeploymentArchive</code> information for each module.
 * </p>
 *
 * <p>
 * The
 * <code>BeanDeploymentArchive</code>s are stored in the <code>Deployment</code> (that will
 * eventually be handed off to <code>Weld</code>. Once this method is called for all modules (and
 * <code>BeanDeploymentArchive</code> information has been collected for all <code>Weld</code>
 * modules), a relationship structure is produced defining the accessiblity rules for the
 * <code>BeanDeploymentArchive</code>s.
 * </p>
 *
 * @param container
 * @param context
 * @return
 */
@Override
public WeldApplicationContainer load(WeldContainer container, DeploymentContext context) {
    DeployCommandParameters deployParams = context.getCommandParameters(DeployCommandParameters.class);
    ApplicationInfo applicationInfo = applicationRegistry.get(deployParams.name);
    ReadableArchive archive = context.getSource();
    boolean[] setTransientAppMetaData = { false };
    // See if a WeldBootsrap has already been created - only want one per app.
    WeldBootstrap bootstrap = getWeldBootstrap(context, applicationInfo, setTransientAppMetaData);
    EjbBundleDescriptor ejbBundle = getEjbBundleFromContext(context);
    EjbServices ejbServices = null;
    Set<EjbDescriptor> ejbs = new HashSet<>();
    if (ejbBundle != null) {
        ejbs.addAll(ejbBundle.getEjbs());
        ejbServices = new EjbServicesImpl(services);
    }
    // Create a deployment collecting information from the ReadableArchive (archive)
    // If the archive is a composite, or has version numbers per maven conventions, strip them out
    String archiveName = getArchiveName(context, applicationInfo, archive);
    DeploymentImpl deploymentImpl = context.getTransientAppMetaData(WELD_DEPLOYMENT, DeploymentImpl.class);
    if (deploymentImpl == null) {
        deploymentImpl = new DeploymentImpl(archive, ejbs, context, archiveFactory, archiveName, services.getService(InjectionManager.class));
        // Add services
        TransactionServices transactionServices = new TransactionServicesImpl(services);
        deploymentImpl.getServices().add(TransactionServices.class, transactionServices);
        SecurityServices securityServices = new SecurityServicesImpl();
        deploymentImpl.getServices().add(SecurityServices.class, securityServices);
        ProxyServices proxyServices = new ProxyServicesImpl(services);
        deploymentImpl.getServices().add(ProxyServices.class, proxyServices);
        try {
            ExecutorServices executorServices = new ExecutorServicesImpl();
            deploymentImpl.getServices().add(ExecutorServices.class, executorServices);
        } catch (NamingException ex) {
            throw new RuntimeException(ex);
        }
        addWeldListenerToAllWars(context);
    } else {
        deploymentImpl.scanArchive(archive, ejbs, context, archiveName);
    }
    deploymentImpl.addDeployedEjbs(ejbs);
    if (ejbBundle != null && (!deploymentImpl.getServices().contains(EjbServices.class))) {
        // EJB Services is registered as a top-level service
        deploymentImpl.getServices().add(EjbServices.class, ejbServices);
    }
    ExternalConfigurationImpl externalConfiguration = new ExternalConfigurationImpl();
    externalConfiguration.setRollingUpgradesDelimiter(System.getProperty("fish.payara.rollingUpgradesDelimiter", ":"));
    externalConfiguration.setBeanIndexOptimization(!deployParams.isAvailabilityEnabled());
    externalConfiguration.setNonPortableMode(false);
    configureConcurrentDeployment(context, externalConfiguration);
    deploymentImpl.getServices().add(ExternalConfiguration.class, externalConfiguration);
    BeanDeploymentArchive beanDeploymentArchive = deploymentImpl.getBeanDeploymentArchiveForArchive(archiveName);
    if (beanDeploymentArchive != null && !beanDeploymentArchive.getBeansXml().getBeanDiscoveryMode().equals(NONE)) {
        if (setTransientAppMetaData[0]) {
            // Do this only if we have a root BDA
            appToBootstrap.put(context.getModuleMetaData(Application.class), bootstrap);
            applicationInfo.addTransientAppMetaData(WELD_BOOTSTRAP, bootstrap);
        }
        WebBundleDescriptor webBundleDescriptor = context.getModuleMetaData(WebBundleDescriptor.class);
        boolean developmentMode = isDevelopmentMode(context);
        if (webBundleDescriptor != null) {
            webBundleDescriptor.setExtensionProperty(WELD_EXTENSION, "true");
            // Add the Weld Listener. We have to do it here too in case addWeldListenerToAllWars wasn't
            // able to do it.
            webBundleDescriptor.addAppListenerDescriptorToFirst(new AppListenerDescriptorImpl(WELD_LISTENER));
            // Add Weld Context Listener - this listener will ensure the WeldELContextListener is used
            // for JSP's..
            webBundleDescriptor.addAppListenerDescriptor(new AppListenerDescriptorImpl(WELD_CONTEXT_LISTENER));
            // Weld 2.2.1.Final. There is a tck test for this:
            // org.jboss.cdi.tck.tests.context.session.listener.SessionContextHttpSessionListenerTest
            // This WeldTerminationListener must come after all application-defined listeners
            webBundleDescriptor.addAppListenerDescriptor(new AppListenerDescriptorImpl(WeldTerminationListenerProxy.class.getName()));
            // Adding Weld ConverstationFilter if there is a filterMapping for it and it doesn't exist already.
            // However, it will be applied only if web.xml has a mapping for it.
            // Doing this here to make sure that its done only for CDI enabled web applications
            registerWeldConversationFilter(webBundleDescriptor);
            // every deployment
            if (developmentMode) {
                registerProbeFilter(webBundleDescriptor);
            }
        }
        if (developmentMode) {
            registerProbeExtension(externalConfiguration, deploymentImpl);
        }
        BundleDescriptor bundle = (webBundleDescriptor != null) ? webBundleDescriptor : ejbBundle;
        if (bundle != null) {
            if (!beanDeploymentArchive.getBeansXml().getBeanDiscoveryMode().equals(NONE)) {
                // Register EE injection manager at the bean deployment archive level.
                // We use the generic InjectionService service to handle all EE-style
                // injection instead of the per-dependency-type InjectionPoint approach.
                // Each InjectionServicesImpl instance knows its associated GlassFish bundle.
                InjectionServices injectionServices = new InjectionServicesImpl(deploymentImpl.injectionManager, bundle, deploymentImpl);
                ResourceInjectionServicesImpl resourceInjectionServices = new ResourceInjectionServicesImpl();
                if (logger.isLoggable(FINE)) {
                    logger.log(FINE, ADDING_INJECTION_SERVICES, new Object[] { injectionServices, beanDeploymentArchive.getId() });
                }
                beanDeploymentArchive.getServices().add(InjectionServices.class, injectionServices);
                beanDeploymentArchive.getServices().add(ResourceInjectionServices.class, resourceInjectionServices);
                EEModuleDescriptor eeModuleDescriptor = getEEModuleDescriptor(beanDeploymentArchive);
                if (eeModuleDescriptor != null) {
                    beanDeploymentArchive.getServices().add(EEModuleDescriptor.class, eeModuleDescriptor);
                }
                // Relevant in WAR BDA - WEB-INF/lib BDA scenarios
                for (BeanDeploymentArchive subBda : beanDeploymentArchive.getBeanDeploymentArchives()) {
                    if (logger.isLoggable(FINE)) {
                        logger.log(FINE, ADDING_INJECTION_SERVICES, new Object[] { injectionServices, subBda.getId() });
                    }
                    subBda.getServices().add(InjectionServices.class, injectionServices);
                    // Should not be subBda?
                    eeModuleDescriptor = getEEModuleDescriptor(beanDeploymentArchive);
                    if (eeModuleDescriptor != null) {
                        beanDeploymentArchive.getServices().add(EEModuleDescriptor.class, eeModuleDescriptor);
                    }
                }
            }
            bundleToBeanDeploymentArchive.put(bundle, beanDeploymentArchive);
        }
    }
    context.addTransientAppMetaData(WELD_DEPLOYMENT, deploymentImpl);
    applicationInfo.addTransientAppMetaData(WELD_DEPLOYMENT, deploymentImpl);
    return new WeldApplicationContainer();
}
Also used : ProxyServices(org.jboss.weld.serialization.spi.ProxyServices) SecurityServices(org.jboss.weld.security.spi.SecurityServices) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) WeldBootstrap(org.jboss.weld.bootstrap.WeldBootstrap) InjectionServices(org.jboss.weld.injection.spi.InjectionServices) ResourceInjectionServices(org.jboss.weld.injection.spi.ResourceInjectionServices) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) NamingException(javax.naming.NamingException) HashSet(java.util.HashSet) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) EjbServices(org.jboss.weld.ejb.spi.EjbServices) TransactionServices(org.jboss.weld.transaction.spi.TransactionServices) AppListenerDescriptorImpl(org.glassfish.web.deployment.descriptor.AppListenerDescriptorImpl) ExecutorServices(org.jboss.weld.manager.api.ExecutorServices) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) Application(com.sun.enterprise.deployment.Application) EEModuleDescriptor(org.jboss.weld.bootstrap.spi.EEModuleDescriptor)

Aggregations

DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)69 IOException (java.io.IOException)25 File (java.io.File)24 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)24 ActionReport (org.glassfish.api.ActionReport)23 DeploymentContext (org.glassfish.api.deployment.DeploymentContext)16 Application (com.sun.enterprise.deployment.Application)14 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)13 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)13 Logger (java.util.logging.Logger)12 Properties (java.util.Properties)10 DeploymentContextImpl (org.glassfish.deployment.common.DeploymentContextImpl)10 DeploymentException (org.glassfish.deployment.common.DeploymentException)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 ArchiveHandler (org.glassfish.api.deployment.archive.ArchiveHandler)9 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)9 Deployment (org.glassfish.internal.deployment.Deployment)9 PropertyVetoException (java.beans.PropertyVetoException)8 URI (java.net.URI)8 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)8