本文整理汇总了Java中javax.imageio.spi.IIORegistry.getServiceProviders方法的典型用法代码示例。如果您正苦于以下问题:Java IIORegistry.getServiceProviders方法的具体用法?Java IIORegistry.getServiceProviders怎么用?Java IIORegistry.getServiceProviders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.spi.IIORegistry
的用法示例。
在下文中一共展示了IIORegistry.getServiceProviders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJPEGTablesReader
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
/**
* Retrieves a JPEG reader which supports native JPEG stream metadata.
*/
private static ImageReader getJPEGTablesReader() {
ImageReader jpegReader = null;
try {
IIORegistry registry = IIORegistry.getDefaultInstance();
Iterator<?> readerSPIs =
registry.getServiceProviders(ImageReaderSpi.class,
new JPEGSPIFilter(),
true);
if(readerSPIs.hasNext()) {
ImageReaderSpi jpegReaderSPI =
(ImageReaderSpi)readerSPIs.next();
jpegReader = jpegReaderSPI.createReaderInstance();
}
} catch(Exception e) {
// Ignore it ...
}
return jpegReader;
}
示例2: main
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
public static void main(final String[] args) throws IOException {
final IIORegistry registry = IIORegistry.getDefaultInstance();
final Iterator<ImageWriterSpi> iter = registry.getServiceProviders(
ImageWriterSpi.class, provider -> true, true);
// Validates all supported ImageWriters
int numFailures = 0;
while (iter.hasNext()) {
final WriteAfterAbort writeAfterAbort = new WriteAfterAbort();
final ImageWriter writer = iter.next().createWriterInstance();
System.out.println("ImageWriter = " + writer);
try {
writeAfterAbort.test(writer);
} catch (Exception e) {
System.err.println("Test failed for \""
+ writer.getOriginatingProvider().getFormatNames()[0]
+ "\" format.");
numFailures++;
}
}
if (numFailures == 0) {
System.out.println("Test passed.");
} else {
throw new RuntimeException("Test failed.");
}
}
示例3: getJPEGTablesReader
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
/**
* Retrieves a JPEG reader which supports native JPEG stream metadata.
*/
private static ImageReader getJPEGTablesReader() {
ImageReader jpegReader = null;
try {
IIORegistry registry = IIORegistry.getDefaultInstance();
Class<?> imageReaderClass =
Class.forName("javax.imageio.spi.ImageReaderSpi");
Iterator<?> readerSPIs =
registry.getServiceProviders(imageReaderClass,
new JPEGSPIFilter(),
true);
if(readerSPIs.hasNext()) {
ImageReaderSpi jpegReaderSPI =
(ImageReaderSpi)readerSPIs.next();
jpegReader = jpegReaderSPI.createReaderInstance();
}
} catch(Exception e) {
// Ignore it ...
}
return jpegReader;
}
示例4: registerSpi
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
private void registerSpi() {
// We will register a new Spi for creating NIO-based ImageInputStreams.
final IIORegistry defaultInstance = IIORegistry.getDefaultInstance();
Iterator<ImageInputStreamSpi> serviceProviders = defaultInstance.getServiceProviders(ImageInputStreamSpi.class, true);
ImageInputStreamSpi toUnorder = null;
if (defaultInstance.getServiceProviderByClass(FileImageInputStreamSpi.class) == null) {
// register only if not already registered
while (serviceProviders.hasNext()) {
ImageInputStreamSpi current = serviceProviders.next();
if (current.getInputClass() == File.class) {
toUnorder = current;
break;
}
}
channelImageInputStreamSpi = new FileImageInputStreamSpi();
defaultInstance.registerServiceProvider(channelImageInputStreamSpi);
if (toUnorder != null) {
// Make the custom Spi to be the first one to be used.
defaultInstance.setOrdering(ImageInputStreamSpi.class, channelImageInputStreamSpi, toUnorder);
}
}
}
示例5: registerSpi
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
/**
* Registers a file image input strwM SPI for image input stream, if none is yet registered.
*/
protected void registerSpi() {
final IIORegistry defaultInstance = IIORegistry.getDefaultInstance();
Iterator<ImageInputStreamSpi> serviceProviders = defaultInstance.getServiceProviders(ImageInputStreamSpi.class, true);
ImageInputStreamSpi toUnorder = null;
if (defaultInstance.getServiceProviderByClass(FileImageInputStreamSpi.class) == null) {
// register only if not already registered
while (serviceProviders.hasNext()) {
ImageInputStreamSpi current = serviceProviders.next();
if (current.getInputClass() == File.class) {
toUnorder = current;
break;
}
}
imageInputStreamSpi = new FileImageInputStreamSpi();
defaultInstance.registerServiceProvider(imageInputStreamSpi);
if (toUnorder != null) {
// Make the custom Spi to be the first one to be used.
defaultInstance.setOrdering(ImageInputStreamSpi.class, imageInputStreamSpi, toUnorder);
}
}
}
示例6: getJPEGTablesReader
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
/**
* Retrieves a JPEG reader which supports native JPEG stream metadata.
*/
private static ImageReader getJPEGTablesReader() {
ImageReader jpegReader = null;
try {
IIORegistry registry = IIORegistry.getDefaultInstance();
Class imageReaderClass =
Class.forName("javax.imageio.spi.ImageReaderSpi");
Iterator readerSPIs =
registry.getServiceProviders(imageReaderClass,
new JPEGSPIFilter(),
true);
if(readerSPIs.hasNext()) {
ImageReaderSpi jpegReaderSPI =
(ImageReaderSpi)readerSPIs.next();
jpegReader = jpegReaderSPI.createReaderInstance();
}
} catch(Exception e) {
// Ignore it ...
}
return jpegReader;
}
示例7: initIIOReadFormats
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
private static void initIIOReadFormats() {
List spis = new ArrayList();
List shortNames = new ArrayList();
ImageIO.scanForPlugins();
IIORegistry registry = IIORegistry.getDefaultInstance();
java.util.Iterator readerspis =
registry.getServiceProviders(ImageReaderSpi.class, false);
while (readerspis.hasNext()) {
// REMIND: there could be more than one non-core plugin for
// a particular format, as is the case for JPEG2000 in the JAI
// IIO Tools package, so we should support that somehow
ImageReaderSpi spi = (ImageReaderSpi)readerspis.next();
String klass = spi.getClass().getName();
String format = spi.getFormatNames()[0].toLowerCase();
String suffix = spi.getFileSuffixes()[0].toLowerCase();
if (suffix == null || suffix.equals("")) {
suffix = format;
}
String shortName;
if (klass.startsWith("com.sun.imageio.plugins")) {
shortName = "core-" + suffix;
} else {
shortName = "ext-" + suffix;
}
spis.add(spi);
shortNames.add(shortName);
}
imageioReaderSpis = new ImageReaderSpi[spis.size()];
imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis);
imageioReadFormatShortNames = new String[shortNames.size()];
imageioReadFormatShortNames =
(String[])shortNames.toArray(imageioReadFormatShortNames);
}
示例8: initIIOWriteFormats
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
private static void initIIOWriteFormats() {
List spis = new ArrayList();
List shortNames = new ArrayList();
ImageIO.scanForPlugins();
IIORegistry registry = IIORegistry.getDefaultInstance();
java.util.Iterator writerspis =
registry.getServiceProviders(ImageWriterSpi.class, false);
while (writerspis.hasNext()) {
// REMIND: there could be more than one non-core plugin for
// a particular format, as is the case for JPEG2000 in the JAI
// IIO Tools package, so we should support that somehow
ImageWriterSpi spi = (ImageWriterSpi)writerspis.next();
String klass = spi.getClass().getName();
String format = spi.getFormatNames()[0].toLowerCase();
String suffix = spi.getFileSuffixes()[0].toLowerCase();
if (suffix == null || suffix.equals("")) {
suffix = format;
}
String shortName;
if (klass.startsWith("com.sun.imageio.plugins")) {
shortName = "core-" + suffix;
} else {
shortName = "ext-" + suffix;
}
spis.add(spi);
shortNames.add(shortName);
}
imageioWriterSpis = new ImageWriterSpi[spis.size()];
imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis);
imageioWriteFormatShortNames = new String[shortNames.size()];
imageioWriteFormatShortNames =
(String[])shortNames.toArray(imageioWriteFormatShortNames);
}
示例9: main
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
public static void main(final String[] args) throws IOException {
final IIORegistry registry = IIORegistry.getDefaultInstance();
final Iterator<ImageWriterSpi> iter = registry.getServiceProviders(
ImageWriterSpi.class, provider -> true, true);
// Validates all supported ImageWriters
while (iter.hasNext()) {
final WriteAfterAbort writeAfterAbort = new WriteAfterAbort();
final ImageWriter writer = iter.next().createWriterInstance();
System.out.println("ImageWriter = " + writer);
writeAfterAbort.test(writer);
}
System.out.println("Test passed");
}
示例10: main
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
final IIORegistry registry = IIORegistry.getDefaultInstance();
final Iterator<ImageWriterSpi> iter =
registry.getServiceProviders(ImageWriterSpi.class,
provider -> true, true);
// Validates all supported ImageWriters
while (iter.hasNext()) {
final ImageWriter writer = iter.next().createWriterInstance();
System.out.println("ImageWriter = " + writer);
test(writer);
}
System.out.println("Test passed");
}
示例11: RegisterPluginTwiceTest
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
public RegisterPluginTwiceTest() throws Exception {
BMPImageReaderSPI BMPSpi = new BMPImageReaderSPI();
BMPImageReaderSPI BMPSpi1 = new BMPImageReaderSPI();
IIORegistry regis = IIORegistry.getDefaultInstance();
boolean res1
= regis.registerServiceProvider(BMPSpi,
javax.imageio.spi.ImageReaderSpi.class);
boolean res2
= regis.registerServiceProvider(BMPSpi1,
javax.imageio.spi.ImageReaderSpi.class);
if(!res1 || res2) {
throw new RuntimeException("Bad returned values for registerServiceProvider");
}
Iterator it = regis.getServiceProviders(Class.forName("javax.imageio.spi.ImageReaderSpi"), true);
int count = 0;
while (it.hasNext()) {
Object o = it.next();
if(o instanceof BMPImageReaderSPI) {
count++;
System.out.println("Found next BMPImageReaderSPI, count = " +count);
}
}
if(count > 1) {
throw new RuntimeException("Too many instances of the BMPImageReaderSPI was registered!");
}
}
示例12: clearImageIORegistry
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
protected void clearImageIORegistry() {
IIORegistry registry = IIORegistry.getDefaultInstance();
Iterator<Class<?>> categories = registry.getCategories();
final ClassLoader webClassLoader = getWebApplicationClassLoader();
ServiceRegistry.Filter classLoaderFilter = provider -> {
//remove all service provider loaded by the current ClassLoader
return webClassLoader.equals(provider.getClass().getClassLoader());
};
while (categories.hasNext()) {
@SuppressWarnings("unchecked")
Class<IIOServiceProvider> category = (Class<IIOServiceProvider>) categories.next();
Iterator<IIOServiceProvider> serviceProviders = registry.getServiceProviders(category,
classLoaderFilter, true);
if (serviceProviders.hasNext()) {
info("removing service provider of category: " + category.getSimpleName());
//copy to list
LinkedList<IIOServiceProvider> serviceProviderList = new LinkedList<>();
while (serviceProviders.hasNext()) {
serviceProviderList.add(serviceProviders.next());
}
for (IIOServiceProvider serviceProvider : serviceProviderList) {
info(" - removing: " + serviceProvider.getDescription(Locale.ROOT));
registry.deregisterServiceProvider(serviceProvider);
}
}
}
}
示例13: main
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
public static void main(String[] args) {
IIOMetadataFormat format = null;
if (args.length == 0 || args[0].equals("javax_imageio_1.0")) {
format = IIOMetadataFormatImpl.getStandardFormatInstance();
} else {
IIORegistry registry = IIORegistry.getDefaultInstance();
Iterator iter = registry.getServiceProviders(ImageReaderSpi.class,
false);
while (iter.hasNext()) {
ImageReaderSpi spi = (ImageReaderSpi)iter.next();
if (args[0].equals
(spi.getNativeStreamMetadataFormatName())) {
System.out.print(spi.getDescription(null));
System.out.println(": native stream format");
format = spi.getStreamMetadataFormat(args[0]);
break;
}
String[] extraStreamFormatNames =
spi.getExtraStreamMetadataFormatNames();
if (extraStreamFormatNames != null &&
Arrays.asList(extraStreamFormatNames).
contains(args[0])) {
System.out.print(spi.getDescription(null));
System.out.println(": extra stream format");
format = spi.getStreamMetadataFormat(args[0]);
break;
}
if (args[0].equals
(spi.getNativeImageMetadataFormatName())) {
System.out.print(spi.getDescription(null));
System.out.println(": native image format");
format = spi.getImageMetadataFormat(args[0]);
break;
}
String[] extraImageFormatNames =
spi.getExtraImageMetadataFormatNames();
if (extraImageFormatNames != null &&
Arrays.asList(extraImageFormatNames).contains(args[0])) {
System.out.print(spi.getDescription(null));
System.out.println(": extra image format");
format = spi.getImageMetadataFormat(args[0]);
break;
}
}
}
if (format == null) {
System.err.println("Unknown format: " + args[0]);
System.exit(0);
}
MetadataFormatPrinter printer = new MetadataFormatPrinter(System.out);
printer.print(format);
}
示例14: main
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
public static void main(String[] args) {
fmts = new Hashtable();
fmts.put("javax_imageio_jpeg_stream_1.0", Boolean.FALSE);
fmts.put("javax_imageio_jpeg_image_1.0", Boolean.FALSE);
fmts.put("javax_imageio_png_1.0", Boolean.FALSE);
fmts.put("javax_imageio_bmp_1.0", Boolean.FALSE);
fmts.put("javax_imageio_wbmp_1.0", Boolean.FALSE);
fmts.put("javax_imageio_gif_stream_1.0", Boolean.FALSE);
fmts.put("javax_imageio_gif_image_1.0", Boolean.FALSE);
IIORegistry registry = IIORegistry.getDefaultInstance();
Iterator iter = registry.getServiceProviders(ImageReaderSpi.class,
false);
while(iter.hasNext()) {
ImageReaderSpi spi = (ImageReaderSpi)iter.next();
String fmt_name;
fmt_name = spi.getNativeStreamMetadataFormatName();
testStreamMetadataFormat(spi, fmt_name);
fmt_name = spi.getNativeImageMetadataFormatName();
testImageMetadataFormat(spi, fmt_name);
String[] fmt_names;
fmt_names = spi.getExtraStreamMetadataFormatNames();
for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
testStreamMetadataFormat(spi, fmt_names[i]);
}
fmt_names = spi.getExtraImageMetadataFormatNames();
for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
testImageMetadataFormat(spi, fmt_names[i]);
}
}
Enumeration keys = fmts.keys();
while (keys.hasMoreElements()) {
String key = (String)keys.nextElement();
boolean val = ((Boolean)fmts.get(key)).booleanValue();
if (!val) {
throw new RuntimeException("Test failed: format " +
key + "is not registered.");
}
}
}
示例15: onRegistration
import javax.imageio.spi.IIORegistry; //导入方法依赖的package包/类
public void onRegistration(ServiceRegistry registry, Class category) {
// run over all ImageWriterSpis and store their formats Alphabetically
IIORegistry imageRegistry = IIORegistry.getDefaultInstance();
Iterator providers = imageRegistry.getServiceProviders(
ImageWriterSpi.class, false);
ExportFileTypeRegistry exportRegistry = ExportFileTypeRegistry.getDefaultInstance(null);
while (providers.hasNext()) {
ImageWriterSpi writerSpi = (ImageWriterSpi) providers.next();
String[] formats = writerSpi.getFileSuffixes();
if ((formats != null) && (formats[0] != null)) {
exportRegistry.add(new ImageExportFileType(writerSpi));
} else {
System.err.println(getClass() + ": Cannot register "
+ writerSpi + " because it has no filesuffixes.");
}
}
/*
// Look for the last ExportFileType so that these ImageExportFileTypes
// are registered neatly behind that one.
ExportFileType previous = null;
Iterator exportTypes = registry.getServiceProviders(
ExportFileType.class, true);
while (exportTypes.hasNext()) {
previous = (ExportFileType) exportTypes.next();
}
// run over all formats and book them as ExportFileTypes
Iterator formats = formatSet.iterator();
while (formats.hasNext()) {
String format = (String) formats.next();
ExportFileType export = ImageExportFileType.getInstance(format);
if (export != null) {
registry.registerServiceProvider(export, ExportFileType.class);
if (previous != null) {
registry.unsetOrdering(ExportFileType.class, previous,
export);
registry.setOrdering(ExportFileType.class,
previous, export);
// System.out.println("Ordering set : "+result);
}
previous = export;
} else {
System.err.println(getClass() + ": Invalid format: " + format
+ ".");
}
}
*/
registry.deregisterServiceProvider(this, category);
}