Java Code Examples for javax.imageio.spi.ServiceRegistry#lookupProviders()
The following examples show how to use
javax.imageio.spi.ServiceRegistry#lookupProviders() .
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: JobValidatorRegistry.java From scheduling with GNU Affero General Public License v3.0 | 6 votes |
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()); } }
Example 2
Source File: SPIServiceRegistry.java From geowave with Apache License 2.0 | 5 votes |
public <T> Iterator<T> load(final Class<T> service) { final Set<ClassLoader> checkset = new HashSet<>(); final Set<ClassLoader> clSet = getClassLoaders(); final Iterator<ClassLoader> loaderIt = clSet.iterator(); return new Iterator<T>() { Iterator<T> spiIT = null; @Override public boolean hasNext() { while (((spiIT == null) || !spiIT.hasNext()) && (loaderIt.hasNext())) { final ClassLoader l = loaderIt.next(); if (checkset.contains(l)) { continue; } checkset.add(l); spiIT = ServiceRegistry.lookupProviders(service, l); } return (spiIT != null) && spiIT.hasNext(); } @Override public T next() { return spiIT.next(); } @Override public void remove() {} }; }
Example 3
Source File: JAIIIOServiceImpl.java From scifio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void writeImage(final OutputStream out, final BufferedImage img, final JPEG2000CodecOptions options) throws IOException, ServiceException { final ImageOutputStream ios = ImageIO.createImageOutputStream(out); final IIORegistry registry = IIORegistry.getDefaultInstance(); final Iterator<J2KImageWriterSpi> iter = ServiceRegistry.lookupProviders( J2KImageWriterSpi.class); registry.registerServiceProviders(iter); final J2KImageWriterSpi spi = registry.getServiceProviderByClass( J2KImageWriterSpi.class); final J2KImageWriter writer = new J2KImageWriter(spi); writer.setOutput(ios); final String filter = options.lossless ? J2KImageWriteParam.FILTER_53 : J2KImageWriteParam.FILTER_97; final IIOImage iioImage = new IIOImage(img, null, null); final J2KImageWriteParam param = (J2KImageWriteParam) writer .getDefaultWriteParam(); param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionType("JPEG2000"); param.setLossless(options.lossless); param.setFilter(filter); param.setCodeBlockSize(options.codeBlockSize); param.setEncodingRate(options.quality); if (options.tileWidth > 0 && options.tileHeight > 0) { param.setTiling(options.tileWidth, options.tileHeight, options.tileGridXOffset, options.tileGridYOffset); } if (options.numDecompositionLevels != null) { param.setNumDecompositionLevels(options.numDecompositionLevels .intValue()); } writer.write(null, iioImage, param); ios.close(); }
Example 4
Source File: JAIIIOServiceImpl.java From scifio with BSD 2-Clause "Simplified" License | 5 votes |
/** Set up the JPEG-2000 image reader. */ private J2KImageReader getReader() { final IIORegistry registry = IIORegistry.getDefaultInstance(); final Iterator<J2KImageReaderSpi> iter = ServiceRegistry.lookupProviders( J2KImageReaderSpi.class); registry.registerServiceProviders(iter); final J2KImageReaderSpi spi = registry.getServiceProviderByClass( J2KImageReaderSpi.class); return new J2KImageReader(spi); }