Search in sources :

Example 1 with ComponentEnvManager

use of com.sun.enterprise.container.common.spi.util.ComponentEnvManager in project Payara by payara.

the class SafeProperties method setupEnvironment.

private void setupEnvironment() throws javax.naming.NamingException {
    // call the NamingManager to setup the java:comp/env namespace
    // for this EJB.
    ComponentEnvManager envManager = ejbContainerUtilImpl.getComponentEnvManager();
    componentId = envManager.bindToComponentNamespace(ejbDescriptor);
    invFactory = new EjbInvocationFactory(componentId, this);
    ejbContainerUtilImpl.registerContainer(this);
    // create envProps object to be returned from EJBContext.getEnvironment
    Set env = ejbDescriptor.getEnvironmentProperties();
    SafeProperties safeProps = new SafeProperties();
    safeProps.copy(env);
    envProps = safeProps;
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager)

Example 2 with ComponentEnvManager

use of com.sun.enterprise.container.common.spi.util.ComponentEnvManager in project Payara by payara.

the class InternalInterceptorBindingImpl method registerInterceptor.

public void registerInterceptor(Object systemInterceptor) {
    InvocationManager invManager = services.getService(InvocationManager.class);
    ComponentInvocation currentInv = invManager.getCurrentInvocation();
    if (currentInv == null) {
        throw new IllegalStateException("no current invocation");
    } else if (currentInv.getInvocationType() != ComponentInvocation.ComponentInvocationType.SERVLET_INVOCATION) {
        throw new IllegalStateException("Illegal invocation type : " + currentInv.getInvocationType() + ".  This operation is only available from a web app context");
    }
    ComponentEnvManager compEnvManager = services.getService(ComponentEnvManager.class);
    JndiNameEnvironment env = compEnvManager.getCurrentJndiNameEnvironment();
    BundleDescriptor webBundle = (BundleDescriptor) env;
    ModuleDescriptor moduleDesc = webBundle.getModuleDescriptor();
    // Register interceptor for EJB components
    if (EjbContainerUtilImpl.isInitialized()) {
        Collection<EjbBundleDescriptor> ejbBundles = moduleDesc.getDescriptor().getExtensionsDescriptors(EjbBundleDescriptor.class);
        if (ejbBundles.size() == 1) {
            EjbBundleDescriptor ejbBundle = ejbBundles.iterator().next();
            for (EjbDescriptor ejb : ejbBundle.getEjbs()) {
                BaseContainer container = EjbContainerUtilImpl.getInstance().getContainer(ejb.getUniqueId());
                container.registerSystemInterceptor(systemInterceptor);
            }
        }
    }
    // Register interceptor for any managed beans
    // TODO Handle 299-enabled case
    ManagedBeanManager managedBeanManager = services.getService(ManagedBeanManager.class, "ManagedBeanManagerImpl");
    managedBeanManager.registerRuntimeInterceptor(systemInterceptor, webBundle);
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationManager(org.glassfish.api.invocation.InvocationManager) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) ManagedBeanManager(com.sun.enterprise.container.common.spi.ManagedBeanManager)

Example 3 with ComponentEnvManager

use of com.sun.enterprise.container.common.spi.util.ComponentEnvManager in project Payara by payara.

the class WebModuleContextConfig method stop.

/**
 * Process a "stop" event for this Context.
 */
@Override
protected synchronized void stop() {
    super.stop();
    ComponentEnvManager namingMgr = services.getService(com.sun.enterprise.container.common.spi.util.ComponentEnvManager.class);
    unbindFromComponentNamespace(namingMgr);
}
Also used : java.util(java.util) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager)

Example 4 with ComponentEnvManager

use of com.sun.enterprise.container.common.spi.util.ComponentEnvManager in project Payara by payara.

the class JavaModuleNamingProxy method getModuleName.

private String getModuleName() throws NamingException {
    ComponentEnvManager namingMgr = habitat.getService(ComponentEnvManager.class);
    String moduleName = null;
    if (namingMgr != null) {
        JndiNameEnvironment env = namingMgr.getCurrentJndiNameEnvironment();
        BundleDescriptor bd = null;
        if (env instanceof EjbDescriptor) {
            bd = ((EjbDescriptor) env).getEjbBundleDescriptor();
        } else if (env instanceof BundleDescriptor) {
            bd = (BundleDescriptor) env;
        }
        if (bd != null) {
            moduleName = bd.getModuleDescriptor().getModuleName();
        }
    }
    if (moduleName == null) {
        throw new NamingException("Could not resolve " + JAVA_MODULE_NAME);
    }
    return moduleName;
}
Also used : ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) NamingException(javax.naming.NamingException)

Example 5 with ComponentEnvManager

use of com.sun.enterprise.container.common.spi.util.ComponentEnvManager in project Payara by payara.

the class ManagedBeanManagerImpl method getBundle.

private BundleDescriptor getBundle() {
    ComponentEnvManager compEnvManager = habitat.getService(ComponentEnvManager.class);
    JndiNameEnvironment env = compEnvManager.getCurrentJndiNameEnvironment();
    BundleDescriptor bundle = null;
    if (env instanceof BundleDescriptor) {
        bundle = (BundleDescriptor) env;
    } else if (env instanceof EjbDescriptor) {
        bundle = (BundleDescriptor) ((EjbDescriptor) env).getEjbBundleDescriptor().getModuleDescriptor().getDescriptor();
    }
    if (bundle == null) {
        throw new IllegalStateException("Invalid context for managed bean creation");
    }
    return bundle;
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Aggregations

ComponentEnvManager (com.sun.enterprise.container.common.spi.util.ComponentEnvManager)13 NamingException (javax.naming.NamingException)4 WebServiceException (javax.xml.ws.WebServiceException)3 ManagedBeanManager (com.sun.enterprise.container.common.spi.ManagedBeanManager)2 InjectionException (com.sun.enterprise.container.common.spi.util.InjectionException)2 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)2 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)2 java.util (java.util)2 InvocationManager (org.glassfish.api.invocation.InvocationManager)2 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)2 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)1 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)1 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)1 WebServicesDescriptor (com.sun.enterprise.deployment.WebServicesDescriptor)1 SystemHandlerDelegate (com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate)1 RequestTracingService (fish.payara.nucleus.requesttracing.RequestTracingService)1 String (java.lang.String)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1