Skip to content

Instantly share code, notes, and snippets.

@umjammer
Last active September 24, 2015 23:38
Show Gist options
  • Save umjammer/827910 to your computer and use it in GitHub Desktop.
Save umjammer/827910 to your computer and use it in GitHub Desktop.
static <T> void setOrder(Class<T> pt, String p1, String p2) {
IIORegistry iioRegistry = IIORegistry.getDefaultInstance();
T sp1 = null;
T sp2 = null;
Iterator<T> i = iioRegistry.getServiceProviders(pt, true);
while (i.hasNext()) {
T p = i.next();
if (p1.equals(p.getClass().getName())) {
sp1 = p;
System.err.println("1: " + sp1.getClass().getName());
} else if (p2.equals(p.getClass().getName())) {
sp2 = p;
System.err.println("2: " + sp2.getClass().getName());
}
}
if (sp1 == null || sp2 == null) {
throw new IllegalArgumentException(p1 + " or " + p2 + " not found");
}
iioRegistry.setOrdering(pt, sp1, sp2);
}
setOrder(ImageReaderSpi.class,
"com.sixlegs.png.iio.PngImageReaderSpi",
"com.sun.imageio.plugins.png.PNGImageReaderSpi");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment