Search in sources :

Example 36 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.

the class DynamicWebServletRegistrationImpl method addMapping.

@Override
public Set<String> addMapping(String... urlPatterns) {
    Set<String> conflicts = super.addMapping(urlPatterns);
    if (conflicts.isEmpty() && urlPatterns != null && urlPatterns.length > 0) {
        /*
             * Propagate the new mappings to the underlying 
             * WebBundleDescriptor provided by the deployment backend,
             * so that corresponding security constraints may be calculated
             * by the security subsystem, which uses the
             * WebBundleDescriptor as its input
             */
        WebBundleDescriptor wbd = ((WebModule) getContext()).getWebBundleDescriptor();
        if (wbd == null) {
            throw new IllegalStateException("Missing WebBundleDescriptor for " + getContext().getName());
        }
        WebComponentDescriptor wcd = wbd.getWebComponentByCanonicalName(getName());
        if (wcd == null) {
            throw new IllegalStateException("Missing WebComponentDescriptor for " + getName());
        }
        for (String urlPattern : urlPatterns) {
            wcd.addUrlPattern(urlPattern);
        }
    }
    return conflicts;
}
Also used : WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) PwcWebModule(com.sun.enterprise.web.pwc.PwcWebModule)

Example 37 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.

the class WeldDeployer method isDevelopmentMode.

private boolean isDevelopmentMode(DeploymentContext context) {
    boolean devMode = WeldUtils.isCDIDevModeEnabled(context) || Boolean.getBoolean(DEV_MODE_PROPERTY);
    WebBundleDescriptor wDesc = context.getModuleMetaData(WebBundleDescriptor.class);
    if (!devMode && wDesc != null) {
        Enumeration<ContextParameter> cpEnumeration = wDesc.getContextParameters();
        while (cpEnumeration.hasMoreElements()) {
            ContextParameter param = cpEnumeration.nextElement();
            if (DEV_MODE_PROPERTY.equals(param.getName()) && Boolean.valueOf(param.getValue())) {
                devMode = true;
                WeldUtils.setCDIDevMode(context, devMode);
                break;
            }
        }
    }
    return devMode;
}
Also used : ContextParameter(com.sun.enterprise.deployment.web.ContextParameter) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

Example 38 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor 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);
        BootstrapConfigurationImpl bootstrapConfiguration = new BootstrapConfigurationImpl();
        deploymentImpl.getServices().add(BootstrapConfiguration.class, bootstrapConfiguration);
        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);
    }
    DeployCommandParameters dc = context.getCommandParameters(DeployCommandParameters.class);
    ExternalConfigurationImpl externalConfiguration = new ExternalConfigurationImpl();
    externalConfiguration.setRollingUpgradesDelimiter(System.getProperty("fish.payara.rollingUpgradesDelimiter", ":"));
    externalConfiguration.setBeanIndexOptimization(dc != null ? !dc.isAvailabilityEnabled() : true);
    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);
                if (logger.isLoggable(FINE)) {
                    logger.log(FINE, ADDING_INJECTION_SERVICES, new Object[] { injectionServices, beanDeploymentArchive.getId() });
                }
                beanDeploymentArchive.getServices().add(InjectionServices.class, injectionServices);
                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) ExternalConfigurationImpl(org.glassfish.weld.services.ExternalConfigurationImpl) SecurityServices(org.jboss.weld.security.spi.SecurityServices) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) WeldBootstrap(org.jboss.weld.bootstrap.WeldBootstrap) NonModuleInjectionServices(org.glassfish.weld.services.NonModuleInjectionServices) InjectionServices(org.jboss.weld.injection.spi.InjectionServices) EjbServicesImpl(org.glassfish.weld.services.EjbServicesImpl) ProxyServicesImpl(org.glassfish.weld.services.ProxyServicesImpl) TransactionServicesImpl(org.glassfish.weld.services.TransactionServicesImpl) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) 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) BootstrapConfigurationImpl(org.glassfish.weld.services.BootstrapConfigurationImpl) AppListenerDescriptorImpl(org.glassfish.web.deployment.descriptor.AppListenerDescriptorImpl) SecurityServicesImpl(org.glassfish.weld.services.SecurityServicesImpl) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) InjectionServicesImpl(org.glassfish.weld.services.InjectionServicesImpl) Application(com.sun.enterprise.deployment.Application) EEModuleDescriptor(org.jboss.weld.bootstrap.spi.EEModuleDescriptor)

