Destroy the existing contextual instance. If there is no existing instance, no action is taken.
302303304305306307308309310311312
Class<? extends Annotation> beanScope = bean.getScope(); Context currentContext = webBeansContext.getBeanManagerImpl().getContext(beanScope); if (currentContext instanceof AlterableContext) { AlterableContext alterableContext = (AlterableContext)currentContext; alterableContext.destroy(bean); } else { throw new UnsupportedOperationException("Not AlterableContext so you can't call destroy youself"); }
7879808182838485868788
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); }
8182838485868788899091
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); } private <T extends AbstractComponent> void testComponent(Class<T> javaClass) { Bean<?> bean = getUniqueBean(javaClass);
8283848586878889909192
application.setValue("value"); context.destroy(bean); assertTrue(AbstractComponent.isDestroyed()); context.destroy(bean); // make sure subsequent calls do not raise exception context.destroy(bean); } private <T extends AbstractComponent> void testComponent(Class<T> javaClass) { Bean<?> bean = getUniqueBean(javaClass); @SuppressWarnings("unchecked")
979899100101102103104105106107
assertNull(reference.getValue()); reference.setValue(string); assertEquals(reference.getValue(), string); AbstractComponent.reset(); context.destroy(bean); assertTrue(AbstractComponent.isDestroyed()); assertNull(reference.getValue(), reference.getValue()); } } }