当前位置: 首页>>代码示例>>Java>>正文


Java ServiceRegistry类代码示例

本文整理汇总了Java中javax.imageio.spi.ServiceRegistry的典型用法代码示例。如果您正苦于以下问题:Java ServiceRegistry类的具体用法?Java ServiceRegistry怎么用?Java ServiceRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceRegistry类属于javax.imageio.spi包,在下文中一共展示了ServiceRegistry类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeTiff

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
/**
 * Writes a buffered image to a TIFF output stream.
 * @param image buffered image to write out as a TIFF
 * @param output output stream to write to
 * @throws IOException If there is an error writing to
 * <code>output</code>.
 */
private void writeTiff(BufferedImage image, OutputStream output)
        throws IOException {
    try (ImageOutputStream ios =
            ImageIO.createImageOutputStream(output)) {
        IIORegistry registry = IIORegistry.getDefaultInstance();
        registry.registerServiceProviders(
                ServiceRegistry.lookupProviders(
                        TIFFImageWriterSpi.class));
        TIFFImageWriterSpi spi = registry.getServiceProviderByClass(
                TIFFImageWriterSpi.class);
        TIFFImageWriter writer = new TIFFImageWriter(spi);
        writer.setOutput(ios);
        writer.write(null, new IIOImage(image, null, null), null);
    }
}
 
开发者ID:glencoesoftware,项目名称:omero-ms-pixel-buffer,代码行数:23,代码来源:TileRequestHandler.java

示例2: getImageTranscoders

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
/**
 * Returns an <code>Iterator</code> containing all currently
 * registered <code>ImageTranscoder</code>s that claim to be
 * able to transcode between the metadata of the given
 * <code>ImageReader</code> and <code>ImageWriter</code>.
 *
 * @param reader an <code>ImageReader</code>.
 * @param writer an <code>ImageWriter</code>.
 *
 * @return an <code>Iterator</code> containing
 * <code>ImageTranscoder</code>s.
 *
 * @exception IllegalArgumentException if <code>reader</code> or
 * <code>writer</code> is <code>null</code>.
 */
public static Iterator<ImageTranscoder>
    getImageTranscoders(ImageReader reader, ImageWriter writer)
{
    if (reader == null) {
        throw new IllegalArgumentException("reader == null!");
    }
    if (writer == null) {
        throw new IllegalArgumentException("writer == null!");
    }
    ImageReaderSpi readerSpi = reader.getOriginatingProvider();
    ImageWriterSpi writerSpi = writer.getOriginatingProvider();
    ServiceRegistry.Filter filter =
        new TranscoderFilter(readerSpi, writerSpi);

    Iterator iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class,
                                        filter, true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageTranscoderIterator(iter);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:40,代码来源:ImageIO.java

示例3: getImageTranscoders

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
/**
 * Returns an {@code Iterator} containing all currently
 * registered {@code ImageTranscoder}s that claim to be
 * able to transcode between the metadata of the given
 * {@code ImageReader} and {@code ImageWriter}.
 *
 * @param reader an {@code ImageReader}.
 * @param writer an {@code ImageWriter}.
 *
 * @return an {@code Iterator} containing
 * {@code ImageTranscoder}s.
 *
 * @exception IllegalArgumentException if {@code reader} or
 * {@code writer} is {@code null}.
 */
public static Iterator<ImageTranscoder>
    getImageTranscoders(ImageReader reader, ImageWriter writer)
{
    if (reader == null) {
        throw new IllegalArgumentException("reader == null!");
    }
    if (writer == null) {
        throw new IllegalArgumentException("writer == null!");
    }
    ImageReaderSpi readerSpi = reader.getOriginatingProvider();
    ImageWriterSpi writerSpi = writer.getOriginatingProvider();
    ServiceRegistry.Filter filter =
        new TranscoderFilter(readerSpi, writerSpi);

    Iterator<ImageTranscoderSpi> iter;
    // Ensure category is present
    try {
        iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class,
                                        filter, true);
    } catch (IllegalArgumentException e) {
        return Collections.emptyIterator();
    }
    return new ImageTranscoderIterator(iter);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:ImageIO.java

示例4: OrderingTest

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
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");
         }

     }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:OrderingTest.java

