public void release() { context.release(); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void doReinjectBeanInstance(BeanManagerImpl beanManager, AbstractClassBean bean, Context context) { Object instance = context.get(bean); if (instance != null) { doCallInject(beanManager, bean, instance); } }
@Override public void destroy(T instance, CreationalContext<T> creationalContext) { creationalContext.release(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void doReinjectBeanInstance(BeanManagerImpl beanManager, InjectionTargetBean bean, Context context) { Object instance = context.get(bean); if (instance != null) { bean.getProducer().inject(instance, beanManager.createCreationalContext(bean)); LOGGER.info("Bean '{}' injection points was reinjected.", bean.getBeanClass().getName()); } }
@Override public void release() { context.release(); }
/** * 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); } } }
@Override public void release() { try { injectionTarget.preDestroy(instance); } finally { ctx.release(); } }
@Override public void stop(final StopContext context) { beanManager = null; synchronized (contexts) { for (Holder holder : contexts.values()) { // Only release the context for @Dependent beans, Weld should take care of the other scopes if (holder.isDependent()) { holder.context.release(); } } contexts.clear(); } }
@Override public void release() { if ( beanInstance == null ) { return; } try { if ( bean == null ) { // todo : BeanInstanceProducer#release? return; } bean.destroy( beanInstance, creationalContext ); } catch (Exception ignore) { } finally { if ( creationalContext != null ) { try { creationalContext.release(); } catch (Exception ignore) { } } this.beanInstance = null; this.creationalContext = null; this.bean = null; this.beanManager = null; } }
public void destroy(T instance, CreationalContext<T> creationalContext) { if (LOGGER.isDebugEnabled()) { LOGGER.debug(String.format("Destroying bean instance %s for repository type '%s'.", instance.toString(), beanClass.getName())); } creationalContext.release(); }
@Override public void destroy(Supplier<T> instance, CreationalContext<Supplier<T>> context) { injectionTarget.preDestroy(instance); injectionTarget.dispose(instance); context.release(); }
@Override public void destroy(T instance, CreationalContext<T> context) { injectionTarget.preDestroy(instance); injectionTarget.dispose(instance); context.release(); }
@Override public void destroy(CdiRequestScope instance, CreationalContext<CdiRequestScope> context) { injectionTarget.preDestroy(instance); injectionTarget.dispose(instance); context.release(); }
@Override public void destroy(ValidationInterceptor instance, CreationalContext<ValidationInterceptor> ctx) { interceptorTarget.preDestroy(instance); interceptorTarget.dispose(instance); ctx.release(); } });
@Override public void destroy(CdiExternalRequestScope instance, CreationalContext<CdiExternalRequestScope> ctx) { interceptorTarget.preDestroy(instance); interceptorTarget.dispose(instance); ctx.release(); } });
/** * Dispose of the instance, doing any necessary cleanup * * @throws IllegalStateException if dispose() is called before produce() is called * @throws IllegalStateException if dispose() is called on an instance that has already been disposed * @return self */ public UnmanagedInstance<T> dispose() { if (instance == null) { throw new IllegalStateException("Trying to call dispose() before produce() was called"); } if (disposed) { throw new IllegalStateException("Trying to call dispose() on already disposed instance"); } disposed = true; injectionTarget.dispose(instance); ctx.release(); return this; }
@Override public void release() { if ( beanInstance == null ) { return; } try { if ( injectionTarget == null ) { // todo : BeanInstanceProducer#release? return; } injectionTarget.preDestroy( beanInstance ); injectionTarget.dispose( beanInstance ); this.creationalContext.release(); } catch (Exception ignore) { } finally { this.beanInstance = null; this.creationalContext = null; this.injectionTarget = null; } } }
@Override public void destroy(final Object instance) { final Holder holder = contexts.remove(instance); if (holder == null) { // This bean was not created via CDI, we need to invoke the JBeret cleanup super.destroy(instance); } else { // Only release the context for @Dependent beans, Weld should take care of the other scopes if (holder.isDependent()) { // We're not destroying the bean here because weld should handle that for use when we release the // CreationalContext holder.context.release(); } } }
this.creationalContext.release();
@Override public Object processInvocation(final InterceptorContext context) throws Exception { final ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class); final InterceptorInstances interceptorInstances = interceptorSupport.getInterceptorInstances(componentInstance); final InterceptorBindings interceptorBindings = interceptorBindingsSupplier.get(); switch (interceptionType) { case AROUND_INVOKE: return doMethodInterception(context.getInvocationContext(), InterceptionType.AROUND_INVOKE, interceptorInstances, interceptorBindings); case AROUND_TIMEOUT: return doMethodInterception(context.getInvocationContext(), InterceptionType.AROUND_TIMEOUT, interceptorInstances, interceptorBindings); case PRE_DESTROY: try { return doLifecycleInterception(context, interceptorInstances, interceptorBindings); } finally { interceptorInstances.getCreationalContext().release(); } case POST_CONSTRUCT: return doLifecycleInterception(context, interceptorInstances, interceptorBindings); case AROUND_CONSTRUCT: return doLifecycleInterception(context, interceptorInstances, interceptorBindings); default: //should never happen return context.proceed(); } }