@Override public void destroyContext(AbstractContext context) { context.destroy(); }
/** * {@inheritDoc} */ public void destroy() { Set<Contextual<?>> keySet = new HashSet<>(componentInstanceMap.keySet()); for (Contextual<?> contextual: keySet) { destroyInstance(contextual); } setActive(false); }
/** * {@inheritDoc} */ @Override public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext) { checkActive(); return getInstance(contextual, creationalContext); }
@Override public void setActive(AbstractContext context) { context.setActive(true); }
creationalContext = owbContext.getCreationalContext(contextual); owbContext.initContextualBag((OwbBean<Object>)this.ejbBean, creationalContext);
/** * Creates a new context with given scope type. * * @param scopeType context scope type */ protected AbstractContext(Class<? extends Annotation> scopeType) { this.scopeType = scopeType; setComponentInstanceMap(); }
@Override public void destroy(Contextual<?> contextual) { destroyInstance(contextual); }
/** * Check that context is active or throws exception. */ protected void checkActive() { if (!active) { throw new ContextNotActiveException("WebBeans context with scope annotation @" + getScope().getName() + " is not active with respect to the current thread"); } }
/** * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public <T> T get(Contextual<T> component) { checkActive(); BeanInstanceBag bag = componentInstanceMap.get(component); if(bag != null) { return (T) bag.getBeanInstance(); } return null; }
if(bag == null) bag = createContextualBag(contextual, creationalContext);
private void initiateBeanBag(OwbBean<Object> bean, CreationalContext<Object> creationalContext) { Context webbeansContext = BeanManagerImpl.getManager().getContext(bean.getScope()); if (webbeansContext instanceof AbstractContext) { AbstractContext owbContext = (AbstractContext)webbeansContext; owbContext.initContextualBag(bean, creationalContext); } }
@Override public void setInactive(AbstractContext context) { context.setActive(false); }
setComponentInstanceMap(); if (componentInstanceMap == null)
/** * Internal destroy method. */ public void destroyInstance(Contextual<?> contextual) { BeanInstanceBag<?> instance = componentInstanceMap.get(contextual); if (instance == null) { // just exit if people manually invoke destroy after the bean already got ditched return; } //Get creational context CreationalContext<Object> cc = (CreationalContext<Object>)instance.getBeanCreationalContext(); //Destroy instance Object beanInstance = instance.getBeanInstance(); if (beanInstance != null) { destroyInstance((Contextual<Object>)contextual, beanInstance, cc); } }
@Override public void destroy(Contextual<?> contextual) { super.destroy(contextual); RequestScopedBeanInterceptorHandler.removeThreadLocals(); } }
/** * This method should only get called at container shutdown. * It will destroy the Extensions as well */ public void destroySystemBeans() { super.destroy(); setActive(false); }