Example 39 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.

the class WeldFacesConfigProvider method getResources.

@Override
public Collection<URI> getResources(ServletContext context) {
    ServiceLocator defaultServices = (ServiceLocator) context.getAttribute(HABITAT_ATTRIBUTE);
    invokeMgr = defaultServices.getService(InvocationManager.class);
    ComponentInvocation inv = invokeMgr.getCurrentInvocation();
    WebModule webModule = (WebModule) inv.getContainer();
    WebBundleDescriptor wdesc = webModule.getWebBundleDescriptor();
    List<URI> list = new ArrayList<URI>(1);
    if (!wdesc.hasExtensionProperty(WeldDeployer.WELD_EXTENSION)) {
        return list;
    }
    // Don't use Util.getCurrentLoader().  This config resource should
    // be available from the same classloader that loaded this instance.
    // Doing so allows us to be more OSGi friendly.
    ClassLoader loader = this.getClass().getClassLoader();
    URL resource = loader.getResource(SERVICES_FACES_CONFIG);
    if (resource != null) {
        try {
            list.add(resource.toURI());
        } catch (URISyntaxException ex) {
            if (logger.isLoggable(Level.SEVERE)) {
                logger.log(Level.SEVERE, CDILoggerInfo.SEVERE_ERROR_CREATING_URI_FOR_FACES_CONFIG_XML, new Object[] { resource.toExternalForm(), ex });
            }
        }
    }
    return list;
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) ArrayList(java.util.ArrayList) WebModule(com.sun.enterprise.web.WebModule) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URL(java.net.URL)

Example 40 with WebBundleDescriptor

use of com.sun.enterprise.deployment.WebBundleDescriptor in project Payara by payara.

the class DynamicWebServletRegistrationImpl method contextListenerStart.

@Override
protected void contextListenerStart() {
    ServletContext servletContext = getServletContext();
    WebBundleDescriptor wbd = getWebBundleDescriptor();
    try {
        // for jsf injection
        servletContext.setAttribute(Constants.DEPLOYMENT_CONTEXT_ATTRIBUTE, getWebModuleConfig().getDeploymentContext());
        // null check for OSGi/HTTP
        if (wbd != null) {
            servletContext.setAttribute(Constants.IS_DISTRIBUTABLE_ATTRIBUTE, wbd.isDistributable());
        }
        servletContext.setAttribute(Constants.ENABLE_HA_ATTRIBUTE, Boolean.valueOf(webContainer.getServerConfigLookup().calculateWebAvailabilityEnabledFromConfig(this)));
        super.contextListenerStart();
    } finally {
        servletContext.removeAttribute(Constants.DEPLOYMENT_CONTEXT_ATTRIBUTE);
        servletContext.removeAttribute(Constants.IS_DISTRIBUTABLE_ATTRIBUTE);
        servletContext.removeAttribute(Constants.ENABLE_HA_ATTRIBUTE);
    }
    for (ServletRegistrationImpl srImpl : servletRegisMap.values()) {
        if (srImpl instanceof DynamicWebServletRegistrationImpl) {
            DynamicWebServletRegistrationImpl dwsrImpl = (DynamicWebServletRegistrationImpl) srImpl;
            dwsrImpl.postProcessAnnotations();
        }
    }
    webContainer.afterServletContextInitializedEvent(wbd);
}
Also used : DynamicServletRegistrationImpl(org.apache.catalina.core.DynamicServletRegistrationImpl) ServletRegistrationImpl(org.apache.catalina.core.ServletRegistrationImpl) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) ServletContext(javax.servlet.ServletContext)

Aggregations

WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)47 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)14 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)10 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)9 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)7 Application (com.sun.enterprise.deployment.Application)6 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)5 ArrayList (java.util.ArrayList)4 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)4 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)3 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)3 SecurityConstraint (com.sun.enterprise.deployment.web.SecurityConstraint)3 WebResourceCollection (com.sun.enterprise.deployment.web.WebResourceCollection)3 IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)3 Iterator (java.util.Iterator)3 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2 JMSDestinationDefinitionDescriptor (com.sun.enterprise.deployment.JMSDestinationDefinitionDescriptor)2 XMLNode (com.sun.enterprise.deployment.node.XMLNode)2 LoginConfiguration (com.sun.enterprise.deployment.web.LoginConfiguration)2 File (java.io.File)2