@Test public void dispose() { ApplicationScopedBean bean = new ApplicationScopedBean(); assertFalse(bean.wasPostConstructCalled()); assertFalse(bean.wasPreDestroyCalled()); assertNull(bean.getDependentBean()); CdiInjector<ApplicationScopedBean> injector = new CdiInjector<ApplicationScopedBean>(); injector.dispose(bean); assertFalse(bean.wasPostConstructCalled()); assertTrue(bean.wasPreDestroyCalled()); assertNull(bean.getDependentBean()); }
public void dispose(T object) { BeanManager beanManager = BeanManagerProvider.getBeanManager(); AnnotatedType<T> annotatedType = beanManager.createAnnotatedType((Class<T>) object.getClass()); InjectionTarget<T> injectionTarget = beanManager.createInjectionTarget(annotatedType); injectionTarget.preDestroy(object); injectionTarget.dispose(object); }
CdiInjector { public void dispose(T object) { BeanManager beanManager = BeanManagerProvider.getBeanManager(); AnnotatedType<T> annotatedType = beanManager.createAnnotatedType((Class<T>) object.getClass()); InjectionTarget<T> injectionTarget = beanManager.createInjectionTarget(annotatedType); injectionTarget.preDestroy(object); injectionTarget.dispose(object); } }
CdiInjector { public void dispose(T object) { BeanManager beanManager = BeanManagerProvider.getBeanManager(); AnnotatedType<T> annotatedType = beanManager.createAnnotatedType((Class<T>) object.getClass()); InjectionTarget<T> injectionTarget = beanManager.createInjectionTarget(annotatedType); injectionTarget.preDestroy(object); injectionTarget.dispose(object); }  }
CdiInjector { public void dispose(T object) { BeanManager beanManager = BeanManagerProvider.getBeanManager(); AnnotatedType<T> annotatedType = beanManager.createAnnotatedType((Class<T>) object.getClass()); InjectionTarget<T> injectionTarget = beanManager.createInjectionTarget(annotatedType); injectionTarget.preDestroy(object); injectionTarget.dispose(object); }  void inject(T object); void dispose(T object); }
CdiInjector { public void dispose(T object) { BeanManager beanManager = BeanManagerProvider.getBeanManager(); AnnotatedType<T> annotatedType = beanManager.createAnnotatedType((Class<T>) object.getClass()); InjectionTarget<T> injectionTarget = beanManager.createInjectionTarget(annotatedType); injectionTarget.preDestroy(object); injectionTarget.dispose(object); }  void inject(T object); void dispose(T object);  }