public static Module loadModulesFromProperties ( final Module jFunkModule , final String propertiesFile ) throws ClassNotFoundException , InstantiationException , IllegalAccessException , IOException { final List < Module > modules = Lists . newArrayList ( ) ; LOG . debug ( "Using jfunk.props.file=" + propertiesFile ) ; Properties props = loadProperties ( propertiesFile ) ; for ( final Enumeration < ? > en = props . propertyNames ( ) ; en . hasMoreElements ( ) ; ) { String name = ( String ) en . nextElement ( ) ; if ( name . startsWith ( "module." ) ) { String className = props . getProperty ( name ) ; LOG . info ( "Loading " + name + "=" + className ) ; Class < ? extends Module > moduleClass = Class . forName ( className ) . asSubclass ( Module . class ) ; Module module = moduleClass . newInstance ( ) ; modules . add ( module ) ; } } return Modules . override ( jFunkModule ) . with ( modules ) ; }
Loads Guice modules whose class names are specified as properties . All properties starting with module . are considered to have a fully qualified class name representing a Guice module . The modules are combined and override thespecified jFunkModule .