Loads service providers for the {@code klass} service using {@link ServiceLoader}.
353490
@VisibleForTesting
  public static <T> Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl) {
    Iterable<T> i = ServiceLoader.load(klass, cl);
    // Attempt to load using the context class loader and ServiceLoader.
    // This allows frameworks like http://aries.apache.org/modules/spi-fly.html to plug in.
    if (!i.iterator().hasNext()) {
      i = ServiceLoader.load(klass);
    }
    return i;
  }
951740
public <T extends StoreConfigurationBuilder<?, ?>> T addStore(Class<T> klass) {
      try {
         Constructor<T> constructor = klass.getDeclaredConstructor(PersistenceConfigurationBuilder.class);
         T builder = constructor.newInstance(this);
         this.stores.add(builder);
         return builder;
      } catch (Exception e) {
         throw new CacheConfigurationException("Could not instantiate loader configuration builder '" + klass.getName()
               + "'", e);
      }
   }
705312
@VisibleForTesting
  public static <T> Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl) {
    return ServiceProviders.getCandidatesViaServiceLoader(klass, cl);
  }
277699
private static ClassLoader[] getClassLoaders(ClassLoader classLoader) {
		return new ClassLoader[] { classLoader, Thread.currentThread().getContextClassLoader(), ClassLoaderUtils.class.getClassLoader(),
				systemClassLoader };
	}
816651
static <T,X extends T> T createProviderForClass(final PluggableService<T> service, final Class<X> cls) throws PluginException,
            ProviderCreationException {
        debug("Try loading provider " + cls.getName());
        if(!(service instanceof JavaClassProviderLoadable)){
            return null;
        }
        JavaClassProviderLoadable<T> loadable = (JavaClassProviderLoadable<T>) service;
        final Plugin annotation = getPluginMetadata(cls);

        final String pluginname = annotation.name();

        if (!loadable.isValidProviderClass(cls)) {
            throw new PluginException("Class " + cls.getName() + " was not a valid plugin class for service: " 
                    + service.getName() + ". Expected class " + cls.getName() + ", with a public constructor with no parameter");
        }
        debug("Succeeded loading plugin " + cls.getName() + " for service: " + service.getName());
        return loadable.createProviderInstance(cls, pluginname);
    }
202804
private static <T> Collection<String> loadClasses(final ClassLoader classLoader, final Class<? extends T> service) {
		String name = SERVICE_PREFIX + service.getName();
		Enumeration<URL> urls;
		try {
			urls = classLoader.getResources(name);
		} catch (IOException ex) {
			InternalLogger.log(Level.ERROR, "Failed loading services from '" + name + "'");
			return Collections.emptyList();
		}

		Collection<String> classes = new ArrayList<String>();

		while (urls.hasMoreElements()) {
			URL url = urls.nextElement();
			BufferedReader reader = null;

			try {
				reader = new BufferedReader(new InputStreamReader(url.openStream(), "utf-8"));
				for (String line = reader.readLine(); line != null; line = reader.readLine()) {
					line = line.trim();
					if (line.length() > 0 && line.charAt(0) != '#' && !classes.contains(line)) {
						classes.add(line);
					}
				}
			} catch (IOException ex) {
				InternalLogger.log(Level.ERROR, "Failed reading service resource '" + url + "'");
			} finally {
				if (reader != null) {
					try {
						reader.close();
					} catch (IOException ex) {
						// Ignore
					}
				}
			}
		}

		return classes;
	}
289508
private static final void loadResources(final CClassLoader loader,
			final List URLList, final String resourceName) {
		final List l = loader.getPrivateResource(resourceName);

		if (l != null) {
			URLList.addAll(l);
		}

		final List loaderList = new ArrayList();

		for (final Iterator it = loader.childrenMap.entrySet().iterator(); it
				.hasNext();) {
			final Entry entry = (Entry) it.next();
			loaderList.add(entry.getValue());
		}

		for (int i = 0; i < loaderList.size(); i++) {
			final Object element = loaderList.get(i);
			final CClassLoader child = (CClassLoader) element;
			CClassLoader.loadResources(child, URLList, resourceName);
		}
	}
