private static Class < ? extends ObjectFactory > getFactoryClass ( Class < ? > factoryClass ) { if ( factoryPackages . size ( ) == 0 ) throw new IllegalArgumentException ( "No package provide to look for factories." ) ; if ( factoryClasses == null ) { factoryClasses = new HashMap < Class < ? > , Class < ? extends ObjectFactory > > ( ) ; Set < Class < ? extends ObjectFactory > > classes = ReflectionUtils . getSubclassesOf ( ObjectFactory . class , factoryPackages ) ; for ( Class < ? extends ObjectFactory > clazz : classes ) { if ( ! Modifier . isAbstract ( clazz . getModifiers ( ) ) ) { try { Constructor constructor = clazz . getConstructor ( ) ; ObjectFactory factory = ( ObjectFactory ) constructor . newInstance ( ) ; factoryClasses . put ( factory . getFactoryClass ( ) , factory . getClass ( ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; //should not happen, compiler forces factory classes to implement correct constructor. } } } } return factoryClasses . get ( factoryClass ) ; }
Get the class of the Factory for the given factoryClass .