当前位置: 首页>>代码示例>>Java>>正文


Java ServiceConfigurationError.getCause方法代码示例

本文整理汇总了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;
            }
        }
    }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:SelectorProvider.java

示例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;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:AsynchronousChannelProvider.java

示例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;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:HttpServerProvider.java

示例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);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:Preferences.java

示例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;
        }
    };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:URL.java

示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:Preferences.java

示例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;
    }
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:41,代码来源:Preferences.java

示例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;
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:36,代码来源:Preferences.java

示例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();
            }

        };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:46,代码来源:Charset.java

示例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();
            }

        };
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:Charset.java

示例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();
            }

        };
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:46,代码来源:Charset.java


注:本文中的java.util.ServiceConfigurationError.getCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。