Search in sources :

Example 6 with JndiNameEnvironment

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

the class InjectionManagerImpl method injectInstance.

public void injectInstance(Object instance, boolean invokePostConstruct) throws InjectionException {
    ComponentInvocation invocation = invocationMgr.getCurrentInvocation();
    if (invocation == null) {
        throw new InjectionException(localStrings.getLocalString("injection-manager.null-invocation-context", "Null invocation context"));
    }
    JndiNameEnvironment componentEnvironment = compEnvManager.getJndiNameEnvironment(invocation.getComponentId());
    if (componentEnvironment == null) {
        throw new InjectionException(localStrings.getLocalString("injection-manager.no-descriptor-registered-for-invocation", "No descriptor registered for current invocation: {0}", invocation));
    }
    inject(instance.getClass(), instance, componentEnvironment, null, invokePostConstruct);
}
Also used : InjectionException(com.sun.enterprise.container.common.spi.util.InjectionException) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation)

Example 7 with JndiNameEnvironment

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

the class AppSpecificConnectorClassLoaderUtil method processDescriptorForRAReferences.

private void processDescriptorForRAReferences(Application app, Descriptor descriptor, String moduleName) {
    if (descriptor instanceof JndiNameEnvironment) {
        processDescriptorForRAReferences(app, moduleName, (JndiNameEnvironment) descriptor);
    }
    // ejb descriptors
    if (descriptor instanceof EjbBundleDescriptor) {
        EjbBundleDescriptor ejbDesc = (EjbBundleDescriptor) descriptor;
        Set<? extends EjbDescriptor> ejbDescriptors = ejbDesc.getEjbs();
        for (EjbDescriptor ejbDescriptor : ejbDescriptors) {
            processDescriptorForRAReferences(app, moduleName, ejbDescriptor);
            if (ejbDescriptor instanceof EjbMessageBeanDescriptor) {
                EjbMessageBeanDescriptor messageBeanDesc = (EjbMessageBeanDescriptor) ejbDescriptor;
                String raMid = messageBeanDesc.getResourceAdapterMid();
                // there seem to be applications that do not specify ra-mid
                if (raMid != null) {
                    app.addResourceAdapter(raMid);
                }
            }
        }
        // ejb interceptors
        Set<EjbInterceptor> ejbInterceptors = ejbDesc.getInterceptors();
        for (EjbInterceptor ejbInterceptor : ejbInterceptors) {
            processDescriptorForRAReferences(app, moduleName, ejbInterceptor);
        }
    }
    if (descriptor instanceof BundleDescriptor) {
        // managed bean descriptors
        Set<ManagedBeanDescriptor> managedBeanDescriptors = ((BundleDescriptor) descriptor).getManagedBeans();
        for (ManagedBeanDescriptor mbd : managedBeanDescriptors) {
            processDescriptorForRAReferences(app, moduleName, mbd);
        }
    }
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) EjbMessageBeanDescriptor(com.sun.enterprise.deployment.EjbMessageBeanDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) EjbInterceptor(com.sun.enterprise.deployment.EjbInterceptor) ManagedBeanDescriptor(com.sun.enterprise.deployment.ManagedBeanDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 8 with JndiNameEnvironment

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

the class ServletWebServiceDelegate method postInit.

@Override
public void postInit(ServletConfig servletConfig) throws ServletException {
    String servletName = "unknown";
    try {
        WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
        ComponentEnvManager compEnvManager = wscImpl.getComponentEnvManager();
        JndiNameEnvironment jndiNameEnv = compEnvManager.getCurrentJndiNameEnvironment();
        WebBundleDescriptor webBundle = null;
        if (jndiNameEnv != null && jndiNameEnv instanceof WebBundleDescriptor) {
            webBundle = ((WebBundleDescriptor) jndiNameEnv);
        } else {
            throw new WebServiceException("Cannot intialize the JAXRPCServlet for " + jndiNameEnv);
        }
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        servletName = servletConfig.getServletName();
        WebComponentDescriptor webComponent = webBundle.getWebComponentByCanonicalName(servletName);
        if (webComponent != null) {
            WebServicesDescriptor webServices = webBundle.getWebServices();
            Collection endpoints = webServices.getEndpointsImplementedBy(webComponent);
            // Only 1 endpoint per servlet is supported, even though
            // data structure implies otherwise.
            endpoint_ = (WebServiceEndpoint) endpoints.iterator().next();
            registerEndpoint(classLoader);
            // security
            if (secServ != null) {
                SystemHandlerDelegate securityHandlerDelegate = secServ.getSecurityHandler(endpoint_);
                if (securityHandlerDelegate != null) {
                    rpcDelegate_.setSystemHandlerDelegate(securityHandlerDelegate);
                    // need to invoke the endpoint lifecylcle
                    endpointImpl_ = JAXRPCEndpointImpl.class.cast(wsEngine_.createHandler(securityHandlerDelegate, endpoint_));
                    rpcDelegate_.setSystemHandlerDelegate(endpointImpl_);
                }
            }
        } else {
            throw new ServletException(servletName + " not found");
        }
    } catch (Throwable t) {
        String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.SERVLET_ENDPOINT_FAILURE), servletName);
        logger.log(Level.WARNING, msg, t);
        throw new ServletException(t);
    }
}
Also used : WebServicesDescriptor(com.sun.enterprise.deployment.WebServicesDescriptor) WebServiceException(javax.xml.ws.WebServiceException) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) SystemHandlerDelegate(com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) JAXRPCEndpointImpl(org.glassfish.webservices.monitoring.JAXRPCEndpointImpl)

Example 9 with JndiNameEnvironment

use of com.sun.enterprise.deployment.JndiNameEnvironment 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 10 with JndiNameEnvironment

use of com.sun.enterprise.deployment.JndiNameEnvironment 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)

Aggregations

JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)14 ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)8 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)7 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)6 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)5 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)4 InjectionException (com.sun.enterprise.container.common.spi.util.InjectionException)3 ComponentEnvManager (com.sun.enterprise.container.common.spi.util.ComponentEnvManager)2 NamingException (javax.naming.NamingException)2 WeldBootstrap (org.jboss.weld.bootstrap.WeldBootstrap)2 BeanDeploymentArchive (org.jboss.weld.bootstrap.spi.BeanDeploymentArchive)2 EjbInterceptor (com.sun.enterprise.deployment.EjbInterceptor)1 EjbMessageBeanDescriptor (com.sun.enterprise.deployment.EjbMessageBeanDescriptor)1 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)1 ServiceReferenceDescriptor (com.sun.enterprise.deployment.ServiceReferenceDescriptor)1 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)1 WebService (com.sun.enterprise.deployment.WebService)1 WebServicesDescriptor (com.sun.enterprise.deployment.WebServicesDescriptor)1 SecurityContext (com.sun.enterprise.security.SecurityContext)1 SystemHandlerDelegate (com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate)1