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