/** * Insure that timer methods can be invoked for the current operation on this Context. */ private void checkState() throws IllegalStateException { final BaseContext context = (BaseContext) deployment.get(EJBContext.class); context.check(BaseContext.Call.timerMethod); }
public void configureDeployments(final List<BeanContext> ejbDeployments) { beans = new WeakHashMap<Class<?>, BeanContext>(); for (final BeanContext deployment : ejbDeployments) { if (deployment.getComponentType().isSession()) { if (deployment.isLocalbean() && !deployment.isDynamicallyImplemented()) { beans.put(deployment.get(BeanContext.ProxyClass.class).getProxy(), deployment); } beans.put(deployment.getBeanClass(), deployment); } } }
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(); } }
private void resumePersistentSchedulers(final AppContext appContext) { final Scheduler globalScheduler = SystemInstance.get().getComponent(Scheduler.class); final Collection<Scheduler> schedulers = new ArrayList<Scheduler>(); for (final BeanContext ejb : appContext.getBeanContexts()) { final Scheduler scheduler = ejb.get(Scheduler.class); if (scheduler == null || scheduler == globalScheduler || schedulers.contains(scheduler)) { continue; } schedulers.add(scheduler); try { scheduler.resumeAll(); } catch (final Exception e) { logger.warning("Failed to resume scheduler for " + ejb.getEjbName(), e); } } }
@SuppressWarnings("unchecked") public <T> void inject(final T instance, CreationalContext<T> ctx) { final WebBeansContext webBeansContext = getWebBeansContext(); if (webBeansContext == null) { return; } InjectionTargetBean<T> beanDefinition = get(CdiEjbBean.class); if (beanDefinition == null) { beanDefinition = InjectionTargetBean.class.cast(createConstructorInjectionBean(webBeansContext)); } if (!(ctx instanceof CreationalContextImpl)) { ctx = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(ctx, beanDefinition); } beanDefinition.getInjectionTarget().inject(instance, ctx); }
public void configureDeployments(final List<BeanContext> ejbDeployments) { beans = new WeakHashMap<>(); for (final BeanContext deployment : ejbDeployments) { if (deployment.getComponentType().isCdiCompatible()) { if (deployment.isLocalbean() && !deployment.isDynamicallyImplemented()) { beans.put(deployment.get(BeanContext.ProxyClass.class).getProxy(), deployment); } beans.put(deployment.getBeanClass(), deployment); } } }
/** * Insure that timer methods can be invoked for the current operation on this Context. */ private void checkState() throws IllegalStateException { final BaseContext context = (BaseContext) deployment.get(EJBContext.class); context.doCheck(BaseContext.Call.timerMethod); }
@SuppressWarnings("unchecked") public <T> void inject(final T instance, CreationalContext<T> ctx) { final WebBeansContext webBeansContext = getWebBeansContext(); if (webBeansContext == null) { return; } InjectionTargetBean<T> beanDefinition = get(CdiEjbBean.class); if (beanDefinition == null) { beanDefinition = InjectionTargetBean.class.cast(createConstructorInjectionBean(webBeansContext)); } if (!(ctx instanceof CreationalContextImpl)) { ctx = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(ctx, beanDefinition); } beanDefinition.getInjectionTarget().inject(instance, ctx); }
@Override public <T> Bean<T> defineNewSessionBean(final Class<T> clazz) { return new NewCdiEjbBean<T>(findBeanContext(webBeansContext, clazz).get(CdiEjbBean.class)); }
@Override public <T> Bean<T> defineNewSessionBean(final Class<T> clazz) { return new NewCdiEjbBean<T>(findBeanContext(webBeansContext, clazz).get(CdiEjbBean.class)); }
public WebBeansContext getWebBeansContext() { final CdiEjbBean<?> bean = get(CdiEjbBean.class); if (bean != null) { return bean.getWebBeansContext(); } return moduleContext.getAppContext().getWebBeansContext(); }
public ConcurrentMap getLiveHandleRegistry() { final BeanContext beanContext = getBeanContext(); ProxyRegistry proxyRegistry = beanContext.get(ProxyRegistry.class); if (proxyRegistry == null) { proxyRegistry = new ProxyRegistry(); beanContext.set(ProxyRegistry.class, proxyRegistry); } return proxyRegistry.liveHandleRegistry; }
public WebBeansContext getWebBeansContext() { final CdiEjbBean<?> bean = get(CdiEjbBean.class); if (bean != null) { return bean.getWebBeansContext(); } return moduleContext.getAppContext().getWebBeansContext(); }
/** * This may not be that performant, but it's certain to be faster than the * user having to track down which deployment is using a particular jndi name * * @param name * @return . */ private BeanContext findNameOwner(final String name) { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); for (final BeanContext beanContext : containerSystem.deployments()) { final Bindings bindings = beanContext.get(Bindings.class); if (bindings != null && bindings.getBindings().contains(name)) { return beanContext; } } return null; }
/** * This may not be that performant, but it's certain to be faster than the * user having to track down which deployment is using a particular jndi name * * @param name * @return . */ private BeanContext findNameOwner(final String name) { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); for (final BeanContext beanContext : containerSystem.deployments()) { final Bindings bindings = beanContext.get(Bindings.class); if (bindings != null && bindings.getBindings().contains(name)) { return beanContext; } } return null; }
public Principal getCallerPrincipal() { // if security is not enabled, we don't have a principal ThreadContext threadContext = ThreadContext.getThreadContext(); BeanContext deploymentInfo = threadContext.getBeanContext(); EjbDeployment ejbDeployment = deploymentInfo.get(EjbDeployment.class); if (ejbDeployment == null || !ejbDeployment.isSecurityEnabled()) { return null; } Subject callerSubject = ContextManager.getCurrentCaller(); return ContextManager.getCurrentPrincipal(callerSubject); }
public boolean isPassivatingScope() { final CdiEjbBean<?> bean = get(CdiEjbBean.class); if (bean == null) { return true; } if (ConversationScoped.class == bean.getScope()) { try { return !bean.getWebBeansContext().getConversationManager().getConversationBeanReference().isTransient(); } catch (final RuntimeException re) { // conversation not found for instance so act as @RequestScoped return false; } } return true; }
public boolean isPassivatingScope() { final CdiEjbBean<?> bean = get(CdiEjbBean.class); if (bean == null) { return true; } if (ConversationScoped.class == bean.getScope()) { try { return !bean.getWebBeansContext().getConversationManager().getConversationBeanReference().isTransient(); } catch (final RuntimeException re) { // conversation not found for instance so act as @RequestScoped return false; } } return true; }
public void release(@Observes final EventContext<BeforeUnDeploy> event) { if (!SystemInstance.isInitialized()) { event.proceed(); return; } try { event.proceed(); } finally { final BeanContext bc = beanContext(); if (bc != null) { // can be null if deployment exception final CreationalContext<?> cc = bc.get(CreationalContext.class); if (cc != null) { cc.release(); } } } }
/** * Insure that timer methods can be invoked for the current operation on this Context. */ private void checkState() throws IllegalStateException, NoSuchObjectLocalException { final BeanContext beanContext = ThreadContext.getThreadContext().getBeanContext(); final BaseContext context = (BaseContext) beanContext.get(EJBContext.class); context.check(BaseContext.Call.timerMethod); if (timerData.isCancelled() && !timerData.isStopped()) { throw new NoSuchObjectLocalException("Timer has been cancelled"); } if (timerData.isExpired()) { throw new NoSuchObjectLocalException("The timer has expired"); } }