738649
public static Config load(final ClassLoader loader) {
        final ConfigParseOptions withLoader = ConfigParseOptions.defaults().setClassLoader(loader);
        return ConfigImpl.computeCachedConfig(loader, "load", new Callable<Config>() {
            @Override
            public Config call() {
                return load(loader, defaultApplication(withLoader));
            }
        });
    }
653249
public synchronized void reload() {
    for (PropertyConfig.Provider provider : providers)
      add(provider.getConfig());
    multicast();
  }

  /**
   * <p>
   * Setter for the field <code>providers</code>.
   * </p>
   *
   * @param providers a {@link java.util.List} object.
   */
  public void setProviders(List<PropertyConfig.Provider> providers) {
    this.providers = providers;
  }
31373
private void addVetoedClasses(String serviceName, String serviceImpls, ClassLoader classLoader,
        Map<Class<?>, Set<Class<?>>> vetoed) {
        try {
            final Class<?> serviceClass = classLoader.loadClass(serviceName);
            final Set<Class<?>> classes = loadVetoedServiceImpl(serviceImpls, classLoader);

            final Set<Class<?>> registeredVetoedClasses = vetoed.get(serviceClass);
            if (registeredVetoedClasses == null) {
                vetoed.put(serviceClass, classes);
            } else {
                registeredVetoedClasses.addAll(classes);
            }
        } catch (ClassNotFoundException e) {
            // ignores since this is a veto that it is not applicable
        }
    }
909347
public static <T> Class<T> loadClass(String className, ResourceLoader resourceLoader) {
        try {
            return cast(resourceLoader.classForName(className));
        } catch (ResourceLoadingException e) {
            return null;
        } catch (SecurityException e) {
            return null;
        }
    }
724680
public static Config load(final ClassLoader loader) {
        return ConfigImpl.computeCachedConfig(loader, "load", new Callable<Config>() {
            @Override
            public Config call() {
                return loadDefaultConfig(loader);
            }
        });
    }
586428
private void autoLoadClasses()
	{
		Set<ASMData> classes = ImmutableSortedSet.copyOf(	Ordering.natural().onResultOf(ASMData::getClassName),
															asmDataTable.getAll(AutoLoad.class.getName()));

		Set<ASMData> clientClasses = asmDataTable.getAll(SideOnly.class.getName());

		for (ASMData data : classes)
		{
			try
			{
				//don't load client classes on server.
				if (!isClient() && isClientClass(data.getClassName(), clientClasses))
					continue;

				Class<?> clazz = Class.forName(data.getClassName());
				AutoLoad anno = clazz.getAnnotation(AutoLoad.class);
				if (anno.value())
					clazz.newInstance();
			}
			catch (Exception e)
			{
				MalisisCore.log.error("Could not autoload {}.", data.getClassName(), e);
			}
		}
	}
817781
public ConfigurationBuilder addClassLoaders(Collection<ClassLoader> classLoaders) {
        return addClassLoaders(classLoaders.toArray(new ClassLoader[classLoaders.size()]));
    }
1123015
public static <T> List<T> loadAll(
      Class<T> klass,
      Iterable<Class<?>> hardCodedClasses,
      ClassLoader classLoader,
      PriorityAccessor<T> priorityAccessor) {
    return ServiceProviders.loadAll(klass, hardCodedClasses, classLoader, priorityAccessor);
  }
672472
public <T> RestBuilder addProvider(Class<T> clazz, Class<? extends ContextProvider<T>> provider) {

		Assert.notNull(clazz, "Missing provided class type!");
		Assert.notNull(provider, "Missing context provider!");
		registeredProviders.put(clazz, provider);
		return this;
	}
808434
public static <T> PluggableProviderService<T> getPluginProviderService(
        Class<T> serviceType,
        String serviceName,
        ServiceProviderLoader loader
    )
    {
        for (PluginProviderServices pluginProviderServices : pluginProviderServiceLoader) {
            if (pluginProviderServices.hasServiceFor(serviceType, serviceName)) {
                return pluginProviderServices.getServiceProviderFor(serviceType, serviceName, loader);
            }
        }
        return null;
    }