/** * THIS METHOD WILL ME MOVED/RENAMED, DO NOT USE. * * @param registry the registry to lookup from. * @param providerClassName name of the provider class. * @param category provider category * * @return the provider instance, or {@code null}. */ public static <T> T lookupProviderByName(final ServiceRegistry registry, final String providerClassName, Class<T> category) { try { return category.cast(registry.getServiceProviderByClass(Class.forName(providerClassName))); } catch (ClassNotFoundException ignore) { return null; } }
// New and improved (shorter) version. :-) private static <T> T lookupProviderByName(final ServiceRegistry registry, final String providerClassName) { try { return (T) registry.getServiceProviderByClass(Class.forName(providerClassName)); } catch (ClassNotFoundException ignore) { return null; } }
// New and improved (shorter) version. :-) private static <T> T lookupProviderByName(final ServiceRegistry registry, final String providerClassName) { try { return (T) registry.getServiceProviderByClass(Class.forName(providerClassName)); } catch (ClassNotFoundException ignore) { return null; } }
/** * THIS METHOD WILL ME MOVED/RENAMED, DO NOT USE. * * @param registry the registry to lookup from. * @param providerClassName name of the provider class. * * @return the provider instance, or {@code null}. */ public static <T> T lookupProviderByName(final ServiceRegistry registry, final String providerClassName) { try { return (T) registry.getServiceProviderByClass(Class.forName(providerClassName)); } catch (ClassNotFoundException ignore) { return null; } }
/** Instruct registry to prioritize this ReaderSpi over other JPEG readers. **/ @SuppressWarnings("unchecked") @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { Stream.of( "com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReaderSpi", "com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi").forEach((clsName) -> { try { ImageReaderSpi defaultProvider = (ImageReaderSpi) registry.getServiceProviderByClass(Class.forName(clsName)); registry.setOrdering((Class<ImageReaderSpi>) category, this, defaultProvider); } catch (ClassNotFoundException e) { // NOP } }); }
/** Instruct registry to prioritize this WriterSpi over other JPEG writers. **/ @SuppressWarnings("unchecked") @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { Stream.of( "com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageWriterSpi", "com.sun.imageio.plugins.jpeg.JPEGImageWriterSpi").forEach((clsName) -> { try { ImageWriterSpi defaultProvider = (ImageWriterSpi) registry.getServiceProviderByClass(Class.forName(clsName)); registry.setOrdering((Class<ImageWriterSpi>) category, this, defaultProvider); } catch (ClassNotFoundException e) { // NOP } }); }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib writer precedence. Class codecLibWriterSPIClass = null; try { codecLibWriterSPIClass = Class.forName("com.github.jaiimageio.jpeg2000.impl.J2KImageWriterCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibWriterSPIClass != null) { Object codecLibWriterSPI = registry.getServiceProviderByClass(codecLibWriterSPIClass); if(codecLibWriterSPI != null) { registry.setOrdering(category, codecLibWriterSPI, this); } } }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib writer precedence. Class codecLibWriterSPIClass = null; try { codecLibWriterSPIClass = Class.forName("com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageWriterCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibWriterSPIClass != null) { Object codecLibWriterSPI = registry.getServiceProviderByClass(codecLibWriterSPIClass); if(codecLibWriterSPI != null) { registry.setOrdering(category, codecLibWriterSPI, this); } } }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib reader precedence. Class codecLibReaderSPIClass = null; try { codecLibReaderSPIClass = Class.forName("com.github.jaiimageio.jpeg2000.impl.J2KImageReaderCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibReaderSPIClass != null) { Object codecLibReaderSPI = registry.getServiceProviderByClass(codecLibReaderSPIClass); if(codecLibReaderSPI != null) { registry.setOrdering(category, codecLibReaderSPI, this); } } }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib writer precedence. Class codecLibWriterSPIClass = null; try { codecLibWriterSPIClass = Class.forName("com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageWriterCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibWriterSPIClass != null) { Object codecLibWriterSPI = registry.getServiceProviderByClass(codecLibWriterSPIClass); if(codecLibWriterSPI != null) { registry.setOrdering(category, codecLibWriterSPI, this); } } }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib reader precedence. Class codecLibReaderSPIClass = null; try { codecLibReaderSPIClass = Class.forName("io.scif.media.imageioimpl.plugins.jpeg2000.J2KImageReaderCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibReaderSPIClass != null) { Object codecLibReaderSPI = registry.getServiceProviderByClass(codecLibReaderSPIClass); if(codecLibReaderSPI != null) { registry.setOrdering(category, codecLibReaderSPI, this); } } }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib writer precedence. Class codecLibWriterSPIClass = null; try { codecLibWriterSPIClass = Class.forName("io.scif.media.imageioimpl.plugins.jpeg2000.J2KImageWriterCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibWriterSPIClass != null) { Object codecLibWriterSPI = registry.getServiceProviderByClass(codecLibWriterSPIClass); if(codecLibWriterSPI != null) { registry.setOrdering(category, codecLibWriterSPI, this); } } }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib reader precedence. Class codecLibReaderSPIClass = null; try { codecLibReaderSPIClass = Class.forName("com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibReaderSPIClass != null) { Object codecLibReaderSPI = registry.getServiceProviderByClass(codecLibReaderSPIClass); if(codecLibReaderSPI != null) { registry.setOrdering(category, codecLibReaderSPI, this); } } }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib writer precedence. Class codecLibWriterSPIClass = null; try { codecLibWriterSPIClass = Class.forName("com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageWriterCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibWriterSPIClass != null) { Object codecLibWriterSPI = registry.getServiceProviderByClass(codecLibWriterSPIClass); if(codecLibWriterSPI != null) { registry.setOrdering(category, codecLibWriterSPI, this); } } }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib reader precedence. Class codecLibReaderSPIClass = null; try { codecLibReaderSPIClass = Class.forName("com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibReaderSPIClass != null) { Object codecLibReaderSPI = registry.getServiceProviderByClass(codecLibReaderSPIClass); if(codecLibReaderSPI != null) { registry.setOrdering(category, codecLibReaderSPI, this); } } }
public void onRegistration(ServiceRegistry registry, Class category) { if (registered) { return; } registered = true; // Set pairwise ordering to give codecLib reader precedence. Class codecLibReaderSPIClass = null; try { codecLibReaderSPIClass = Class.forName("com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderCodecLibSpi"); } catch(Throwable t) { // Ignore it. } if(codecLibReaderSPIClass != null) { Object codecLibReaderSPI = registry.getServiceProviderByClass(codecLibReaderSPIClass); if(codecLibReaderSPI != null) { registry.setOrdering(category, codecLibReaderSPI, this); } } }
@SuppressWarnings("unchecked") @Override public void onRegistration(final ServiceRegistry registry, final Class<?> category) { // Make sure we're ordered before the Apple-provided TIFF reader on OS X try { Class<ImageReaderSpi> providerClass = (Class<ImageReaderSpi>) Class.forName("com.sun.imageio.plugins.tiff.TIFFImageReaderSpi"); ImageReaderSpi appleSpi = registry.getServiceProviderByClass(providerClass); if (appleSpi != null && appleSpi.getVendorName() != null && appleSpi.getVendorName().startsWith("Apple")) { registry.setOrdering((Class<ImageReaderSpi>) category, this, appleSpi); } } catch (ClassNotFoundException ignore) { // This is actually OK, now we don't have to do anything } }
it = registry.getServiceProviders(category, false); } else { it = Collections.singleton(registry.getServiceProviderByClass(type)).iterator();