@Override public void destroy(Contextual<?> contextual) { ((AlterableContext) context).destroy(sbv.getSerializableBean(contextual)); } }
@Override public void destroy(Contextual<?> contextual) { contextual = store.getSerializableContextual(contextual); delegate().destroy(contextual); } }
@Override public void destroy(Contextual<?> contextual) { contextual = store.getSerializableContextual(contextual); delegate().destroy(contextual); } }
@Override public void destroy(Contextual<?> contextual) { contextual = store.getSerializableContextual(contextual); delegate().destroy(contextual); } }
@Override public void destroy(Contextual<?> contextual) { contextual = store.getSerializableContextual(contextual); delegate().destroy(contextual); } }
@Override public void destroy(Contextual<?> contextual) { contextual = store.getSerializableContextual(contextual); delegate().destroy(contextual); } }
@Override public void destroy(Contextual<?> contextual) { contextual = store.getSerializableContextual(contextual); delegate().destroy(contextual); } }
@Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertion(section = CONTEXT, id = "t") public void testNothingHappensIfNoInstanceToDestroy(ApplicationScopedComponent application) { Bean<?> bean = getUniqueBean(ApplicationScopedComponent.class); AlterableContext context = (AlterableContext) getCurrentManager().getContext(bean.getScope()); AbstractComponent.reset(); application.setValue("value"); context.destroy(bean); assertTrue(AbstractComponent.isDestroyed()); context.destroy(bean); // make sure subsequent calls do not raise exception context.destroy(bean); }
/** * TODO add assertion - OPEN ISSUE atm * * @param application */ @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) public void testNothingHappensIfNoInstanceToDestroy( ApplicationScopedComponent application) { Bean<?> bean = getUniqueBean(ApplicationScopedComponent.class); AlterableContext context = (AlterableContext) getCurrentManager() .getContext(bean.getScope()); AbstractComponent.reset(); application.setValue("value"); context.destroy(bean); assertTrue(AbstractComponent.isDestroyed()); context.destroy(bean); // Make sure subsequent calls do not raise exception context.destroy(bean); }
alterableContext.destroy(bean);
/** * @see Beans#destroy(Bean) */ public static <T> void destroy(BeanManager beanManager, Bean<T> bean) { Context context = beanManager.getContext(bean.getScope()); if (context instanceof AlterableContext) { ((AlterableContext) context).destroy(bean); } else { T instance = context.get(bean); if (instance != null) { destroy(beanManager, bean, instance); } } }
/** * @see Beans#destroy(Bean) */ public static <T> void destroy(BeanManager beanManager, Bean<T> bean) { Context context = beanManager.getContext(bean.getScope()); if (context instanceof AlterableContext) { ((AlterableContext) context).destroy(bean); } else { T instance = context.get(bean); if (instance != null) { destroy(beanManager, bean, instance); } } }
private <T extends AbstractComponent> void testComponent(Class<T> javaClass) { Bean<?> bean = getUniqueBean(javaClass); @SuppressWarnings("unchecked") T reference = (T) getCurrentManager().getReference(bean, javaClass, getCurrentManager().createCreationalContext(bean)); AlterableContext context = (AlterableContext) getCurrentManager().getContext(bean.getScope()); for (String string : VALUES) { assertNull(reference.getValue()); reference.setValue(string); assertEquals(reference.getValue(), string); AbstractComponent.reset(); context.destroy(bean); assertTrue(AbstractComponent.isDestroyed()); assertNull(reference.getValue(), reference.getValue()); } } }
@Override public void destroy(T instance) { Preconditions.checkNotNull(instance); // Attempt to destroy instance which is either a client proxy or a dependent session bean proxy if (instance instanceof ProxyObject) { ProxyObject proxy = (ProxyObject) instance; if (proxy.getHandler() instanceof ProxyMethodHandler) { ProxyMethodHandler handler = (ProxyMethodHandler) proxy.getHandler(); Bean<?> bean = handler.getBean(); if (instance instanceof EnterpriseBeanInstance && Dependent.class.equals(bean.getScope())) { // Destroy internal reference to a dependent session bean destroyDependentInstance(instance); return; } else { // Destroy contextual instance of a normal-scoped bean Context context = getBeanManager().getContext(bean.getScope()); if (context instanceof AlterableContext) { AlterableContext alterableContext = (AlterableContext) context; alterableContext.destroy(bean); return; } else { throw BeanLogger.LOG.destroyUnsupported(context); } } } } // Attempt to destroy dependent instance which is neither a client proxy nor a dependent session bean proxy destroyDependentInstance(instance); }
@Override public void destroy(T instance) { checkNotNull(instance); // Attempt to destroy instance which is either a client proxy or a dependent session bean proxy if (instance instanceof ProxyObject) { ProxyObject proxy = (ProxyObject) instance; if (proxy.weld_getHandler() instanceof ProxyMethodHandler) { ProxyMethodHandler handler = (ProxyMethodHandler) proxy.weld_getHandler(); Bean<?> bean = handler.getBean(); if (isSessionBeanProxy(instance) && Dependent.class.equals(bean.getScope())) { // Destroy internal reference to a dependent session bean destroyDependentInstance(instance); return; } else { // Destroy contextual instance of a normal-scoped bean Context context = getBeanManager().getContext(bean.getScope()); if (context instanceof AlterableContext) { AlterableContext alterableContext = (AlterableContext) context; alterableContext.destroy(bean); return; } else { throw BeanLogger.LOG.destroyUnsupported(context); } } } } // Attempt to destroy dependent instance which is neither a client proxy nor a dependent session bean proxy destroyDependentInstance(instance); }
@Override public void destroy(T instance) { checkNotNull(instance); // Attempt to destroy instance which is either a client proxy or a dependent session bean proxy if (instance instanceof ProxyObject) { ProxyObject proxy = (ProxyObject) instance; if (proxy.weld_getHandler() instanceof ProxyMethodHandler) { ProxyMethodHandler handler = (ProxyMethodHandler) proxy.weld_getHandler(); Bean<?> bean = handler.getBean(); if (isSessionBeanProxy(instance) && Dependent.class.equals(bean.getScope())) { // Destroy internal reference to a dependent session bean destroyDependentInstance(instance); return; } else { // Destroy contextual instance of a normal-scoped bean Context context = getBeanManager().getContext(bean.getScope()); if (context instanceof AlterableContext) { AlterableContext alterableContext = (AlterableContext) context; alterableContext.destroy(bean); return; } else { throw BeanLogger.LOG.destroyUnsupported(context); } } } } // Attempt to destroy dependent instance which is neither a client proxy nor a dependent session bean proxy destroyDependentInstance(instance); }
@Override public void destroy(T instance) { checkNotNull(instance); // Attempt to destroy instance which is either a client proxy or a dependent session bean proxy if (instance instanceof ProxyObject) { ProxyObject proxy = (ProxyObject) instance; if (proxy.weld_getHandler() instanceof ProxyMethodHandler) { ProxyMethodHandler handler = (ProxyMethodHandler) proxy.weld_getHandler(); Bean<?> bean = handler.getBean(); if (isSessionBeanProxy(instance) && Dependent.class.equals(bean.getScope())) { // Destroy internal reference to a dependent session bean destroyDependentInstance(instance); return; } else { // Destroy contextual instance of a normal-scoped bean Context context = getBeanManager().getContext(bean.getScope()); if (context instanceof AlterableContext) { AlterableContext alterableContext = (AlterableContext) context; alterableContext.destroy(bean); return; } else { throw BeanLogger.LOG.destroyUnsupported(context); } } } } // Attempt to destroy dependent instance which is neither a client proxy nor a dependent session bean proxy destroyDependentInstance(instance); }
@Override public void destroy(T instance) { checkNotNull(instance); // Attempt to destroy instance which is either a client proxy or a dependent session bean proxy if (instance instanceof ProxyObject) { ProxyObject proxy = (ProxyObject) instance; if (proxy.weld_getHandler() instanceof ProxyMethodHandler) { ProxyMethodHandler handler = (ProxyMethodHandler) proxy.weld_getHandler(); Bean<?> bean = handler.getBean(); if (isSessionBeanProxy(instance) && Dependent.class.equals(bean.getScope())) { // Destroy internal reference to a dependent session bean destroyDependentInstance(instance); return; } else { // Destroy contextual instance of a normal-scoped bean Context context = getBeanManager().getContext(bean.getScope()); if (context instanceof AlterableContext) { AlterableContext alterableContext = (AlterableContext) context; alterableContext.destroy(bean); return; } else { throw BeanLogger.LOG.destroyUnsupported(context); } } } } // Attempt to destroy dependent instance which is neither a client proxy nor a dependent session bean proxy destroyDependentInstance(instance); }
@Override public void destroy(T instance) { checkNotNull(instance); // Attempt to destroy instance which is either a client proxy or a dependent session bean proxy if (instance instanceof ProxyObject) { ProxyObject proxy = (ProxyObject) instance; if (proxy.weld_getHandler() instanceof ProxyMethodHandler) { ProxyMethodHandler handler = (ProxyMethodHandler) proxy.weld_getHandler(); Bean<?> bean = handler.getBean(); if (isSessionBeanProxy(instance) && Dependent.class.equals(bean.getScope())) { // Destroy internal reference to a dependent session bean destroyDependentInstance(instance); return; } else { // Destroy contextual instance of a normal-scoped bean Context context = getBeanManager().getContext(bean.getScope()); if (context instanceof AlterableContext) { AlterableContext alterableContext = (AlterableContext) context; alterableContext.destroy(bean); return; } else { throw BeanLogger.LOG.destroyUnsupported(context); } } } } // Attempt to destroy dependent instance which is neither a client proxy nor a dependent session bean proxy destroyDependentInstance(instance); }