示例5: SpiTest

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
public SpiTest() {
    testImageReaderSpiConstructor();
    testImageWriterSpiConstructor();

    ServiceRegistry registry = IIORegistry.getDefaultInstance();
    Iterator readers = registry.getServiceProviders(ImageReaderSpi.class,
                                                    false);
    while (readers.hasNext()) {
        ImageReaderSpi rspi = (ImageReaderSpi)readers.next();
        System.out.println("*** Testing " + rspi.getClass().getName());
        testSpi(rspi);
    }

    Iterator writers = registry.getServiceProviders(ImageWriterSpi.class,
                                                    false);
    while (writers.hasNext()) {
        ImageWriterSpi wspi = (ImageWriterSpi)writers.next();
        System.out.println("*** Testing " + wspi.getClass().getName());
        testSpi(wspi);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SpiTest.java

示例6: DeregisterOrderedSpiTest

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
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());
         }
     }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:DeregisterOrderedSpiTest.java

示例7: load

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
public void load() {
    Iterator<JobValidatorService> loadedFactories = ServiceRegistry.lookupProviders(JobValidatorService.class);
    ImmutableMap.Builder<String, JobValidatorService> mapBuilder = new ImmutableMap.Builder();
    while (loadedFactories.hasNext()) {
        try {
            JobValidatorService validator = loadedFactories.next();
            String validatorID = validator.getClass().getCanonicalName();

            logger.debug("Job Validator Factory provider <" + validatorID + "> found");
            mapBuilder.put(validatorID, validator);
        } catch (Exception err) {
            logger.error("Failed to load job validator factory: " + err);
        }
    }
    jobValidators = mapBuilder.build();
    if (logger.isInfoEnabled()) {
        logger.info("[JobValidatorRegistry] job validators registered : " + jobValidators.keySet());
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:20,代码来源:JobValidatorRegistry.java

示例8: onRegistration

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:scifio,项目名称:scifio-jai-imageio,代码行数:26,代码来源:J2KImageReaderSpi.java

示例9: onRegistration

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:scifio,项目名称:scifio-jai-imageio,代码行数:26,代码来源:J2KImageWriterSpi.java

示例10: getImageTranscoders

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
/**
 * Returns an <code>Iterator</code> containing all currently registered <code>ImageTranscoder</code>s that
 * claim to be able to transcode between the metadata of the given <code>ImageReader</code> and
 * <code>ImageWriter</code>.
 * 
 * @param reader
 *            an <code>ImageReader</code>.
 * @param writer
 *            an <code>ImageWriter</code>.
 * 
 * @return an <code>Iterator</code> containing <code>ImageTranscoder</code>s.
 * 
 * @exception IllegalArgumentException
 *                if <code>reader</code> or <code>writer</code> is <code>null</code>.
 */
public static Iterator<ImageTranscoder> getImageTranscoders(ImageReader reader, ImageWriter writer) {
	if (reader == null) {
		throw new IllegalArgumentException("reader == null!");
	}
	if (writer == null) {
		throw new IllegalArgumentException("writer == null!");
	}
	ImageReaderSpi readerSpi = reader.getOriginatingProvider();
	ImageWriterSpi writerSpi = writer.getOriginatingProvider();
	ServiceRegistry.Filter filter = new TranscoderFilter(readerSpi, writerSpi);

	Iterator iter;
	// Ensure category is present
	try {
		iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class, filter, true);
	} catch (IllegalArgumentException e) {
		return new HashSet().iterator();
	}
	return new ImageTranscoderIterator(iter);
}
 
开发者ID:MKLab-ITI,项目名称:multimedia-indexing,代码行数:36,代码来源:ImageIOGreyScale.java

示例11: onRegistration

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
public void onRegistration(ServiceRegistry registry,
                           Class<?> category) {
    if (registered) {
        return;
    }
    registered = true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:WBMPImageReaderSpi.java

示例12: onRegistration

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
public void onRegistration(ServiceRegistry registry,
                           Class<?> category) {
    if (registered) {
        return;
    }

    registered = true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:WBMPImageWriterSpi.java

示例13: main

import javax.imageio.spi.ServiceRegistry; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {

        final ArrayList<Class<?>> services = new ArrayList<Class<?>>();
        services.add(ImageInputStreamSpi.class);

        final ServiceRegistry reg = new ServiceRegistry(services.iterator());

        //create new thread for Registerer and Consumer Class
        Thread registerer = new Thread(new Registerer(reg));
        Thread consumer = new Thread(new Consumer(reg));

        //run both registerer and consumer thread parallely
        registerer.start();
        consumer.start();
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:ServiceRegistrySyncTest.java


注:本文中的javax.imageio.spi.ServiceRegistry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。