private static void addDependencyFactoryToContainer ( Object dependencyFactory ) { try { Class clazz = dependencyFactory . getClass ( ) ; for ( Field field : ReflectionHelper . getFields ( clazz ) ) { if ( field . isAnnotationPresent ( Dependency . class ) ) { qualifiers . clear ( ) ; for ( Annotation annotation : field . getAnnotations ( ) ) { if ( annotation . annotationType ( ) . isAnnotationPresent ( Qualifier . class ) ) { qualifiers . add ( annotation . annotationType ( ) . getCanonicalName ( ) ) ; } } dependencyContainer . add ( DependencyIdentifier . getDependencyIdentifierForClass ( field , qualifiers ) , new DependencySource ( DependencySource . DependencySourceType . FIELD , field , null , dependencyFactory , field . isAnnotationPresent ( Singleton . class ) ) ) ; } } for ( Method method : clazz . getMethods ( ) ) { if ( method . isAnnotationPresent ( Dependency . class ) ) { qualifiers . clear ( ) ; for ( Annotation annotation : method . getAnnotations ( ) ) { if ( annotation . annotationType ( ) . isAnnotationPresent ( Qualifier . class ) ) { qualifiers . add ( annotation . annotationType ( ) . getCanonicalName ( ) ) ; } } dependencyContainer . add ( DependencyIdentifier . getDependencyIdentifierForClass ( method , qualifiers ) , new DependencySource ( DependencySource . DependencySourceType . METHOD , null , method , dependencyFactory , method . isAnnotationPresent ( Singleton . class ) ) ) ; } } } catch ( Exception e ) { throw new AvicennaRuntimeException ( e ) ; } }
Internal method which iterates over fields and methods to find and store dependency producers .