Search in sources :

Example 21 with WebBundleDescriptor

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

the class BeanManagerNamingProxy method handle.

@Override
public Object handle(String name) throws NamingException {
    Object beanManager = null;
    if (BEAN_MANAGER_CONTEXT.equals(name)) {
        try {
            // Use invocation context to find applicable BeanDeploymentArchive.
            ComponentInvocation inv = invocationManager.getCurrentInvocation();
            if (inv != null) {
                JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());
                if (componentEnv != null) {
                    BundleDescriptor bundle = null;
                    if (componentEnv instanceof EjbDescriptor) {
                        bundle = (BundleDescriptor) ((EjbDescriptor) componentEnv).getEjbBundleDescriptor().getModuleDescriptor().getDescriptor();
                    } else if (componentEnv instanceof WebBundleDescriptor) {
                        bundle = (BundleDescriptor) componentEnv;
                    }
                    if (bundle != null) {
                        BeanDeploymentArchive bda = weldDeployer.getBeanDeploymentArchiveForBundle(bundle);
                        if (bda != null) {
                            WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(bundle.getApplication());
                            // System.out.println("BeanManagerNamingProxy:: getting BeanManagerImpl for" + bda);
                            beanManager = bootstrap.getManager(bda);
                        }
                    }
                    if (beanManager == null) {
                        throw new IllegalStateException("Cannot resolve bean manager");
                    }
                } else {
                    throw new IllegalStateException("No invocation context found");
                }
            }
        } catch (Throwable t) {
            NamingException ne = new NamingException("Error retrieving java:comp/BeanManager");
            ne.initCause(t);
            throw ne;
        }
    }
    return beanManager;
}
Also used : WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) WeldBootstrap(org.jboss.weld.bootstrap.WeldBootstrap) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) NamingException(javax.naming.NamingException) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 22 with WebBundleDescriptor

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

the class ValidationNamingProxy method obtainBeanManager.

/**
 * Obtain the BeanManagerNamingProxy from hk2, so the BeanManager can be looked up
 *
 * @throws NamingException
 */
private synchronized BeanManager obtainBeanManager() throws NamingException {
    BeanManager beanManager = null;
    // Use invocation context to find applicable BeanDeploymentArchive.
    ComponentInvocation inv = invocationManager.getCurrentInvocation();
    if (inv != null) {
        JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());
        if (componentEnv != null) {
            BundleDescriptor bundle = null;
            if (componentEnv instanceof EjbDescriptor) {
                bundle = (BundleDescriptor) ((EjbDescriptor) componentEnv).getEjbBundleDescriptor().getModuleDescriptor().getDescriptor();
            } else if (componentEnv instanceof WebBundleDescriptor) {
                bundle = (BundleDescriptor) componentEnv;
            }
            if (bundle != null) {
                BeanDeploymentArchive bda = weldDeployer.getBeanDeploymentArchiveForBundle(bundle);
                if (bda != null) {
                    WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(bundle.getApplication());
                    beanManager = bootstrap.getManager(bda);
                }
            }
        }
    }
    return beanManager;
}
Also used : WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) WeldBootstrap(org.jboss.weld.bootstrap.WeldBootstrap) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) BeanManager(javax.enterprise.inject.spi.BeanManager) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 23 with WebBundleDescriptor

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

the class WeldDeployer method addWeldListenerToAllWars.

private void addWeldListenerToAllWars(DeploymentContext context) {
    // if there's at least 1 ejb jar then add the listener to all wars
    ApplicationHolder applicationHolder = context.getModuleMetaData(ApplicationHolder.class);
    if (applicationHolder != null) {
        if (applicationHolder.app.getBundleDescriptors(EjbBundleDescriptor.class).size() > 0) {
            Set<WebBundleDescriptor> webBundleDescriptors = applicationHolder.app.getBundleDescriptors(WebBundleDescriptor.class);
            for (WebBundleDescriptor oneWebBundleDescriptor : webBundleDescriptors) {
                // Add the Weld Listener if it does not already exist..
                // we have to do this regardless because the war may not be cdi-enabled but an ejb is.
                oneWebBundleDescriptor.addAppListenerDescriptorToFirst(new AppListenerDescriptorImpl(WELD_LISTENER));
                oneWebBundleDescriptor.addAppListenerDescriptor(new AppListenerDescriptorImpl(WeldTerminationListenerProxy.class.getName()));
            }
        }
    }
}
Also used : ApplicationHolder(org.glassfish.javaee.core.deployment.ApplicationHolder) AppListenerDescriptorImpl(org.glassfish.web.deployment.descriptor.AppListenerDescriptorImpl) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

