@Override public Object getObject() throws NamingException { if (potentials.size() == 1) { return unwrap(defaultValue); } final ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader != null) { for (final Map.Entry<BeanContext, Object> o : potentials.entrySet()) { if (loader.equals(o.getKey().getClassLoader())) { return unwrap(o.getValue()); } } } return unwrap(defaultValue); }
public static ThreadContext enter(final ThreadContext newContext) { if (newContext == null) { throw new NullPointerException("newContext is null"); } // set the thread context class loader final Thread thread = Thread.currentThread(); newContext.oldClassLoader = thread.getContextClassLoader(); thread.setContextClassLoader(newContext.beanContext.getClassLoader()); // update thread local final ThreadContext oldContext = threadStorage.get(); threadStorage.set(newContext); // notify listeners for (final ThreadContextListener listener : listeners) { try { listener.contextEntered(oldContext, newContext); } catch (final Throwable e) { log.warning("ThreadContextListener threw an exception", e); } } // return old context so it can be used for exit call below return oldContext; }
public static ThreadContext enter(final ThreadContext newContext) { if (newContext == null) { throw new NullPointerException("newContext is null"); } // set the thread context class loader newContext.oldClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(newContext.beanContext.getClassLoader()); // update thread local final ThreadContext oldContext = threadStorage.get(); threadStorage.set(newContext); // notify listeners for (final ThreadContextListener listener : listeners) { try { listener.contextEntered(oldContext, newContext); } catch (final Throwable e) { log.warning("ThreadContextListener threw an exception", e); } } // return old context so it can be used for exit call below return oldContext; }
private void readObject(final ObjectInputStream in) throws IOException { final String dId = in.readUTF(); transacted = in.readBoolean(); retryAttempts = in.readInt(); deployment = SystemInstance.get().getComponent(ContainerSystem.class).getBeanContext(dId); transactionManager = getDefaultTransactionManager(); timerStore = deployment.getEjbTimerService().getTimerStore(); scheduler = (Scheduler) Proxy.newProxyInstance(deployment.getClassLoader(), new Class<?>[]{Scheduler.class}, new LazyScheduler(deployment)); }
private void readObject(final ObjectInputStream in) throws IOException { final String dId = in.readUTF(); transacted = in.readBoolean(); retryAttempts = in.readInt(); deployment = SystemInstance.get().getComponent(ContainerSystem.class).getBeanContext(dId); transactionManager = getDefaultTransactionManager(); timerStore = deployment.getEjbTimerService().getTimerStore(); scheduler = (Scheduler) Proxy.newProxyInstance(deployment.getClassLoader(), new Class<?>[]{Scheduler.class}, new LazyScheduler(deployment)); }
public ProxyClass(final BeanContext beanContext, final Class<?>[] interfaces) { Class<?> clazz; try { clazz = LocalBeanProxyFactory.createProxy( beanContext.getBeanClass(), beanContext.getClassLoader(), interfaces); } catch (final Throwable e) { // VerifyError logger.debug(beanContext.getBeanClass().getName() + " is not proxiable", e); clazz = null; } this.proxy = clazz; }
public ProxyClass(final BeanContext beanContext, final Class<?>[] interfaces) { Class<?> clazz; try { clazz = LocalBeanProxyFactory.createProxy( beanContext.getBeanClass(), beanContext.getClassLoader(), interfaces); } catch (final Throwable e) { // VerifyError logger.debug(beanContext.getBeanClass().getName() + " is not proxiable", e); clazz = null; } this.proxy = clazz; }
private TimerStore newTimerStore(final BeanContext beanContext) { for (final DeploymentContext context : Arrays.asList(beanContext, beanContext.getModuleContext(), beanContext.getModuleContext().getAppContext())) { final String timerStoreClass = context.getProperties().getProperty(TIMER_STORE_CLASS); if (timerStoreClass != null) { logger.info("Found timer class: " + timerStoreClass); try { final Class<?> clazz = beanContext.getClassLoader().loadClass(timerStoreClass); try { final Constructor<?> constructor = clazz.getConstructor(TransactionManager.class); return TimerStore.class.cast(constructor.newInstance(EjbTimerServiceImpl.getDefaultTransactionManager())); } catch (final Exception ignored) { return TimerStore.class.cast(clazz.newInstance()); } } catch (final Exception e) { logger.error("Failed to instantiate " + timerStoreClass + ", using default memory timer store"); } } } return new MemoryTimerStore(EjbTimerServiceImpl.getDefaultTransactionManager()); }
private TimerStore newTimerStore(final BeanContext beanContext) { for (final DeploymentContext context : Arrays.asList(beanContext, beanContext.getModuleContext(), beanContext.getModuleContext().getAppContext())) { final String timerStoreClass = context.getProperties().getProperty(TIMER_STORE_CLASS); if (timerStoreClass != null) { logger.info("Found timer class: " + timerStoreClass); try { final Class<?> clazz = beanContext.getClassLoader().loadClass(timerStoreClass); try { final Constructor<?> constructor = clazz.getConstructor(TransactionManager.class); return TimerStore.class.cast(constructor.newInstance(EjbTimerServiceImpl.getDefaultTransactionManager())); } catch (final Exception ignored) { return TimerStore.class.cast(clazz.newInstance()); } } catch (final Exception e) { logger.error("Can't instantiate " + timerStoreClass + ", using default memory timer store"); } } } return new MemoryTimerStore(EjbTimerServiceImpl.getDefaultTransactionManager()); }
private void deployEJB(final String web, final String context, final BeanContext beanContext, final Collection<Object> additionalProviders, final Collection<ServiceInfo> serviceInfos) { final String nopath = getAddress(context, beanContext.getBeanClass()); final RsHttpListener listener = createHttpListener(); final RsRegistry.AddressInfo address = rsRegistry.createRsHttpListener(web, listener, beanContext.getClassLoader(), nopath.substring(NOPATH_PREFIX.length() - 1), virtualHost, auth, realm); services.add(new DeployedService(address.complete, context, beanContext.getBeanClass().getName())); listener.deployEJB(context, getFullContext(address.base, context), beanContext, additionalProviders, new ServiceConfiguration(beanContext.getProperties(), serviceInfos)); LOGGER.info("REST Service: " + address.complete + " -> EJB " + beanContext.getEjbName()); }
Thread.currentThread().setContextClassLoader(beanContext.getClassLoader()); try { final PortData port = WsBuilder.toPortData(portInfo, beanContext.getInjections(), moduleBaseUrl, beanContext.getClassLoader()); ejbLocations.put(bean.ejbDeploymentId, location); final ClassLoader classLoader = beanContext.getClassLoader(); if (wsRegistry != null) { String auth = authMethod;
deployApplication(appInfo, next.getValue().path, restEjbs, comp.getClassLoader(), comp.getInjections(), containerSystem.getAppContext(appInfo.appId).getWebBeansContext(), comp.getJndiContext(), providers, pojoConfigurations, application, wildcard); final BeanContext ctx = ejb.getValue().context; if (BeanType.MANAGED.equals(ctx.getComponentType())) { deployPojo("", ejb.getValue().path, ctx.getBeanClass(), null, ctx.getClassLoader(), ctx.getInjections(), ctx.getJndiContext(), containerSystem.getAppContext(appInfo.appId).getWebBeansContext(),
public EndpointFactory(final ActivationSpec activationSpec, final MdbContainer container, final BeanContext beanContext, final MdbInstanceFactory instanceFactory, final XAResourceWrapper xaResourceWrapper) { this.activationSpec = activationSpec; this.container = container; this.beanContext = beanContext; this.instanceFactory = instanceFactory; classLoader = container.getMessageListenerInterface().getClassLoader(); interfaces = new Class[]{container.getMessageListenerInterface(), MessageEndpoint.class}; this.xaResourceWrapper = xaResourceWrapper; final BeanContext.ProxyClass proxyClass = beanContext.get(BeanContext.ProxyClass.class); if (proxyClass == null) { proxy = LocalBeanProxyFactory.createProxy(beanContext.getBeanClass(), beanContext.getClassLoader(), interfaces); beanContext.set(BeanContext.ProxyClass.class, new BeanContext.ProxyClass(beanContext, interfaces)); } else { proxy = proxyClass.getProxy(); } }
public EndpointFactory(final ActivationSpec activationSpec, final BaseMdbContainer container, final BeanContext beanContext, final MdbInstanceFactory instanceFactory, final MdbInstanceManager instanceManager, final XAResourceWrapper xaResourceWrapper, boolean usePool) { this.activationSpec = activationSpec; this.container = container; this.beanContext = beanContext; this.instanceFactory = instanceFactory; this.instanceManager = instanceManager; classLoader = container.getMessageListenerInterface().getClassLoader(); interfaces = new Class[]{container.getMessageListenerInterface(), MessageEndpoint.class}; this.xaResourceWrapper = xaResourceWrapper; this.usePool = usePool; final BeanContext.ProxyClass proxyClass = beanContext.get(BeanContext.ProxyClass.class); if (proxyClass == null) { proxy = LocalBeanProxyFactory.createProxy(beanContext.getBeanClass(), beanContext.getClassLoader(), interfaces); beanContext.set(BeanContext.ProxyClass.class, new BeanContext.ProxyClass(beanContext, interfaces)); } else { proxy = proxyClass.getProxy(); } }
if (webBeansContext.getBeanManagerImpl().isNormalScope(scopeClass)) { final BeanContext beanContext = cdiEjbBean.getBeanContext(); final Provider provider = webBeansContext.getNormalScopeProxyFactory().getInstanceProvider(beanContext.getClassLoader(), cdiEjbBean); final Class<?> proxyClass = normalScopeProxyFactory.createProxyClass(beanContext.getClassLoader(), beanContext.getBeanClass()); instance = normalScopeProxyFactory.createProxyInstance(proxyClass, provider);
if (webBeansContext.getBeanManagerImpl().isNormalScope(scopeClass)) { final BeanContext beanContext = cdiEjbBean.getBeanContext(); final Provider provider = webBeansContext.getNormalScopeProxyFactory().getInstanceProvider(beanContext.getClassLoader(), cdiEjbBean); final Class<?> proxyClass = normalScopeProxyFactory.createProxyClass(beanContext.getClassLoader(), beanContext.getBeanClass()); instance = normalScopeProxyFactory.createProxyInstance(proxyClass, provider);
@Override protected HttpListener createEjbWsContainer(final URL url, final PortData port, final BeanContext beanContext, final ServiceConfiguration serviceInfos) throws Exception { final ClassLoader classLoader = beanContext.getClassLoader(); // todo build JaxRpcServiceInfo in assembler final JaxRpcServiceInfo serviceInfo = getJaxRpcServiceInfo(classLoader); // Build java service descriptor final JavaServiceDescBuilder javaServiceDescBuilder = new JavaServiceDescBuilder(serviceInfo, classLoader); final JavaServiceDesc serviceDesc = javaServiceDescBuilder.createServiceDesc(); // Create service final RPCProvider provider = new EjbRpcProvider(beanContext, createHandlerInfos(port.getHandlerChains())); final SOAPService service = new SOAPService(null, provider, null); service.setServiceDescription(serviceDesc); // Set class name service.setOption("className", beanContext.getServiceEndpointInterface().getName()); serviceDesc.setImplClass(beanContext.getServiceEndpointInterface()); // Create container final AxisWsContainer container = new AxisWsContainer(port.getWsdlUrl(), service, null, classLoader); wsContainers.put(beanContext.getDeploymentID().toString(), container); return container; }
Thread.currentThread().setContextClassLoader(getBeanContext().getClassLoader()); try { args = copyArgs(args);
Thread.currentThread().setContextClassLoader(deployment.getClassLoader()); } else { Thread.currentThread().setContextClassLoader(EjbTimerServiceImpl.class.getClassLoader());
Thread.currentThread().setContextClassLoader(deployment.getClassLoader()); } else { Thread.currentThread().setContextClassLoader(EjbTimerServiceImpl.class.getClassLoader());