本文整理汇总了Java中java.util.ServiceConfigurationError.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceConfigurationError.getCause方法的具体用法?Java ServiceConfigurationError.getCause怎么用?Java ServiceConfigurationError.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ServiceConfigurationError
的用法示例。
在下文中一共展示了ServiceConfigurationError.getCause方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadProviderAsService
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static boolean loadProviderAsService() {
ServiceLoader<SelectorProvider> sl =
ServiceLoader.load(SelectorProvider.class,
ClassLoader.getSystemClassLoader());
Iterator<SelectorProvider> i = sl.iterator();
for (;;) {
try {
if (!i.hasNext())
return false;
provider = i.next();
return true;
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore the security exception, try the next provider
continue;
}
throw sce;
}
}
}
示例2: loadProviderAsService
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static AsynchronousChannelProvider loadProviderAsService() {
ServiceLoader<AsynchronousChannelProvider> sl =
ServiceLoader.load(AsynchronousChannelProvider.class,
ClassLoader.getSystemClassLoader());
Iterator<AsynchronousChannelProvider> i = sl.iterator();
for (;;) {
try {
return (i.hasNext()) ? i.next() : null;
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore the security exception, try the next provider
continue;
}
throw sce;
}
}
}
示例3: loadProviderAsService
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static boolean loadProviderAsService() {
Iterator<HttpServerProvider> i =
ServiceLoader.load(HttpServerProvider.class,
ClassLoader.getSystemClassLoader())
.iterator();
for (;;) {
try {
if (!i.hasNext())
return false;
provider = i.next();
return true;
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore the security exception, try the next provider
continue;
}
throw sce;
}
}
}
示例4: factory1
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static PreferencesFactory factory1() {
// 2. Try service provider interface
Iterator<PreferencesFactory> itr = ServiceLoader
.load(PreferencesFactory.class, ClassLoader.getSystemClassLoader())
.iterator();
// choose first provider instance
while (itr.hasNext()) {
try {
return itr.next();
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore the security exception, try the next provider
continue;
}
throw sce;
}
}
// 3. Use platform-specific system-wide default
String osName = System.getProperty("os.name");
String platformFactory;
if (osName.startsWith("Windows")) {
platformFactory = "java.util.prefs.WindowsPreferencesFactory";
} else if (osName.contains("OS X")) {
platformFactory = "java.util.prefs.MacOSXPreferencesFactory";
} else {
platformFactory = "java.util.prefs.FileSystemPreferencesFactory";
}
try {
return (PreferencesFactory)
Class.forName(platformFactory, false,
Preferences.class.getClassLoader()).newInstance();
} catch (Exception e) {
throw new InternalError(
"Can't instantiate platform default Preferences factory "
+ platformFactory, e);
}
}
示例5: providers
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static Iterator<URLStreamHandlerProvider> providers() {
return new Iterator<>() {
ClassLoader cl = ClassLoader.getSystemClassLoader();
ServiceLoader<URLStreamHandlerProvider> sl =
ServiceLoader.load(URLStreamHandlerProvider.class, cl);
Iterator<URLStreamHandlerProvider> i = sl.iterator();
URLStreamHandlerProvider next = null;
private boolean getNext() {
while (next == null) {
try {
if (!i.hasNext())
return false;
next = i.next();
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore security exceptions
continue;
}
throw sce;
}
}
return true;
}
public boolean hasNext() {
return getNext();
}
public URLStreamHandlerProvider next() {
if (!getNext())
throw new NoSuchElementException();
URLStreamHandlerProvider n = next;
next = null;
return n;
}
};
}
示例6: factory1
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static PreferencesFactory factory1() {
// 2. Try service provider interface
Iterator<PreferencesFactory> itr = ServiceLoader
.load(PreferencesFactory.class, ClassLoader.getSystemClassLoader())
.iterator();
// choose first provider instance
while (itr.hasNext()) {
try {
return itr.next();
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore the security exception, try the next provider
continue;
}
throw sce;
}
}
// 3. Use platform-specific system-wide default
String osName = System.getProperty("os.name");
String platformFactory;
if (osName.startsWith("Windows")) {
platformFactory = "java.util.prefs.WindowsPreferencesFactory";
} else if (osName.contains("OS X")) {
platformFactory = "java.util.prefs.MacOSXPreferencesFactory";
} else {
platformFactory = "java.util.prefs.FileSystemPreferencesFactory";
}
try {
@SuppressWarnings("deprecation")
Object result = Class.forName(platformFactory, false,
Preferences.class.getClassLoader()).newInstance();
return (PreferencesFactory) result;
} catch (Exception e) {
throw new InternalError(
"Can't instantiate platform default Preferences factory "
+ platformFactory, e);
}
}
示例7: factory1
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static PreferencesFactory factory1() {
// 2. Try service provider interface
Iterator<PreferencesFactory> itr = ServiceLoader
.load(PreferencesFactory.class, ClassLoader.getSystemClassLoader())
.iterator();
// choose first provider instance
while (itr.hasNext()) {
try {
return itr.next();
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore the security exception, try the next provider
continue;
}
throw sce;
}
}
// 3. Use platform-specific system-wide default
String osName = System.getProperty("os.name");
String platformFactory;
if (osName.startsWith("Windows")) {
platformFactory = "java.util.prefs.WindowsPreferencesFactory";
} else if (osName.contains("OS X")) {
platformFactory = "java.util.prefs.MacOSXPreferencesFactory";
} else {
platformFactory = "java.util.prefs.FileSystemPreferencesFactory";
}
try {
return (PreferencesFactory)
Class.forName(platformFactory, false, null).newInstance();
} catch (Exception e) {
InternalError error = new InternalError(
"Can't instantiate platform default Preferences factory "
+ platformFactory);
error.initCause(e);
throw error;
}
}
示例8: factory1
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static PreferencesFactory factory1() {
// 2. Try service provider interface
Iterator<PreferencesFactory> itr = ServiceLoader
.load(PreferencesFactory.class, ClassLoader.getSystemClassLoader())
.iterator();
// choose first provider instance
while (itr.hasNext()) {
try {
return itr.next();
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore the security exception, try the next provider
continue;
}
throw sce;
}
}
// 3. Use platform-specific system-wide default
String platformFactory =
System.getProperty("os.name").startsWith("Windows")
? "java.util.prefs.WindowsPreferencesFactory"
: "java.util.prefs.FileSystemPreferencesFactory";
try {
return (PreferencesFactory)
Class.forName(platformFactory, false, null).newInstance();
} catch (Exception e) {
InternalError error = new InternalError(
"Can't instantiate platform default Preferences factory "
+ platformFactory);
error.initCause(e);
throw error;
}
}
示例9: providers
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static Iterator<CharsetProvider> providers() {
return new Iterator<CharsetProvider>() {
ClassLoader cl = ClassLoader.getSystemClassLoader();
ServiceLoader<CharsetProvider> sl =
ServiceLoader.load(CharsetProvider.class, cl);
Iterator<CharsetProvider> i = sl.iterator();
CharsetProvider next = null;
private boolean getNext() {
while (next == null) {
try {
if (!i.hasNext())
return false;
next = i.next();
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore security exceptions
continue;
}
throw sce;
}
}
return true;
}
public boolean hasNext() {
return getNext();
}
public CharsetProvider next() {
if (!getNext())
throw new NoSuchElementException();
CharsetProvider n = next;
next = null;
return n;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例10: providers
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static Iterator<CharsetProvider> providers() {
return new Iterator<>() {
ClassLoader cl = ClassLoader.getSystemClassLoader();
ServiceLoader<CharsetProvider> sl =
ServiceLoader.load(CharsetProvider.class, cl);
Iterator<CharsetProvider> i = sl.iterator();
CharsetProvider next = null;
private boolean getNext() {
while (next == null) {
try {
if (!i.hasNext())
return false;
next = i.next();
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore security exceptions
continue;
}
throw sce;
}
}
return true;
}
public boolean hasNext() {
return getNext();
}
public CharsetProvider next() {
if (!getNext())
throw new NoSuchElementException();
CharsetProvider n = next;
next = null;
return n;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例11: providers
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
private static Iterator providers() {
return new Iterator() {
ClassLoader cl = ClassLoader.getSystemClassLoader();
ServiceLoader<CharsetProvider> sl =
ServiceLoader.load(CharsetProvider.class, cl);
Iterator<CharsetProvider> i = sl.iterator();
Object next = null;
private boolean getNext() {
while (next == null) {
try {
if (!i.hasNext())
return false;
next = i.next();
} catch (ServiceConfigurationError sce) {
if (sce.getCause() instanceof SecurityException) {
// Ignore security exceptions
continue;
}
throw sce;
}
}
return true;
}
public boolean hasNext() {
return getNext();
}
public Object next() {
if (!getNext())
throw new NoSuchElementException();
Object n = next;
next = null;
return n;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}