Example 24 with WebBundleDescriptor

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

the class AppServRegistry method getWebModule.

/*
     * This function is called once for every endpoint registration.
     * and the WebModule corresponding to that endpoint is stored.
     */
static WebModule getWebModule(WebServiceEndpoint wsep) {
    ApplicationRegistry appRegistry = org.glassfish.internal.api.Globals.getDefaultHabitat().getService(ApplicationRegistry.class);
    String appName = wsep.getBundleDescriptor().getApplication().getAppName();
    ApplicationInfo appInfo = appRegistry.get(appName);
    WebApplication webApp = null;
    if (appInfo != null) {
        Collection<ModuleInfo> moduleInfos = appInfo.getModuleInfos();
        Set<EngineRef> engineRefs = null;
        WebBundleDescriptor requiredWbd = (WebBundleDescriptor) wsep.getBundleDescriptor();
        for (ModuleInfo moduleInfo : moduleInfos) {
            engineRefs = moduleInfo.getEngineRefs();
            for (EngineRef engineRef : engineRefs) {
                if (engineRef.getApplicationContainer() instanceof WebApplication) {
                    webApp = (WebApplication) engineRef.getApplicationContainer();
                    WebBundleDescriptor wbd = webApp.getDescriptor();
                    if (wbd.equals(requiredWbd)) {
                        // WebApp corresponding to wsep is found.
                        break;
                    } else {
                        webApp = null;
                    }
                }
            }
        }
    }
    // get the required WebModule from the webApp.
    if (webApp != null) {
        String requiredModule = ((WebBundleDescriptor) wsep.getBundleDescriptor()).getModuleName();
        Set<WebModule> webModules = webApp.getWebModules();
        for (WebModule wm : webModules) {
            if (wm.getModuleName().equalsIgnoreCase(requiredModule)) {
                return wm;
            }
        }
    }
    return null;
}
Also used : ApplicationRegistry(org.glassfish.internal.data.ApplicationRegistry) ModuleInfo(org.glassfish.internal.data.ModuleInfo) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) WebModule(com.sun.enterprise.web.WebModule) WebApplication(com.sun.enterprise.web.WebApplication) EngineRef(org.glassfish.internal.data.EngineRef)

Example 25 with WebBundleDescriptor

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

the class WebBundleDescriptorImpl method combineEnvironmentEntries.

@Override
protected void combineEnvironmentEntries(JndiNameEnvironment env) {
    for (Object oenve : env.getEnvironmentProperties()) {
        EnvironmentEntry enve = (EnvironmentEntry) oenve;
        EnvironmentProperty envProp = _getEnvironmentPropertyByName(enve.getName());
        if (envProp != null) {
            combineInjectionTargets(envProp, (EnvironmentProperty) enve);
            EnvironmentProperty envP = (EnvironmentProperty) enve;
            if (!envProp.hasInjectionTargetFromXml() && (!envProp.isSetValueCalled()) && envP.isSetValueCalled()) {
                envProp.setValue(enve.getValue());
            }
        } else {
            if (env instanceof WebBundleDescriptor && ((WebBundleDescriptor) env).isConflictEnvironmentEntry()) {
                throw new IllegalArgumentException(localStrings.getLocalString("web.deployment.exceptionconflictenventry", "There are more than one environment entries defined in web fragments with the same name, but not overrided in web.xml"));
            } else {
                addEnvironmentEntry(enve);
            }
        }
    }
}
Also used : EnvironmentEntry(com.sun.enterprise.deployment.web.EnvironmentEntry) EnvironmentProperty(com.sun.enterprise.deployment.EnvironmentProperty) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

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