本文整理汇总了Java中javax.imageio.spi.ServiceRegistry.lookupProviders方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceRegistry.lookupProviders方法的具体用法?Java ServiceRegistry.lookupProviders怎么用?Java ServiceRegistry.lookupProviders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.imageio.spi.ServiceRegistry
的用法示例。
在下文中一共展示了ServiceRegistry.lookupProviders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
示例2: getLogicalTimeFactory
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
/**
* Locates and constructs a LogicalTimeFactory matching the specified name.
* Each federation chooses its implementation by passing the appropriate name
* to createFederationExecution.
* If the supplied name is the empty string, the HLAfloat64TimeFactory is
* returned. If the supplied implementation name does not match any name
* supported by the library, then a NULL pointer is returned.
*
* @param name
* @return
*/
public static LogicalTimeFactory getLogicalTimeFactory(String name)
{
if (name.equals("")) {
name = "HLAfloat64Time";
}
Iterator<LogicalTimeFactory> i = ServiceRegistry.lookupProviders(LogicalTimeFactory.class);
while (i.hasNext()) {
LogicalTimeFactory logicalTimeFactory = i.next();
if (logicalTimeFactory.getName().equals(name)) {
return logicalTimeFactory;
}
}
return null;
}
示例3: getAvailableLogicalTimeFactories
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
public static Set<LogicalTimeFactory> getAvailableLogicalTimeFactories()
{
Iterator<LogicalTimeFactory> i = ServiceRegistry.lookupProviders(LogicalTimeFactory.class);
Set<LogicalTimeFactory> factories = new HashSet<LogicalTimeFactory>();
while (i.hasNext()) {
LogicalTimeFactory logicalTimeFactory = i.next();
factories.add(logicalTimeFactory);
}
return factories;
}
示例4: getRtiFactory
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
public static RtiFactory getRtiFactory(String name)
throws
RTIinternalError
{
Iterator<RtiFactory> i = ServiceRegistry.lookupProviders(RtiFactory.class);
while (i.hasNext()) {
RtiFactory rtiFactory = i.next();
if (rtiFactory.rtiName().equals(name)) {
return rtiFactory;
}
}
throw new RTIinternalError("Cannot find factory matching " + name);
}
示例5: getAvailableRtiFactories
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
public static Set<RtiFactory> getAvailableRtiFactories()
{
Iterator<RtiFactory> i = ServiceRegistry.lookupProviders(RtiFactory.class);
Set<RtiFactory> factories = new HashSet<RtiFactory>();
while (i.hasNext()) {
RtiFactory rtiFactory = i.next();
factories.add(rtiFactory);
}
return factories;
}
示例6: newFactory
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
@Override
protected GeneralDBConnectionFactory newFactory(DatabaseMetaData metaData) throws SQLException {
String dbn = metaData.getDatabaseProductName();
String dbv = metaData.getDatabaseProductVersion();
GeneralDBConnectionFactory factory;
Iterator<GeneralDBProvider> providers;
providers = ServiceRegistry.lookupProviders(GeneralDBProvider.class);
while (providers.hasNext()) {
GeneralDBProvider provider = providers.next();
factory = provider.createRdbmsConnectionFactory(dbn, dbv);
if (factory != null)
return factory;
}
return new PostGISConnectionFactory();
}
示例7: newFactory
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
@Override
protected GeneralDBConnectionFactory newFactory(DatabaseMetaData metaData) throws SQLException {
String dbn = metaData.getDatabaseProductName();
String dbv = metaData.getDatabaseProductVersion();
GeneralDBConnectionFactory factory;
Iterator<MonetDBProvider> providers;
providers = ServiceRegistry.lookupProviders(MonetDBProvider.class);
while (providers.hasNext()) {
MonetDBProvider provider = providers.next();
factory = provider.createRdbmsConnectionFactory(dbn, dbv);
if (factory != null)
return factory;
}
return new MonetDBConnectionFactory();
}
示例8: load
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
public <T> Iterator<T> load(
final Class<T> service ) {
final Set<ClassLoader> checkset = new HashSet<ClassLoader>();
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 = (Iterator<T>) ServiceRegistry.lookupProviders(
service,
l);
}
return spiIT != null && spiIT.hasNext();
}
@Override
public T next() {
return (T) spiIT.next();
}
@Override
public void remove() {}
};
}
示例9: testGuiceWorksInOSGiContainer
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
public void testGuiceWorksInOSGiContainer()
throws Throwable {
// ask framework to clear cache on startup
Properties properties = new Properties();
properties.setProperty("org.osgi.framework.storage", BUILD_TEST_DIR + "/bundle.cache");
properties.setProperty("org.osgi.framework.storage.clean", "onFirstInit");
// test each available OSGi framework in turn
Iterator<FrameworkFactory> f = ServiceRegistry.lookupProviders(FrameworkFactory.class);
while (f.hasNext()) {
Framework framework = f.next().newFramework(properties);
framework.start();
BundleContext systemContext = framework.getBundleContext();
// load all the necessary bundles and start the OSGi test bundle
/*if[AOP]*/
systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/aopalliance.jar");
/*end[AOP]*/
systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/javax.inject.jar");
systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/guava.jar");
systemContext.installBundle("reference:file:" + GUICE_JAR);
systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/osgitests.jar").start();
framework.stop();
}
}
示例10: writeImage
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
@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();
}
示例11: getReader
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
/** 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);
}
示例12: testGuiceWorksInOSGiContainer
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
public void testGuiceWorksInOSGiContainer()
throws Throwable {
// ask framework to clear cache on startup
Properties properties = new Properties();
properties.setProperty("org.osgi.framework.storage", BUILD_TEST_DIR + "/bundle.cache");
properties.setProperty("org.osgi.framework.storage.clean", "onFirstInit");
// test each available OSGi framework in turn
Iterator<FrameworkFactory> f = ServiceRegistry.lookupProviders(FrameworkFactory.class);
while (f.hasNext()) {
Framework framework = f.next().newFramework(properties);
framework.start();
BundleContext systemContext = framework.getBundleContext();
// load all the necessary bundles and start the OSGi test bundle
/*if[AOP]*/
systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/aopalliance.jar");
/*end[AOP]*/
systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/javax.inject.jar");
systemContext.installBundle("reference:file:" + GUICE_JAR);
systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/osgitests.jar").start();
framework.stop();
}
}
示例13: get
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
/**
* aliases for the Socket Factories provided with ProActive
*/
public static PAMRSocketFactorySPI get() {
if (!PAMRConfig.PA_PAMR_SOCKET_FACTORY.isSet()) {
// the user wants the default
return getDefaultSocketFactory();
}
String socketFactory = PAMRConfig.PA_PAMR_SOCKET_FACTORY.getValue();
Iterator<PAMRSocketFactorySPI> socketFactories = ServiceRegistry
.lookupProviders(PAMRSocketFactorySPI.class);
try {
while (socketFactories.hasNext()) {
PAMRSocketFactorySPI factory = socketFactories.next();
if (socketFactory.equals(factory.getAlias()) ||
socketFactories.equals(factory.getClass().getName())) {
if (logger.isDebugEnabled()) {
logger.debug("Installing the " + factory.getAlias() + " (" +
factory.getClass().getName() + ") socket factory for message routing");
}
return factory;
}
}
} catch (Error e) {
logger.warn("Failed to load a service provider for " + PAMRSocketFactorySPI.class.getName(), e);
}
logger
.warn(socketFactory +
" is neither an alias for a socket factory provided with ProActive,\n" +
" nor a class name for a socket factory which could be found using the service provider mechanisms.\n" +
" Will instantiate the default, plain socket factory.");
return getDefaultSocketFactory();
}
示例14: lookup
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
public static <T extends ServiceProvider> Iterator<T> lookup(Class<T> clazz) {
ClassLoader cl = ClassLoader.getSystemClassLoader();
// return java.util.ServiceLoader.load(clazz, cl).iterator(); // jse 6
/// return (Iterator<T>)sun.misc.Service.providers(clazz, cl); // jse 5 sun
return ServiceRegistry.lookupProviders(clazz, cl); // jse version compatibility hack !!!
}
示例15: createInstance
import javax.imageio.spi.ServiceRegistry; //导入方法依赖的package包/类
/**
* @param fileName
* name of the configuration file
* @return configuration factory which is able to process specified
* configuration file or <code>null</code> otherwise.
* @throws IllegalArgumentException
* if <code>fileName</code> is illegal
* @see #ILLEGAL_FILE_NAMES
*/
public static final AbstractConfigurationFactory createInstance(final String fileName) {
if (ILLEGAL_FILE_NAMES.contains(fileName)) {
throw new IllegalArgumentException(fileName);
}
Iterator<AbstractConfigurationFactory> providers = ServiceRegistry.lookupProviders(AbstractConfigurationFactory.class);
while (providers.hasNext()) {
AbstractConfigurationFactory configurationFactory = providers.next();
if (configurationFactory.acceptsFileType(getFileExtension(fileName))) {
try {
// we need a configuration created using constructor with file name
final Constructor<?extends AbstractConfigurationFactory> constructor = configurationFactory.getClass().getConstructor(String.class);
return constructor.newInstance(fileName);
} catch (Exception e) {
// just wrap a bunch of different exceptions into a single
throw new ArchitectureException(e);
}
}
}
return null;
}