public static < E > E get ( Class < E > type ) { ServiceLoader < E > loader = ServiceLoader . load ( type ) ; Iterator < E > iterator = loader . iterator ( ) ; if ( iterator . hasNext ( ) ) { return iterator . next ( ) ; // only one is expected } try { //loads the default implementation return ( E ) Class . forName ( getDefaultImplementationName ( type ) ) . newInstance ( ) ; } catch ( Exception e ) { throw new TruggerException ( e ) ; } }
Returns the implementation for a given class .