Collection < BindingStrategy > collectFromAggregates ( Collection < Class < ? extends AggregateRoot > > aggregateClasses ) { Collection < BindingStrategy > bindingStrategies = new ArrayList <> ( ) ; Map < Type [ ] , Key < ? > > allGenerics = new HashMap <> ( ) ; for ( Class < ? extends AggregateRoot < ? > > aggregateClass : BusinessUtils . includeSuperClasses ( aggregateClasses ) ) { Type [ ] generics = getTypes ( aggregateClass ) ; TypeLiteral < ? > genericInterface = TypeLiteral . get ( newParameterizedType ( Repository . class , generics ) ) ; allGenerics . put ( generics , resolveDefaultQualifier ( bindings , application . getConfiguration ( aggregateClass ) , DEFAULT_REPOSITORY_KEY , aggregateClass , genericInterface ) . orElse ( null ) ) ; } // Create a binding strategy for each default repository implementation for ( Class < ? extends Repository > defaultRepoImpl : defaultRepositoryImplementations ) { bindingStrategies . add ( new GenericBindingStrategy <> ( Repository . class , defaultRepoImpl , allGenerics ) ) ; } return bindingStrategies ; }
Prepares the binding strategies which bind default repositories . The specificity here is that it could have multiple implementations of default repository i . e . one per persistence .