/** * Will re-inject any managed beans in the target. Will not call any other life-cycle methods * * @param ctx * @param managedBean */ public static void reinitialize(Context ctx, Contextual<Object> contextual) { try { ManagedBean<Object> managedBean = ManagedBean.class.cast(contextual); LOGGER.debug("Re-Initializing........ {},: {}", managedBean, ctx); Object get = ctx.get(managedBean); if (get != null) { LOGGER.debug("Bean injection points are reinitialized '{}'", managedBean); managedBean.getProducer().inject(get, managedBean.getBeanManager().createCreationalContext(managedBean)); } } catch (Exception e) { LOGGER.error("Error reinitializing bean {},: {}", e, contextual, ctx); } } }
/** * Creates an instance of the bean * * @return The instance */ @Override public T create(CreationalContext<T> creationalContext) { T instance = getProducer().produce(creationalContext); getProducer().inject(instance, creationalContext); if (!hasPostConstructCallback || beanManager.isContextActive(RequestScoped.class)) { getProducer().postConstruct(instance); } else { /* * CDI-219 * The request scope is active during @PostConstruct callback of any bean. */ RequestContext context = getUnboundRequestContext(); try { context.activate(); beanManager.fireRequestContextInitialized(getId()); getProducer().postConstruct(instance); } finally { context.invalidate(); context.deactivate(); beanManager.fireRequestContextDestroyed(getId()); } } return instance; }
/** * Creates an instance of the bean * * @return The instance */ @Override public T create(CreationalContext<T> creationalContext) { T instance = getProducer().produce(creationalContext); getProducer().inject(instance, creationalContext); if (!hasPostConstructCallback || beanManager.isContextActive(RequestScoped.class)) { getProducer().postConstruct(instance); } else { /* * CDI-219 * The request scope is active during @PostConstruct callback of any bean. */ RequestContext context = getUnboundRequestContext(); try { context.activate(); beanManager.fireRequestContextInitialized(getId()); getProducer().postConstruct(instance); } finally { beanManager.fireRequestContextBeforeDestroyed(getId()); context.invalidate(); context.deactivate(); beanManager.fireRequestContextDestroyed(getId()); } } return instance; }
/** * Creates an instance of the bean * * @return The instance */ @Override public T create(CreationalContext<T> creationalContext) { T instance = getProducer().produce(creationalContext); getProducer().inject(instance, creationalContext); if (!hasPostConstructCallback || beanManager.isContextActive(RequestScoped.class)) { getProducer().postConstruct(instance); } else { /* * CDI-219 * The request scope is active during @PostConstruct callback of any bean. */ RequestContext context = getUnboundRequestContext(); try { context.activate(); beanManager.fireRequestContextInitialized(getId()); getProducer().postConstruct(instance); } finally { beanManager.fireRequestContextBeforeDestroyed(getId()); context.invalidate(); context.deactivate(); beanManager.fireRequestContextDestroyed(getId()); } } return instance; }
/** * Creates an instance of the bean * * @return The instance */ @Override public T create(CreationalContext<T> creationalContext) { T instance = getProducer().produce(creationalContext); getProducer().inject(instance, creationalContext); if (!hasPostConstructCallback || beanManager.isContextActive(RequestScoped.class)) { getProducer().postConstruct(instance); } else { /* * CDI-219 * The request scope is active during @PostConstruct callback of any bean. */ RequestContext context = getUnboundRequestContext(); try { context.activate(); beanManager.fireRequestContextInitialized(getId()); getProducer().postConstruct(instance); } finally { beanManager.fireRequestContextBeforeDestroyed(getId()); context.invalidate(); context.deactivate(); beanManager.fireRequestContextDestroyed(getId()); } } return instance; }
/** * Creates an instance of the bean * * @return The instance */ @Override public T create(CreationalContext<T> creationalContext) { T instance = getProducer().produce(creationalContext); getProducer().inject(instance, creationalContext); if (!hasPostConstructCallback || beanManager.isContextActive(RequestScoped.class)) { getProducer().postConstruct(instance); } else { /* * CDI-219 * The request scope is active during @PostConstruct callback of any bean. */ RequestContext context = getUnboundRequestContext(); try { context.activate(); beanManager.fireRequestContextInitialized(getId()); getProducer().postConstruct(instance); } finally { beanManager.fireRequestContextBeforeDestroyed(getId()); context.invalidate(); context.deactivate(); beanManager.fireRequestContextDestroyed(getId()); } } return instance; }
/** * Creates an instance of the bean * * @return The instance */ @Override public T create(CreationalContext<T> creationalContext) { T instance = getProducer().produce(creationalContext); getProducer().inject(instance, creationalContext); if (!hasPostConstructCallback || beanManager.isContextActive(RequestScoped.class)) { getProducer().postConstruct(instance); } else { /* * CDI-219 * The request scope is active during @PostConstruct callback of any bean. */ RequestContext context = getUnboundRequestContext(); try { context.activate(); beanManager.fireRequestContextInitialized(getId()); getProducer().postConstruct(instance); } finally { beanManager.fireRequestContextBeforeDestroyed(getId()); context.invalidate(); context.deactivate(); beanManager.fireRequestContextDestroyed(getId()); } } return instance; }
if (contextual instanceof ManagedBean<?> && !isInterceptorOrDecorator(contextual)) { ManagedBean<?> managedBean = (ManagedBean<?>) contextual; if (managedBean.getProducer() instanceof BasicInjectionTarget<?>) { BasicInjectionTarget<?> injectionTarget = (BasicInjectionTarget<?>) managedBean.getProducer(); if (!injectionTarget.getLifecycleCallbackInvoker().hasPreDestroyMethods() && !injectionTarget.hasInterceptors()) {
if (contextual instanceof ManagedBean<?> && !isInterceptorOrDecorator(contextual)) { ManagedBean<?> managedBean = (ManagedBean<?>) contextual; if (managedBean.getProducer() instanceof BasicInjectionTarget<?>) { BasicInjectionTarget<?> injectionTarget = (BasicInjectionTarget<?>) managedBean.getProducer(); if (!injectionTarget.getLifecycleCallbackInvoker().hasPreDestroyMethods() && !injectionTarget.hasInterceptors()) {
if (contextual instanceof ManagedBean<?> && !isInterceptorOrDecorator(contextual)) { ManagedBean<?> managedBean = (ManagedBean<?>) contextual; if (managedBean.getProducer() instanceof BasicInjectionTarget<?>) { BasicInjectionTarget<?> injectionTarget = (BasicInjectionTarget<?>) managedBean.getProducer(); if (!injectionTarget.getLifecycleCallbackInvoker().hasPreDestroyMethods() && !injectionTarget.hasInterceptors()) {
if (contextual instanceof ManagedBean<?> && !isInterceptorOrDecorator(contextual)) { ManagedBean<?> managedBean = (ManagedBean<?>) contextual; if (managedBean.getProducer() instanceof BasicInjectionTarget<?>) { BasicInjectionTarget<?> injectionTarget = (BasicInjectionTarget<?>) managedBean.getProducer(); if (!injectionTarget.getLifecycleCallbackInvoker().hasPreDestroyMethods() && !injectionTarget.hasInterceptors()) {
/** * Destroys an instance of the bean * * @param instance The instance */ @Override public void destroy(T instance, CreationalContext<T> creationalContext) { super.destroy(instance, creationalContext); try { getProducer().preDestroy(instance); // WELD-1010 hack? if (creationalContext instanceof CreationalContextImpl) { ((CreationalContextImpl<T>) creationalContext).release(this, instance); } else { creationalContext.release(); } } catch (Exception e) { BeanLogger.LOG.errorDestroying(instance, this); BeanLogger.LOG.catchingDebug(e); } }
if (contextual instanceof ManagedBean<?> && !isInterceptorOrDecorator(contextual)) { ManagedBean<?> managedBean = (ManagedBean<?>) contextual; if (managedBean.getProducer() instanceof BasicInjectionTarget<?>) { BasicInjectionTarget<?> injectionTarget = (BasicInjectionTarget<?>) managedBean.getProducer(); if (!injectionTarget.getLifecycleCallbackInvoker().hasPreDestroyMethods() && !injectionTarget.hasInterceptors()) {
if (contextual instanceof ManagedBean<?> && !isInterceptorOrDecorator(contextual)) { ManagedBean<?> managedBean = (ManagedBean<?>) contextual; if (managedBean.getProducer() instanceof BasicInjectionTarget<?>) { BasicInjectionTarget<?> injectionTarget = (BasicInjectionTarget<?>) managedBean.getProducer(); if (!injectionTarget.getLifecycleCallbackInvoker().hasPreDestroyMethods() && !injectionTarget.hasInterceptors()) {
/** * Destroys an instance of the bean * * @param instance The instance */ @Override public void destroy(T instance, CreationalContext<T> creationalContext) { super.destroy(instance, creationalContext); try { getProducer().preDestroy(instance); // WELD-1010 hack? if (creationalContext instanceof CreationalContextImpl) { ((CreationalContextImpl<T>) creationalContext).release(this, instance); } else { creationalContext.release(); } } catch (Exception e) { BeanLogger.LOG.errorDestroying(instance, this); BeanLogger.LOG.catchingDebug(e); } }
/** * Destroys an instance of the bean * * @param instance The instance */ @Override public void destroy(T instance, CreationalContext<T> creationalContext) { super.destroy(instance, creationalContext); try { getProducer().preDestroy(instance); // WELD-1010 hack? if (creationalContext instanceof CreationalContextImpl) { ((CreationalContextImpl<T>) creationalContext).release(this, instance); } else { creationalContext.release(); } } catch (Exception e) { BeanLogger.LOG.errorDestroying(instance, this); BeanLogger.LOG.catchingDebug(e); } }
/** * Destroys an instance of the bean * * @param instance The instance */ @Override public void destroy(T instance, CreationalContext<T> creationalContext) { super.destroy(instance, creationalContext); try { getProducer().preDestroy(instance); // WELD-1010 hack? if (creationalContext instanceof CreationalContextImpl) { ((CreationalContextImpl<T>) creationalContext).release(this, instance); } else { creationalContext.release(); } } catch (Exception e) { BeanLogger.LOG.errorDestroying(instance, this); BeanLogger.LOG.catchingDebug(e); } }
/** * Destroys an instance of the bean * * @param instance The instance */ @Override public void destroy(T instance, CreationalContext<T> creationalContext) { super.destroy(instance, creationalContext); try { getProducer().preDestroy(instance); // WELD-1010 hack? if (creationalContext instanceof CreationalContextImpl) { ((CreationalContextImpl<T>) creationalContext).release(this, instance); } else { creationalContext.release(); } } catch (Exception e) { BeanLogger.LOG.errorDestroying(instance, this); BeanLogger.LOG.catchingDebug(e); } }
/** * Destroys an instance of the bean * * @param instance The instance */ @Override public void destroy(T instance, CreationalContext<T> creationalContext) { super.destroy(instance, creationalContext); try { getProducer().preDestroy(instance); // WELD-1010 hack? if (creationalContext instanceof CreationalContextImpl) { ((CreationalContextImpl<T>) creationalContext).release(this, instance); } else { creationalContext.release(); } } catch (Exception e) { BeanLogger.LOG.errorDestroying(instance, this); BeanLogger.LOG.catchingDebug(e); } }