/** * Upon registration, this method ensures that this SPI will be invoked * before the default FileImageOutputStreamSpi * * @param registry * ServiceRegistry where this object has been registered. * @param category * a Class object indicating the registry category under * which this object has been registered. */ @SuppressWarnings("unchecked") public void onRegistration(ServiceRegistry registry, Class category) { super.onRegistration(registry, category); Object other; final Class targetClass = ImageOutputStreamSpi.class; for (Iterator i = registry.getServiceProviders(targetClass, true); i.hasNext();) { other = i.next(); // using class name to avoid warnings in JDK 11 if (other != null && other.getClass().getName().equals("com.sun.imageio.spi.FileImageOutputStreamSpi")) registry.deregisterServiceProvider(other); if (this != other) { registry.setOrdering(targetClass, this, other); } } }
/** * Upon registration, this method ensures that this SPI will be invoked * before the default FileImageOutputStreamSpi * * @param registry * ServiceRegistry where this object has been registered. * @param category * a Class object indicating the registry category under * which this object has been registered. */ @SuppressWarnings("unchecked") public void onRegistration(ServiceRegistry registry, Class category) { super.onRegistration(registry, category); Object other; final Class targetClass = ImageOutputStreamSpi.class; for (Iterator i = registry.getServiceProviders(targetClass, true); i.hasNext();) { other = i.next(); if (other instanceof FileImageOutputStreamSpi) registry.deregisterServiceProvider(other); if (this != other) { registry.setOrdering(targetClass, this, other); } } }