private static bool LoadProviderFromProperty() { String cn = System.getProperty("java.nio.channels.spi.SelectorProvider"); if (cn == null) { return(false); } try { Class c = Class.ForName(cn, true, ClassLoader.SystemClassLoader); Provider_Renamed = (SelectorProvider)c.NewInstance(); return(true); } catch (ClassNotFoundException x) { throw new ServiceConfigurationError(null, x); } catch (IllegalAccessException x) { throw new ServiceConfigurationError(null, x); } catch (InstantiationException x) { throw new ServiceConfigurationError(null, x); } catch (SecurityException x) { throw new ServiceConfigurationError(null, x); } }
private static bool LoadProviderAsService() { ServiceLoader <SelectorProvider> sl = ServiceLoader.Load(typeof(SelectorProvider), ClassLoader.SystemClassLoader); IEnumerator <SelectorProvider> i = sl.Iterator(); for (;;) { try { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: if (!i.hasNext()) { return(false); } //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: Provider_Renamed = i.next(); return(true); } catch (ServiceConfigurationError sce) { if (sce.Cause is SecurityException) { // Ignore the security exception, try the next provider continue; } throw sce; } } }
/// <summary> /// Initializes a new instance of this class. /// </summary> /// <param name="provider"> /// The provider that created this selector </param> protected internal AbstractSelector(SelectorProvider provider) { this.Provider_Renamed = provider; }