private static List < String > loadServicesImplementations ( final Class < ? > ofClass ) { List < String > result = new ArrayList < String > ( ) ; // Allow a sysprop to specify the first candidate String override = System . getProperty ( ofClass . getName ( ) ) ; if ( override != null ) { result . add ( override ) ; } ClassLoader loader = ServiceLib . class . getClassLoader ( ) ; URL url = loader . getResource ( "org.igniterealtime.jbosh/" + ofClass . getName ( ) ) ; if ( url == null ) { // Early-out return result ; } InputStream inStream = null ; InputStreamReader reader = null ; BufferedReader bReader = null ; try { inStream = url . openStream ( ) ; reader = new InputStreamReader ( inStream ) ; bReader = new BufferedReader ( reader ) ; String line ; while ( ( line = bReader . readLine ( ) ) != null ) { if ( ! line . matches ( "\\s*(#.*)?" ) ) { // not a comment or blank line result . add ( line . trim ( ) ) ; } } } catch ( IOException iox ) { LOG . log ( Level . WARNING , "Could not load services descriptor: " + url . toString ( ) , iox ) ; } finally { finalClose ( bReader ) ; finalClose ( reader ) ; finalClose ( inStream ) ; } return result ; }
Generates a list of implementation class names by using the Jar SPI technique . The order in which the class names occur in the service manifest is significant .