@ SuppressWarnings ( "unchecked" ) @ Override public < I > I newInstance ( ManagedClassSPI managedClass , Object ... args ) { if ( args . length > 0 ) { throw new IllegalArgumentException ( "Service instances factory does not support arguments." ) ; } Class < ? > [ ] interfaceClasses = managedClass . getInterfaceClasses ( ) ; if ( interfaceClasses == null ) { throw new BugError ( "Invalid managed class. Null interface classes." ) ; } if ( interfaceClasses . length != 1 ) { throw new BugError ( "Invalid managed class. It should have exactly one interface class." ) ; } return ( I ) Classes . loadService ( interfaceClasses [ 0 ] ) ; }
Load service defined by managed class interface and return service instance . This factory does not support arguments . Service provider should be present into run - time otherwise no provider exception is thrown .