public void findModules ( ) { ServiceLoader < ClientModuleFactory > loader = ServiceLoader . load ( ClientModuleFactory . class ) ; Iterator < ClientModuleFactory > iterator = loader . iterator ( ) ; while ( iterator . hasNext ( ) ) { ClientModuleFactory factory = iterator . next ( ) ; Module module = factory . create ( ) ; addModule ( module ) ; } objectMapper . findAndRegisterModules ( ) ; }
Finds and registers modules on the classpath trough the use of java . util . ServiceLoader . Each module can register itself for lookup by registering a ClientModuleFactory .