/** * Do not call, for BeanContainer. * @throws IllegalAccessException * @throws InstantiationException */ public Object createInterceptor(Class<?> interceptorClass) throws InstantiationException, IllegalAccessException { Object instance = interceptorClass.newInstance(); // TODO: This needs to be removed once we have all the RPs functioning // and the InjectionManager will solely be responsible for injection InterceptorInjector interceptorInjector = interceptorInjectors.get(interceptorClass); assert interceptorInjector != null : "interceptorInjector not found for " + interceptorClass; interceptorInjector.inject(null, instance); // inject into the interceptor instance using InjectionManager. // the injection manager in a real environment should never // be null. But there are various legacy unit tests which // start up a container in various different ways and it's // a real big task to set a mock injection manager in all those places if (this.injectionManager != null) { this.injectionManager.inject(instance); } return instance; }
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(); }
injectionManager.addInjector(eeInjector);
injectionManager.addInjector(eeInjector); injectionManager.addInjector(lazyEEInjector);
@Override public ManagedBeanInstance<T> createManagedBeanInstance() throws Exception { T instance = this.createInstance(this.managedBeanClass); Collection<Object> interceptorInstances = this.createInterceptors(); // inject the MB instance this.injectionManager.inject(instance); // inject the interceptor instances for (Object interceptorInstance : interceptorInstances) { this.injectionManager.inject(interceptorInstance); } ManagedBeanInstance<T> mbInstance = new ManagedBeanInstanceImpl<T>(instance, interceptorInstances); // invoke post-construct this.handlePostConstruct(mbInstance); return mbInstance; }
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(); }
builder.addUninstall("release"); kernelController.install(builder.getBeanMetaData(), injector); deployment.addInjector(injector);
this.injectionManager.inject(object);
injectionManager.addInjector(eeInjector);
@Override public Object invokeTarget() throws Throwable { // TODO: Once InjectionManager is fully integrated, // this should be removed. Injection should happen solely via InjectionManager.inject if (invocationContext != null) { invocationContext.proceed(); } // additional null safety check till InjectionManager is completely integrated if (this.injectionManager != null) { this.injectionManager.inject(ctx.getInstance()); } // now inject the interceptor instances this.ctx.initialiseInterceptorInstances(); // injection invocation doesn't have anything to return return null; } }