private static JoseFactory loadSpi ( ClassLoader cl ) { if ( cl == null ) { return null ; } // start from the root CL and go back down to the TCCL JoseFactory instance = loadSpi ( cl . getParent ( ) ) ; if ( instance == null ) { ServiceLoader < JoseFactory > sl = ServiceLoader . load ( JoseFactory . class , cl ) ; URL u = cl . getResource ( "/META-INF/services/org.wildfly.swarm.jose.provider.JoseFactory" ) ; log . debugf ( "loadSpi, cl=%s, u=%s, sl=%s" , cl , u , sl ) ; try { for ( Object spi : sl ) { if ( spi instanceof JoseFactory ) { if ( instance != null ) { log . warn ( "Multiple JoseFactory implementations found: " + spi . getClass ( ) . getName ( ) + " and " + instance . getClass ( ) . getName ( ) ) ; break ; } else { log . debugf ( "sl=%s, loaded=%s" , sl , spi ) ; instance = ( JoseFactory ) spi ; } } } } catch ( Throwable e ) { log . warn ( "Failed to locate JoseFactory provider" , e ) ; } } return instance ; }
Look for a JoseFactory service implementation using the ServiceLoader .