public void eagerlyInject ( Object target , Field field ) { /** * We only ever inject fields marked with the correct annotation. */ if ( field . getAnnotation ( Autowired . class ) != null ) { field . setAccessible ( true ) ; Autowired autowired = field . getAnnotation ( Autowired . class ) ; /** * If the field isn't marked for lazy injection, go ahead and inject * it immediately. Otherwise, nullify it with a local "null" * reference of the field's required type. */ if ( autowired . lazy ( ) == false ) { inject ( target , field ) ; } else { nullify ( target , field ) ; } } }
Eagerly injects the target object s target field . Note that if the field is marked for lazy injection we still inject it but with a null reference . This reference is never seen by user code and is used internally by Iroh to detect when eager injection has delegated the injection process to lazy injection thus preventing multiple injection .