static public void registerIOProviderPreferred ( Class iospClass , Class target ) throws IllegalAccessException , InstantiationException { iospDeRegister ( iospClass ) ; // forcibly de-register int pos = - 1 ; for ( int i = 0 ; i < registeredProviders . size ( ) ; i ++ ) { IOServiceProvider candidate = registeredProviders . get ( i ) ; if ( candidate . getClass ( ) == target ) { if ( pos < i ) pos = i ; break ; // this is where is must be placed } } if ( pos < 0 ) pos = 0 ; IOServiceProvider spi = ( IOServiceProvider ) iospClass . newInstance ( ) ; // fail fast registeredProviders . add ( pos , spi ) ; // insert before target }
Register an IOServiceProvider . A new instance will be created when one of its files is opened . This differs from the above in that it specifically locates the target iosp and inserts the new one in front of it in order to override the target . If the iospclass is already registered remove it and reinsert . If the target class is not present then insert at front of the registry