public ConnectionDecoratorFactory resolve ( ) { int loadingIndex = Integer . MIN_VALUE ; ConnectionDecoratorFactory connectionDecoratorFactory = null ; Iterator < ConnectionDecoratorFactoryService > connectionDecoratorFactoryServiceIterator = serviceLoader . iterator ( ) ; while ( connectionDecoratorFactoryServiceIterator . hasNext ( ) ) { try { ConnectionDecoratorFactoryService connectionDecoratorFactoryService = connectionDecoratorFactoryServiceIterator . next ( ) ; int currentLoadingIndex = connectionDecoratorFactoryService . loadingIndex ( ) ; if ( currentLoadingIndex > loadingIndex ) { ConnectionDecoratorFactory currentConnectionDecoratorFactory = connectionDecoratorFactoryService . load ( ) ; if ( currentConnectionDecoratorFactory != null ) { connectionDecoratorFactory = currentConnectionDecoratorFactory ; loadingIndex = currentLoadingIndex ; } } } catch ( LinkageError e ) { LOGGER . info ( "Couldn't load ConnectionDecoratorFactoryService on the current JVM" , e ) ; } } if ( connectionDecoratorFactory != null ) { return connectionDecoratorFactory ; } throw new IllegalStateException ( "No ConnectionDecoratorFactory could be loaded!" ) ; }
Resolve ConnectionDecoratorFactory from the Service Provider Interface configuration