@ PostConstruct public void checkUniqueSchemes ( ) { Multimap < String , ConfigFileLoaderPlugin > schemeToPluginMap = HashMultimap . create ( ) ; for ( ConfigFileLoaderPlugin plugin : getLoaderPlugins ( ) ) { schemeToPluginMap . put ( plugin . getUriScheme ( ) , plugin ) ; } StringBuilder violations = new StringBuilder ( ) ; for ( String scheme : schemeToPluginMap . keySet ( ) ) { final Collection < ConfigFileLoaderPlugin > plugins = schemeToPluginMap . get ( scheme ) ; if ( plugins . size ( ) > 1 ) { violations . append ( "\n\n* " ) . append ( "There are has multiple " ) . append ( ConfigFileLoaderPlugin . class . getSimpleName ( ) ) . append ( " plugins that support the scheme: '" ) . append ( scheme ) . append ( ' ' ) . append ( ":\n\t" ) . append ( plugins ) ; } } if ( violations . length ( ) > 0 ) { throw new IllegalStateException ( violations . toString ( ) ) ; } }
Method is called by spring and verifies that there is only one plugin per URI scheme .