@Test public void testAddProvider$repeated() throws Exception { ProtocolHandlerConfigurator.addProvider(Handler.class); assertThat(ProtocolHandlerConfigurator.isSupported("net"),equalTo(true)); assertThat(ProtocolHandlerConfigurator.addProvider(Handler.class),equalTo(false)); assertThat(ProtocolHandlerConfigurator.isSupported("net"),equalTo(true)); }
private synchronized boolean addProvider(String baseProtocolPackage, String... schemes) { trace(String.format("Configuring provider '%s' for custom protocol handlers %s",baseProtocolPackage,Arrays.asList(schemes))); List<String> providers = getProviders(); boolean needUpdate=!providers.contains(baseProtocolPackage); if(needUpdate) { packagesAdded.add(baseProtocolPackage); } trace( !needUpdate? "Custom protocol handler provider '%s' already configured.": "Registered custom protocol handler provider '%s'.", baseProtocolPackage); return needUpdate; }
ProtocolHandlerConfigurator { private synchronized boolean addProvider(String baseProtocolPackage, String... schemes) { trace(String.format("Configuring provider '%s' for custom protocol handlers %s",baseProtocolPackage,Arrays.asList(schemes))); List<String> providers = getProviders(); boolean needUpdate=!providers.contains(baseProtocolPackage); if(needUpdate) { packagesAdded.add(baseProtocolPackage); } trace( !needUpdate? "Custom protocol handler provider '%s' already configured.": "Registered custom protocol handler provider '%s'.", baseProtocolPackage); return needUpdate; } }
ProtocolHandlerConfigurator { private synchronized boolean addProvider(String baseProtocolPackage, String... schemes) { trace(String.format("Configuring provider '%s' for custom protocol handlers %s",baseProtocolPackage,Arrays.asList(schemes))); List<String> providers = getProviders(); boolean needUpdate=!providers.contains(baseProtocolPackage); if(needUpdate) { packagesAdded.add(baseProtocolPackage); } trace( !needUpdate? "Custom protocol handler provider '%s' already configured.": "Registered custom protocol handler provider '%s'.", baseProtocolPackage); return needUpdate; } private  ProtocolHandlerConfigurator(); }
ProtocolHandlerConfigurator { private synchronized boolean addProvider(String baseProtocolPackage, String... schemes) { trace(String.format("Configuring provider '%s' for custom protocol handlers %s",baseProtocolPackage,Arrays.asList(schemes))); List<String> providers = getProviders(); boolean needUpdate=!providers.contains(baseProtocolPackage); if(needUpdate) { packagesAdded.add(baseProtocolPackage); } trace( !needUpdate? "Custom protocol handler provider '%s' already configured.": "Registered custom protocol handler provider '%s'.", baseProtocolPackage); return needUpdate; } private  ProtocolHandlerConfigurator(); static boolean isSupported(String scheme); static URLStreamHandler getHandler(String scheme); static boolean addProvider(Class<T> handlerClass); static void reset(); }
ProtocolHandlerConfigurator { private synchronized boolean addProvider(String baseProtocolPackage, String... schemes) { trace(String.format("Configuring provider '%s' for custom protocol handlers %s",baseProtocolPackage,Arrays.asList(schemes))); List<String> providers = getProviders(); boolean needUpdate=!providers.contains(baseProtocolPackage); if(needUpdate) { packagesAdded.add(baseProtocolPackage); } trace( !needUpdate? "Custom protocol handler provider '%s' already configured.": "Registered custom protocol handler provider '%s'.", baseProtocolPackage); return needUpdate; } private  ProtocolHandlerConfigurator(); static boolean isSupported(String scheme); static URLStreamHandler getHandler(String scheme); static boolean addProvider(Class<T> handlerClass); static void reset();  }