Java Code Examples for javax.imageio.spi.ServiceRegistry#getServiceProviderByClass()
The following examples show how to use
javax.imageio.spi.ServiceRegistry#getServiceProviderByClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: J2KImageReaderSpi.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 6 votes |
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); } } }
Example 2
Source File: J2KImageWriterSpi.java From healthcare-dicom-dicomweb-adapter with Apache License 2.0 | 6 votes |
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); } } }
Example 3
Source File: OrderingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public OrderingTest() { ServiceRegistry reg = IIORegistry.getDefaultInstance(); ImageReaderSpi gifSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.gif.GIFImageReaderSpi.class); ImageReaderSpi pngSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.png.PNGImageReaderSpi.class); boolean ordered = reg.setOrdering(ImageReaderSpi.class, gifSpi, pngSpi); ordered = reg.setOrdering(ImageReaderSpi.class, pngSpi, gifSpi); boolean unordered = reg.unsetOrdering(ImageReaderSpi.class, gifSpi, pngSpi); boolean unordered1 = reg.unsetOrdering(ImageReaderSpi.class, gifSpi, pngSpi); if (unordered1) { throw new RuntimeException("FAIL: Ordering 2 spi objects in the " + "reverse direction does not remove the previous ordering " + "set between the spi objects and hence unsetOrdering() " + "returns true for the same spi objects when called consecutively"); } else { System.out.println("PASS"); } }
Example 4
Source File: DeregisterOrderedSpiTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public DeregisterOrderedSpiTest() { try { ServiceRegistry reg = IIORegistry.getDefaultInstance(); ImageReaderSpi gifSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.gif.GIFImageReaderSpi.class); ImageReaderSpi pngSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.png.PNGImageReaderSpi.class); ImageReaderSpi jpgSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.class); ImageReaderSpi bmpSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.bmp.BMPImageReaderSpi.class); boolean ordered = reg.setOrdering(ImageReaderSpi.class, pngSpi, gifSpi); ordered = reg.setOrdering(ImageReaderSpi.class, gifSpi, jpgSpi); ordered = reg.setOrdering(ImageReaderSpi.class, bmpSpi, gifSpi); reg.deregisterServiceProvider(gifSpi); System.out.println("PASS"); } catch (Exception e) { System.out.println("FAIL"); throw new RuntimeException("Deregistering a spi object involved in some " + "ordering throws the following exception: " + e.toString()); } }
Example 5
Source File: OrderingTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public OrderingTest() { ServiceRegistry reg = IIORegistry.getDefaultInstance(); ImageReaderSpi gifSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.gif.GIFImageReaderSpi.class); ImageReaderSpi pngSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.png.PNGImageReaderSpi.class); boolean ordered = reg.setOrdering(ImageReaderSpi.class, gifSpi, pngSpi); ordered = reg.setOrdering(ImageReaderSpi.class, pngSpi, gifSpi); boolean unordered = reg.unsetOrdering(ImageReaderSpi.class, gifSpi, pngSpi); boolean unordered1 = reg.unsetOrdering(ImageReaderSpi.class, gifSpi, pngSpi); if (unordered1) { throw new RuntimeException("FAIL: Ordering 2 spi objects in the " + "reverse direction does not remove the previous ordering " + "set between the spi objects and hence unsetOrdering() " + "returns true for the same spi objects when called consecutively"); } else { System.out.println("PASS"); } }
Example 6
Source File: DeregisterOrderedSpiTest.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public DeregisterOrderedSpiTest() { try { ServiceRegistry reg = IIORegistry.getDefaultInstance(); ImageReaderSpi gifSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.gif.GIFImageReaderSpi.class); ImageReaderSpi pngSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.png.PNGImageReaderSpi.class); ImageReaderSpi jpgSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi.class); ImageReaderSpi bmpSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.bmp.BMPImageReaderSpi.class); boolean ordered = reg.setOrdering(ImageReaderSpi.class, pngSpi, gifSpi); ordered = reg.setOrdering(ImageReaderSpi.class, gifSpi, jpgSpi); ordered = reg.setOrdering(ImageReaderSpi.class, bmpSpi, gifSpi); reg.deregisterServiceProvider(gifSpi); System.out.println("PASS"); } catch (Exception e) { System.out.println("FAIL"); throw new RuntimeException("Deregistering a spi object involved in some " + "ordering throws the following exception: " + e.toString()); } }