Java 8 ServiceRegistry - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ServiceRegistry class.

This code example shows how to use the following methods:deregisterServiceProvider, getServiceProviderByClass, registerServiceProvider
            // If JRE contains imageio.jar in lib/ext, get spi classes and unregister them 
            spiClass = Class.forName(clazz.getName(), true, ClassLoader.getSystemClassLoader());
        } catch (ClassNotFoundException e) {
        } 
        if (spiClass != null) {
            Object spi = registry.getServiceProviderByClass(spiClass);
            if (spi != null) { 
                registry.deregisterServiceProvider(spi);
            } 
        } 
        try { 
            // Resister again the spi classes with the bundle classloader 
            registry.registerServiceProvider(clazz.newInstance());
        } catch (Exception e) {
            e.printStackTrace();
        } 
    } 
 
    public static void unRegisterServiceProvider(Class clazz) {
        Object spi = registry.getServiceProviderByClass(clazz);
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        categories.add(ExportFileType.class);
        categories.add(RegisterableService.class);
    } 
 
    private ExportFileTypeRegistry() { 
        service = new ServiceRegistry(categories.iterator());
        extraTypes = new ArrayList<ExportFileType>();
    } 
 
    public static synchronized ExportFileTypeRegistry getDefaultInstance(ClassLoader loader) {
        if ((loader != null) && (loader != ExportFileTypeRegistry.loader)) {
            if (ExportFileTypeRegistry.loader != null) throw new RuntimeException(ExportFileTypeRegistry.class.getName() + ": Different classloader was already used in getDefaultInstance");
            ExportFileTypeRegistry.loader = loader;
        } 
 
        if (registry == null) {
            registry = new ExportFileTypeRegistry();
            // NOTE: not in constructor to avoid recursive calls. If such call comes in 
            // as a result of something on the classpath needing the registry inside 
            // the onRegistration call. Such call would just return the already created 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:registerServiceProvider
    public ImageReader createReaderInstance(Object extension) {
        return new JPEGImageReader(this);
    } 
 
    public static void registerSpis(IIORegistry reg) {
        reg.registerServiceProvider(getReaderSpi(), ImageReaderSpi.class);
    } 
 
    public static synchronized JPEGImageReaderSpi getReaderSpi() { 
        if (readerSpi == null)
            readerSpi = new JPEGImageReaderSpi();
        return readerSpi;
    } 
} 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:deregisterServiceProvider
            deregisterOtherSPIs(registry, category);
        } else { 
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine("Deregistering " + this.getClass().getName());
            } 
            registry.deregisterServiceProvider(this);
        } 
    } 
 
    private static Method readerFormatNamesMethod;
    static { 
        try { 
            readerFormatNamesMethod = ImageReaderSpi.class.getMethod("getFormatNames");
        } catch (NoSuchMethodException e) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.fine(e.getLocalizedMessage());
            } 
        } 
    } 
 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:deregisterServiceProvider
     * @deprecated 
     */ 
    public static <T> void deregisterProvider(final ServiceRegistry pRegistry, final IIOServiceProvider pProvider, final Class<T> pCategory) {
        // http://www.ibm.com/developerworks/java/library/j-jtp04298.html 
        // TODO: Consider placing this method in a ImageReaderSpiBase class or similar 
        pRegistry.deregisterServiceProvider(pCategory.cast(pProvider), pCategory);
    } 
 
    /** 
     * Returns a sorted array of format names, that can be read by ImageIO. 
     * The names are all upper-case, and contains no duplicates. 
     * 
     * @return a normalized array of {@code String}s. 
     * @see javax.imageio.ImageIO#getReaderFormatNames() 
     */ 
    public static String[] getNormalizedReaderFormatNames() {
        return normalizeNames(ImageIO.getReaderFormatNames());
    } 
 
    /** 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 ServiceRegistry Methods: