/** * Will re-inject any managed beans in the target. Will not call any other life-cycle methods * * @param ctx * @param managedBean */ @SuppressWarnings("unchecked") static void reinitialize(Context ctx, Contextual<Object> contextual) { try { ManagedBean<Object> managedBean = ManagedBean.class.cast(contextual); LOGGER.debug("Re-Initializing bean '{}' in context '{}'", managedBean, ctx); Object get = ctx.get(managedBean); if (get != null) { LOGGER.debug("Bean injection points are reinitialized '{}'", managedBean); CreationalContextImpl<Object> creationalContext = managedBean.getWebBeansContext().getCreationalContextFactory().getCreationalContext(managedBean); managedBean.getProducer().inject(get, creationalContext); } } catch (Exception e) { LOGGER.error("Error reinitializing bean '{}' in context '{}'", e, contextual, ctx); } } }
creationalContext = webBeansContext.getCreationalContextFactory().getCreationalContext(cdiEjbBean); } else { creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, cdiEjbBean);
@Override public T create(CreationalContext<T> context) { CreationalContextImpl<T> contextImpl; if(!CreationalContextImpl.class.isInstance(context)) { contextImpl = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(context, this); } else { contextImpl = CreationalContextImpl.class.cast(context); } T t; Bean<T> oldBean = contextImpl.putBean(this); try { t = bean.create(contextImpl); } finally { contextImpl.putBean(oldBean); } if (getScope().equals(Dependent.class)) { contextImpl.addDependent(this, t); } return t; }
creationalContext = CreationalContextFactory.getInstance().getCreationalContext(contextual); owbContext.initContextualBag((OwbBean<Object>)this.ejbBean, creationalContext);
creationalContext = webBeansContext.getCreationalContextFactory().getCreationalContext(cdiEjbBean); } else { creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, cdiEjbBean);
@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); }
@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); }
/** * {@inheritDoc} */ @Override public <T> CreationalContextImpl<T> createCreationalContext(Contextual<T> contextual) { if (contextual instanceof SerializableBean) { contextual = ((SerializableBean)contextual).getBean(); } return webBeansContext.getCreationalContextFactory().getCreationalContext(contextual); }
creationalContextImpl = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, instanceBean);
public T create(CreationalContext<T> creationalContext) { if (!(creationalContext instanceof CreationalContextImpl)) { creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, this); } CreationalContextImpl<T> creationalContextImpl = (CreationalContextImpl<T>)creationalContext; Bean<T> oldBean = creationalContextImpl.putBean(this); Contextual<T> oldContextual = creationalContextImpl.putContextual(this); // otherwise BeanMetaData is broken try { return super.create(creationalContext); } finally { creationalContextImpl.putBean(oldBean); creationalContextImpl.putContextual(oldContextual); } }
creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, this);
creationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(creationalContext, bean);
ownerCreationalContext = webBeansContext.getCreationalContextFactory().wrappedCreationalContext(ownerCreationalContext, injectionPoint.getBean());