Refine search
private static void fail(Class<?> service, String msg) throws ServiceConfigurationError { throw new ServiceConfigurationError(service.getName() + ": " + msg); }
private static List<ParameterResolverFactory> findDelegates(ClassLoader classLoader) { Iterator<ParameterResolverFactory> iterator = load(ParameterResolverFactory.class, classLoader == null ? Thread.currentThread().getContextClassLoader() : classLoader).iterator(); //noinspection WhileLoopReplaceableByForEach final List<ParameterResolverFactory> factories = new ArrayList<>(); while (iterator.hasNext()) { try { ParameterResolverFactory factory = iterator.next(); factories.add(factory); } catch (ServiceConfigurationError e) { logger.info( "ParameterResolverFactory instance ignored, as one of the required classes is not available" + "on the classpath: {}", e.getMessage()); } catch (NoClassDefFoundError e) { logger.info("ParameterResolverFactory instance ignored. It relies on a class that cannot be found: {}", e.getMessage()); } } return factories; } }
public static <T> T findService(Class<T> serviceClass) { Iterator<T> services = ServiceLoader.load(serviceClass, serviceClass.getClassLoader()).iterator(); while (services.hasNext()) { try { return services.next(); } catch (ServiceConfigurationError e) { logger.log(Level.DEBUG, e.getLocalizedMessage()); } } return null; }
private final static MojoLogger createInstance() { try { final ServiceLoader<MojoLogger> load = ServiceLoader.load(MojoLogger.class); final Iterator<MojoLogger> iterator = load.iterator(); final MojoLogger singleton = iterator.next(); if (iterator.hasNext()) { throw new ServiceConfigurationError("Too many MojoLogger implementation found"); } return singleton; } catch (final Exception e) { throw new ServiceConfigurationError("MojoLogger implementation not found", e); } } }
List<String> classNames = new ArrayList<String>(); Iterator<ReadingParser> readingParserList = ServiceLoader.load(ReadingParser.class).iterator(); Iterator<WritingParser> service_list2 = ServiceLoader.load(WritingParser.class).iterator(); e.printStackTrace();
private void loadDozerModules(BeanContainer beanContainer, DestBeanBuilderCreator destBeanBuilderCreator, BeanMappingGenerator beanMappingGenerator, PropertyDescriptorFactory propertyDescriptorFactory, DestBeanCreator destBeanCreator) { try { ServiceLoader<DozerModule> services = ServiceLoader.load(DozerModule.class); for (DozerModule module : services) { module.init(); module.init(beanContainer, destBeanCreator, propertyDescriptorFactory); destBeanBuilderCreator.addPluggedStrategies(module.getBeanBuilderCreationStrategies()); beanMappingGenerator.addPluggedFieldDetectors(module.getBeanFieldsDetectors()); propertyDescriptorFactory.addPluggedPropertyDescriptorCreationStrategies(module.getPropertyDescriptorCreationStrategies()); } } catch (ServiceConfigurationError ex) { LOG.error("{}", ex.getMessage()); } } }
private static <K extends Serializable, V extends Cacheable<K>, G extends Serializable> ClusteredBackingCacheEntryStoreSource<K, V, G> load() { for (ClusteredBackingCacheEntryStoreSource<K, V, G> source: ServiceLoader.load(ClusteredBackingCacheEntryStoreSource.class, ClusteredBackingCacheEntryStoreSourceService.class.getClassLoader())) { return source; } throw new ServiceConfigurationError(ClusteredBackingCacheEntryStoreSource.class.getName()); }
static synchronized TaskDescriptor getTaskDescriptor() { if (_identifier != null) { return _identifier; } try { Iterator<TaskDescriptor> identifiers = _loader.iterator(); if (identifiers.hasNext()) { _identifier = identifiers.next(); LOGGER.info("Using TaskDescriptor: " + _identifier.getClass()); while (identifiers.hasNext()) { TaskDescriptor descriptor = identifiers.next(); LOGGER.debug("Discarding TaskDescriptor: {} as its not first one to be loaded: ", descriptor.getClass()); } } else { LOGGER.info("No provider found for TaskDescriptor, falling back to DefaultTaskDescriptor"); _identifier = getDefaultTaskDescriptor(); } } catch (ServiceConfigurationError e) { LOGGER.error("Unable to load provider for TaskDescriptor, falling back to DefaultTaskDescriptor", e.getMessage()); _identifier = getDefaultTaskDescriptor(); } return _identifier; }
@Override protected void initializeProviders() { ServiceLoader<ZoneRulesProvider> loader = ServiceLoader.load(ZoneRulesProvider.class, ZoneRulesProvider.class.getClassLoader()); for (ZoneRulesProvider provider : loader) { try { ZoneRulesProvider.registerProvider(provider); } catch (ServiceConfigurationError ex) { if (!(ex.getCause() instanceof SecurityException)) { throw ex; } } } } }
public Boolean isXMLFormat(String provider) { try { Iterator<Exporter> exporters = loader.iterator(); while (exporters.hasNext()) { Exporter e = exporters.next(); if (e.getProviderName().equals(provider)) { return e.isXMLFormat(); } } } catch (ServiceConfigurationError serviceError) { serviceError.printStackTrace(); } return null; }
public static <T> void loadServices(ServiceRegistry<T> registry) { Iterable<T> iterable = SystemUtils.loadServices(registry.getServiceType()); final Iterator<T> iterator = iterable.iterator(); //noinspection WhileLoopReplaceableByForEach while (iterator.hasNext()) { try { registry.addService(iterator.next()); } catch (ServiceConfigurationError e) { final Logger logger; if (moduleContext != null) { logger = moduleContext.getLogger(); } else { logger = BeamLogManager.getSystemLogger(); } logger.log(Level.WARNING, e.getMessage(), e.getCause()); } } }
System.err.println("INVALID CONFIGURATION: " + ex.getMessage()); Throwables.getRootCause(ex).printStackTrace(); status = EX_CONFIG;
private boolean getNextServiceLoader() { while (nextServiceLoader == null) { try { if (!serviceLoaderIterator.hasNext()) { return false; } nextServiceLoader = serviceLoaderIterator.next(); } catch (final ServiceConfigurationError e) { if (e.getCause() instanceof SecurityException) { // Ignore security exceptions // TODO Log? continue; } throw e; } } return true; }
private static List<ICoercionProvider> loadCoercionProviders() { try { List<ICoercionProvider> providers = loadCoercionProviders( CoercionProviders.class.getClassLoader() ); providers.addAll( loadCoercionProviders( Thread.currentThread().getContextClassLoader() ) ); return providers; } catch( ServiceConfigurationError e ) { e.printStackTrace(); } return Collections.emptyList(); }
public boolean hasNext() { try { return iterator.hasNext(); } catch(ServiceConfigurationError sce) { log.error("proc.bad.config.file", sce.getLocalizedMessage()); throw new Abort(sce); } catch (Throwable t) { throw new Abort(t); } }
public static <T> T findService(Class<T> serviceClass, Matcher<T> matcher) { List<T> matches = new LinkedList<>(); Iterator<T> services = ServiceLoader.load(serviceClass, serviceClass.getClassLoader()).iterator(); while (services.hasNext()) { try { T service = services.next(); if (matcher.matches(service)) { matches.add(service); } } catch (ServiceConfigurationError e) { logger.log(Level.DEBUG, e.getLocalizedMessage()); } } if (matches.size() > 1) { logger.log(Level.WARN, messages.multipleServicesFound(serviceClass, matcher, matches)); } return !matches.isEmpty() ? matches.get(0) : null; }
/** * Returns an instance of the given service interface or class. * The service implementation is loaded using the current thread's context * class loader. * * @throws ServiceConfigurationError if no implementation of the given * service interface or class can be found on the class path. * @see ServiceLoader#load(Class) */ public static <T> T load(final Class<T> service) { try { return ServiceLoader.load(service).iterator().next(); } catch (NoSuchElementException ex) { throw new ServiceConfigurationError(String.format(Locale.ENGLISH, "Could not find an implementation of the service %s on the class path.", service), ex); } }
ServiceLoader.load(FrameworkFactory.class, getClass().getClassLoader()); Iterator<FrameworkFactory> factoryIterator = factoryLoader.iterator(); framework = frameworkFactory.newFramework(Collections.EMPTY_MAP); } catch (ServiceConfigurationError sce) { sce.printStackTrace();
private <T extends SingularExtension> Iterable<T> loadServices(@Nonnull Class<T> extensionTarget) { try { return ServiceLoader.load(extensionTarget); } catch (ServiceConfigurationError e) { getLogger().debug(e.getMessage(), e); } return Collections.emptyList(); }