/** * 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; }
this.injectionManager.inject(object);
@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; }
@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; } }