@ SuppressWarnings ( "javadoc" ) public static < T > T getSingleService ( Class < T > serviceInterface ) throws IllegalStateException { // Cached single service values are derived from the values cached when checking // for multiple services T rval = null ; Set < T > services = getServices ( serviceInterface ) ; if ( services . size ( ) > 1 ) { throw new IllegalStateException ( "Multiple implementations found of " + serviceInterface ) ; //$NON-NLS-1$ } else if ( ! services . isEmpty ( ) ) { rval = services . iterator ( ) . next ( ) ; } return rval ; }
Gets a single service by its interface .