public Object lookup(final String name) { final ThreadContext threadContext = ThreadContext.getThreadContext(); final BeanContext beanContext = threadContext.getBeanContext(); Context jndiEnc = beanContext.getJndiEnc(); try { jndiEnc = (Context) jndiEnc.lookup("comp/env"); return jndiEnc.lookup(name); } catch (final NamingException | RuntimeException e) { throw new IllegalArgumentException(e); } }
public Object lookup(final String name) { final ThreadContext threadContext = ThreadContext.getThreadContext(); final BeanContext beanContext = threadContext.getBeanContext(); Context jndiEnc = beanContext.getJndiEnc(); try { jndiEnc = (Context) jndiEnc.lookup("comp/env"); return jndiEnc.lookup(name); } catch (final NamingException e) { throw new IllegalArgumentException(e); } catch (final RuntimeException e) { throw new IllegalArgumentException(e); } }
public Object readResolve() throws ObjectStreamException { final ThreadContext thrdCntx = ThreadContext.getThreadContext(); final BeanContext deployment = thrdCntx.getBeanContext(); final Context cntx = deployment.getJndiEnc(); try { final Object obj = cntx.lookup(path); if (obj == null) { throw new InvalidObjectException("JNDI ENC context reference could not be properly resolved when bean instance was activated"); } return obj; } catch (final NamingException e) { throw (InvalidObjectException) new InvalidObjectException("JNDI ENC context reference could not be properly resolved due to a JNDI exception, when bean instance was activated").initCause(e); } }
/** * Gets current context deployment context. * * @return context of deployment * @throws NamingException for exception */ private Context getThreadContext() throws NamingException { ThreadContext threadContext = ThreadContext.getThreadContext(); Context context = threadContext.getBeanContext().getJndiEnc(); return context; }
public Object readResolve() throws ObjectStreamException { final ThreadContext thrdCntx = ThreadContext.getThreadContext(); final BeanContext deployment = thrdCntx.getBeanContext(); final Context cntx = deployment.getJndiEnc(); try { final Object obj = cntx.lookup(path); if (obj == null) { throw new InvalidObjectException("JNDI ENC context reference could not be properly resolved when bean instance was activated"); } return obj; } catch (final NamingException e) { throw (InvalidObjectException) new InvalidObjectException("JNDI ENC context reference could not be properly resolved due to a JNDI exception, when bean instance was activated").initCause(e); } }
private EntityManager getEntityManager(final BeanContext beanContext) { EntityManager entityManager = null; try { entityManager = (EntityManager) beanContext.getJndiEnc().lookup(CMP_PERSISTENCE_CONTEXT_REF_NAME); } catch (final NamingException ignored) { //TODO see OPENEJB-1259 temporary hack until geronimo jndi integration works better try { entityManager = (EntityManager) new InitialContext().lookup("java:" + CMP_PERSISTENCE_CONTEXT_REF_NAME); } catch (final NamingException ignored2) { //ignore } } if (entityManager == null) { throw new EJBException("Entity manager not found at \"openejb/cmp\" in jndi ejb " + beanContext.getDeploymentID()); } registerListener(entityManager); return entityManager; }
private EntityManager getEntityManager(final BeanContext beanContext) { EntityManager entityManager = null; try { entityManager = (EntityManager) beanContext.getJndiEnc().lookup(CMP_PERSISTENCE_CONTEXT_REF_NAME); } catch (final NamingException ignored) { //TODO see OPENEJB-1259 temporary hack until geronimo jndi integration works better try { entityManager = (EntityManager) new InitialContext().lookup("java:" + CMP_PERSISTENCE_CONTEXT_REF_NAME); } catch (final NamingException ignored2) { //ignore } } if (entityManager == null) { throw new EJBException("Entity manager not found at \"openejb/cmp\" in jndi ejb " + beanContext.getDeploymentID()); } registerListener(entityManager); return entityManager; }
/** * Creates a MdbInstanceFactory for a single specific deployment. * * @param beanContext the deployment for which instances will be created * @param securityService the transaction manager for this container system * @param instanceLimit the maximal number of instances or <= 0 if unlimited */ public MdbInstanceFactory(final BeanContext beanContext, final SecurityService securityService, final int instanceLimit) throws OpenEJBException { this.beanContext = beanContext; this.instanceLimit = instanceLimit; mdbContext = new MdbContext(securityService); try { final Context context = beanContext.getJndiEnc(); context.bind("comp/EJBContext", mdbContext); context.bind("comp/TimerService", new TimerServiceWrapper()); } catch (final NamingException e) { throw new OpenEJBException("Failed to bind EJBContext/TimerService", e); } beanContext.set(EJBContext.class, this.mdbContext); }
/** * Creates a MdbInstanceFactory for a single specific deployment. * * @param beanContext the deployment for which instances will be created * @param securityService the transaction manager for this container system * @param instanceLimit the maximal number of instances or <= 0 if unlimited */ public MdbInstanceFactory(final BeanContext beanContext, final SecurityService securityService, final int instanceLimit) throws OpenEJBException { this.beanContext = beanContext; this.instanceLimit = instanceLimit; mdbContext = new MdbContext(securityService); try { final Context context = beanContext.getJndiEnc(); context.bind("comp/EJBContext", mdbContext); context.bind("comp/TimerService", new TimerServiceWrapper()); } catch (final NamingException e) { throw new OpenEJBException("Failed to bind EJBContext/TimerService", e); } beanContext.set(EJBContext.class, this.mdbContext); }
protected EjbDeployment initialize(BeanContext deploymentInfo) { try { ImmutableFederatedContext federatedContext = (ImmutableFederatedContext) ((DeepBindableContext.ContextWrapper)deploymentInfo.getJndiEnc()).getRootContext(); federatedContext.federateContext(componentContext); federatedContext.federateContext(moduleContext); federatedContext.federateContext(applicationContext); federatedContext.federateContext(globalContext); deploymentInfo.set(EjbDeployment.class, this); this.deploymentInfo.set(deploymentInfo); return this; } catch (NamingException e) { throw new IllegalStateException("Unable to complete EjbDeployment initialization", e); } }
/** * Gets current context deployment context. * * @return context of deployment * @throws NamingException for exception */ private Context getThreadContext() throws NamingException { final ThreadContext threadContext = ThreadContext.getThreadContext(); if (skipEjbContext(threadContext)) { return ContextBindings.getClassLoader(); } final Context context = threadContext.getBeanContext().getJndiEnc(); return context; }
public static Object newProxy(final BeanContext context, final InvocationHandler invocationHandler) { if (QueryProxy.class.isInstance(invocationHandler)) { EntityManager em = null; for (final Injection injection : context.getInjections()) { if (QueryProxy.class.equals(injection.getTarget())) { try { em = (EntityManager) context.getJndiEnc().lookup(injection.getJndiName()); } catch (final NamingException e) { throw new OpenEJBRuntimeException("a dynamic bean should reference at least one correct PersistenceContext", e); } } } if (em == null) { throw new OpenEJBRuntimeException("can't find the entity manager to use for the dynamic bean " + context.getEjbName()); } QueryProxy.class.cast(invocationHandler).setEntityManager(em); } return newProxy(context.getBeanClass(), invocationHandler); }
public static Object newProxy(final BeanContext context, final InvocationHandler invocationHandler) { if (QueryProxy.class.isInstance(invocationHandler)) { EntityManager em = null; for (final Injection injection : context.getInjections()) { if (QueryProxy.class.equals(injection.getTarget())) { try { em = (EntityManager) context.getJndiEnc().lookup(injection.getJndiName()); } catch (final NamingException e) { throw new OpenEJBRuntimeException("a dynamic bean should reference at least one correct PersistenceContext", e); } } } if (em == null) { throw new OpenEJBRuntimeException("can't find the entity manager to use for the dynamic bean " + context.getEjbName()); } QueryProxy.class.cast(invocationHandler).setEntityManager(em); } return newProxy(context.getBeanClass(), invocationHandler); }
public static Context getContext() { final ThreadContext callContext = ThreadContext.getThreadContext(); if (callContext == null) { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); final ClassLoader current = Thread.currentThread().getContextClassLoader(); final Context globalContext = containerSystem.getJNDIContext(); if (current == null) { return globalContext; } for (final AppContext appContext : containerSystem.getAppContexts()) { for (final WebContext web : appContext.getWebContexts()) { // more specific first if (current.equals(web.getClassLoader())) { return new ContextHandler(web.getJndiEnc()); } } if (current.equals(appContext.getClassLoader())) { return new ContextHandler(appContext.getAppJndiContext()); } } return globalContext; } final BeanContext di = callContext.getBeanContext(); if (di != null) { return di.getJndiEnc(); } else { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); return containerSystem.getJNDIContext(); } }
public EjbEndpoint(final Bus bus, final PortData portData, final BeanContext beanContext, final HTTPTransportFactory httpTransportFactory, final ServiceConfiguration config) { super(bus, portData, beanContext.getJndiEnc(), beanContext.getBeanClass(), httpTransportFactory, config); this.beanContext = beanContext; final String bindingURI = JaxWsUtils.getBindingURI(portData.getBindingID()); implInfo = new JaxWsImplementorInfoImpl((Class) implementor, bindingURI); serviceFactory = configureService(new JaxWsServiceFactoryBean(implInfo), config, CXF_JAXWS_PREFIX); serviceFactory.setBus(bus); serviceFactory.setServiceClass(beanContext.getBeanClass()); // install as first to overwrite annotations (wsdl-file, wsdl-port, wsdl-service) final CxfServiceConfiguration configuration = new CxfServiceConfiguration(portData); serviceFactory.getConfigurations().add(0, configuration); service = doServiceCreate(); }
public EjbEndpoint(Bus bus, PortData portData, BeanContext beanContext, DestinationFactory transportFactory, ServiceConfiguration config) { super(bus, portData, beanContext.getJndiEnc(), beanContext.getBeanClass(), transportFactory, config); this.beanContext = beanContext; String bindingURI = JaxWsUtils.getBindingURI(portData.getBindingID()); implInfo = new JaxWsImplementorInfoImpl((Class) implementor, bindingURI); serviceFactory = configureService(new JaxWsServiceFactoryBean(implInfo), config, CXF_JAXWS_PREFIX); serviceFactory.setBus(bus); serviceFactory.setServiceClass(beanContext.getBeanClass()); // install as first to overwrite annotations (wsdl-file, wsdl-port, wsdl-service) CxfServiceConfiguration configuration = new CxfServiceConfiguration(portData); serviceFactory.getConfigurations().add(0, configuration); service = doServiceCreate(); }
public static Context getContext() { final ThreadContext callContext = ThreadContext.getThreadContext(); if (callContext == null) { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); final ClassLoader current = Thread.currentThread().getContextClassLoader(); final Context globalContext = containerSystem.getJNDIContext(); if (current == null) { return globalContext; } for (final AppContext appContext : containerSystem.getAppContexts()) { for (final WebContext web : appContext.getWebContexts()) { // more specific first if (current.equals(web.getClassLoader())) { return new ContextHandler(web.getJndiEnc()); } } if (current.equals(appContext.getClassLoader())) { return new ContextHandler(appContext.getAppJndiContext()); } } return globalContext; } final BeanContext di = callContext.getBeanContext(); if (di != null) { return di.getJndiEnc(); } else { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); return containerSystem.getJNDIContext(); } }
final Context context = beanContext.getJndiEnc(); context.bind("comp/EJBContext", sessionContext); context.bind("comp/WebServiceContext", webServiceContext);
final Context context = beanContext.getJndiEnc(); context.bind("comp/EJBContext", sessionContext); } catch (final NamingException e) {
Context context = deploymentInfo.getJndiEnc();