/** * * @param injectionTarget * @param componentDescription * @param beanManager * @return the processed injection target * @see #isProcessing(ComponentDescription) */ default <T> InjectionTarget<T> processInjectionTarget(WeldInjectionTarget<T> injectionTarget, ComponentDescription componentDescription, WeldManager beanManager) { return beanManager.fireProcessInjectionTarget(injectionTarget.getAnnotatedType(), injectionTarget); }
/** * * @param injectionTarget * @param componentDescription * @param beanManager * @return the processed injection target * @see #isProcessing(ComponentDescription) */ default <T> InjectionTarget<T> processInjectionTarget(WeldInjectionTarget<T> injectionTarget, ComponentDescription componentDescription, WeldManager beanManager) { return beanManager.fireProcessInjectionTarget(injectionTarget.getAnnotatedType(), injectionTarget); }
@SuppressWarnings("unchecked") public static void injectNonContextualInstance(Object instance, WeldManager beanManager) { if (beanManager == null) throw new IllegalArgumentException("Null bean manager."); CreationalContext<Object> creationalContext = beanManager.createCreationalContext(null); InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>) beanManager.fireProcessInjectionTarget(beanManager.createAnnotatedType(instance.getClass())); injectionTarget.inject(instance, creationalContext); } }
public <T> void inject(InjectionContext<T> injectionContext) throws InjectionException { WeldManager weldManager = initWeldManagerIfNecessary(); Object instance = injectionContext.getInjectionTarget(); if (weldManager == null) throw new IllegalArgumentException("Null bean manager."); CreationalContext<Object> creationalContext = weldManager.createCreationalContext(null); InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>) weldManager.fireProcessInjectionTarget(weldManager.createAnnotatedType(instance.getClass())); injectionTarget.inject(instance, creationalContext); injectionContext.proceed(); }
public <T> void inject(InjectionContext<T> injectionContext) throws InjectionException { if (isInterceptor(injectionContext.getInjectionTarget())) { WeldManager weldManager = initWeldManagerIfNecessary(); Object instance = injectionContext.getInjectionTarget(); if (weldManager == null) throw new IllegalArgumentException("Null bean manager."); CreationalContext<Object> creationalContext = weldManager.createCreationalContext(null); InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>) weldManager.fireProcessInjectionTarget(weldManager.createAnnotatedType(instance.getClass())); injectionTarget.inject(instance, creationalContext); } injectionContext.proceed(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public <T> JCDIInjectionContext<T> createManagedObject(Class<T> managedClass, BundleDescriptor bundle, boolean invokePostConstruct) { Object managedObject = null; BundleDescriptor topLevelBundleDesc = (BundleDescriptor) bundle.getModuleDescriptor().getDescriptor(); // First get BeanDeploymentArchive for this ejb BeanDeploymentArchive bda = weldDeployer.getBeanDeploymentArchiveForBundle(topLevelBundleDesc); WeldBootstrap bootstrap = weldDeployer.getBootstrapForApp(bundle.getApplication()); BeanManager beanManager = bootstrap.getManager(bda); AnnotatedType annotatedType = beanManager.createAnnotatedType(managedClass); if (!invokePostConstruct) { annotatedType = new NoPostConstructPreDestroyAnnotatedType(annotatedType); } InjectionTarget it = ((BeanDeploymentArchiveImpl)bda).getInjectionTarget(annotatedType); if (it == null) { it = ( ( WeldManager ) beanManager ).fireProcessInjectionTarget( annotatedType ); } CreationalContext cc = beanManager.createCreationalContext(null); managedObject = it.produce(cc); it.inject(managedObject, cc); if( invokePostConstruct ) { it.postConstruct(managedObject); } return new JCDIInjectionContextImpl(it, cc, managedObject); }