The service loader works lazy, however, we want to have all implementations constructed.
Retrieve all implementations from the service loader and return an read-only iterable
backed by an array.
424124
@SuppressWarnings("unchecked")
  private static <S> Iterable<S> constructAllServiceImplementations(Class<S> _service) {
    ClassLoader cl = CacheManagerImpl.class.getClassLoader();
    ArrayList<S> li = new ArrayList<S>();
    Iterator<S> it = ServiceLoader.load(_service, cl).iterator();
    while (it.hasNext()) {
      try {
        li.add(it.next());
      } catch (ServiceConfigurationError ex) {
        Log.getLog(CacheManager.class.getName()).debug("Error loading service '" + _service + "'", ex);
      }
    }
    final S[] a = (S[]) Array.newInstance(_service, li.size());
    li.toArray(a);
    return new Iterable<S>() {
      public Iterator<S> iterator() {
        return new Iterator<S>() {
          private int pos = 0;
          public boolean hasNext() {
            return pos < a.length;
          }
          public S next() {
            return a[pos++];
          }
          public void remove() {
            throw new UnsupportedOperationException();
          }
        };
      }
    };
  }
462437
def loadstore(self, addrs, length=1):
        
        if not isinstance(addrs, Iterable):
            raise ValueError("addr must be iteratable")

        self.first_level.loadstore(addrs, length=length)
1197591
@Override
    public <T extends WindupVertexFrame> Iterable<T> findAll(Class<T> clazz)
    {
        return service(clazz).findAll();
    }
720907
@Override
    public <TResult> Lazy<Map<String, TResult>> load(Class<TResult> clazz, Collection<String> ids) {
        return _session.lazyLoadInternal(clazz, ids.toArray(new String[0]), _includes.toArray(new String[0]), null);
    }
1017540
private synchronized static void loadAll() throws DaoManagerException {
		if (setImpl ==null) {
			long implLastModifiedTime=impl.getLastModified();
				
			if (lastModified<implLastModifiedTime){
				Map<String,PropertyDescriptor> staticValues=impl.getAll();
				// to avoid reading while cleaning
				synchronized (cache) {
					cache.clear();
					cache.putAll(staticValues);
				}
				lastModified=System.currentTimeMillis();
				notifyPropertiesChangedListers(lastModified);	
			}
		} else {
			long implLastModifiedTime=impl.getLastModified();
			long setImplLastModifiedTime=setImpl.getLastModified();
		
			if (lastModified<implLastModifiedTime || lastModified<setImplLastModifiedTime){
				Map<String,PropertyDescriptor> staticValues=impl.getAll();
				Map<String,PropertyDescriptor> dynamicValues=setImpl.getAll();
				// to avoid reading while cleaning
				synchronized (cache) {
					cache.clear();
					cache.putAll(staticValues);
					cache.putAll(dynamicValues);
				}
				lastModified=System.currentTimeMillis();
				notifyPropertiesChangedListers(lastModified);
			}
		}
	}
1298973
@Override
  public Iterator<Reader> iterator() {
    Collection<Object> newCollection = new ArrayList<Object>();
    for (Object o : c) {
      if (o instanceof Reader) {
        String name = o.toString()+".tmp";
        File tmpFile;
        try {
          tmpFile = File.createTempFile(name,"");
        } catch (Exception e) {
          throw new RuntimeException(e.getMessage());
        }
        tmpFile.deleteOnExit();
        StringUtils.printToFile(tmpFile, IOUtils.slurpReader((Reader)o),
                                false, false, enc);
        newCollection.add(tmpFile);
      } else {
        newCollection.add(o);
      }
    }
    c = newCollection;
    return new ReaderIterator();
  }
863337
public static <T> Collection<T> loadEnriched(final Class<T> serviceClass)
   {
      try
      {
         Collection<T> services = new ArrayList<T>();
         ServiceEnricher origin = null;

         if (!NonEnriching.class.isAssignableFrom(serviceClass))
         {
            if (enricherLoader == null)
            {
               enricherLoader = java.util.ServiceLoader
                        .load(ServiceEnricher.class);
            }

            for (ServiceEnricher enricher : enricherLoader)
            {
               services = enricher.produce(serviceClass);
               if (services == null)
               {
                  services = new ArrayList<T>();
               }
               if (!services.isEmpty())
               {
                  origin = enricher;
                  break;
               }
            }
         }

         if (services.isEmpty())
         {
            Constructor<? extends T> constructor = serviceClass.getDeclaredConstructor();
            constructor.setAccessible(true);
            services.add(constructor.newInstance());
         }

         if (!NonEnriching.class.isAssignableFrom(serviceClass))
         {
            for (ServiceEnricher enricher : enricherLoader)
            {
               if (!enricher.equals(origin))
               {
                  for (T service : services) {
                     enricher.enrich(service);
                  }
               }
            }
         }

         return services;
      }
      catch (NoClassDefFoundError e)
      {
         throw new RuntimeException("Could not instantiate service class " + serviceClass.getName(), e);
      }
      catch (InvocationTargetException e)
      {
         throw new RuntimeException("Error instantiating " + serviceClass, e.getCause());
      }
      catch (IllegalArgumentException e)
      {
         throw new RuntimeException("Error instantiating " + serviceClass, e);
      }
      catch (InstantiationException e)
      {
         throw new RuntimeException("Error instantiating " + serviceClass, e);
      }
      catch (IllegalAccessException e)
      {
         throw new RuntimeException("Error instantiating " + serviceClass, e);
      }
      catch (SecurityException e)
      {
         throw new RuntimeException("Error instantiating " + serviceClass, e);
      }
      catch (NoSuchMethodException e)
      {
         throw new RuntimeException("Error instantiating " + serviceClass, e);
      }
   }
1327081
@SuppressWarnings("javadoc")
    public static <T> T getSingleService(Class<T> serviceInterface) throws IllegalStateException {
        // Cached single service values are derived from the values cached when checking
        // for multiple services
        T rval = null;
        Set<T> services = getServices(serviceInterface);
        
        if (services.size() > 1) {
            throw new IllegalStateException("Multiple implementations found of " + serviceInterface); //$NON-NLS-1$
        } else if (!services.isEmpty()) {
            rval = services.iterator().next();
        }
        return rval;
    }
1353590
def get_all():
    '''
    
    '''
    (enabled_services, disabled_services) = _get_service_list(include_enabled=True,
                                                              include_disabled=True)
    enabled_services.update(dict([(s, []) for s in disabled_services]))
    return odict.OrderedDict(enabled_services)
871592
public static ClassLoader[] getClassLoaders(ClassLoader... classLoaders) {

		if (classLoaders != null && classLoaders.length > 0) {
			return classLoaders;
		}

		final ClassLoader ctxClassLoader = Thread.currentThread()
				.getContextClassLoader();
		final ClassLoader staticClassLoader = ClassLoaderUtils.class
				.getClassLoader();

		if (ctxClassLoader == null) {
			if (staticClassLoader == null) {
				return new ClassLoader[] {};
			} else {
				return new ClassLoader[] { staticClassLoader };
			}
		} else {
			if (staticClassLoader == null) {
				return new ClassLoader[] { ctxClassLoader };
			} else {
				return new ClassLoader[] { ctxClassLoader, staticClassLoader };
			}
		}
	}
433209
def utils(opts, whitelist=None, context=None, proxy=proxy):
    '''
    
    '''
    return LazyLoader(
        _module_dirs(opts, 'utils', ext_type_dirs='utils_dirs'),
        opts,
        tag='utils',
        whitelist=whitelist,
        pack={'__context__': context, '__proxy__': proxy or {}},
    )
1209593
public static Class[] getImplementorClasses( Class interfaceType )
    {
        String interfaceName = interfaceType.getName();
        ArrayList/*< Class >*/ classes = new ArrayList/*< Class >*/();
        ClassLoader classLoader = getClassLoader();
        
        try
        {
            Enumeration e = classLoader.getResources( "META-INF/services/" + interfaceName );
            
            while ( e.hasMoreElements() )
            {
                URL url = ( URL ) e.nextElement();
                
                if ( _log.isTraceEnabled() )
                {
                    _log.trace( "Found implementor entry for interface " + interfaceName + " at " + url );
                }
                
                InputStream is = null;
                String className = null;
                
                try
                {
                    is = url.openStream();
                    BufferedReader reader = new BufferedReader( new InputStreamReader( is ) );
                    className = reader.readLine().trim();
                    Class implementorClass = loadImplementorClass( className, interfaceType, classLoader );
                    if ( implementorClass != null ) classes.add( implementorClass );
                }
                catch ( IOException ioe )
                {
                    _log.error( "Could not read implementor class entry at + " + url );
                }
                finally
                {
                    if ( is != null ) is.close();
                }
            }
        }
        catch ( IOException e )
        {
            _log.error( "Could not discover implementors for " + interfaceName, e );
        }
        
        return ( Class[] ) classes.toArray( new Class[0] );
    }
1031937
public static <T, K, S, X extends Collection<T>> X loadNToOne(X list,
			Function<T, K> keyGetter,
			Function<Collection<K>, Collection<S>> loader,
			Function<S, K> loadedKeyGetter, BiConsumer<T, S> match) {
		if (list == null || list.size() == 0)
			return list;

		Set<K> keys = toSet(list, keyGetter);
		if (keys == null || keys.size() == 0)
			return list;

		Collection<S> subs = loader.apply(keys);
		if (subs == null || subs.size() == 0)
			return list;

		HashMap<K, S> map = toHashMap(subs, loadedKeyGetter);
		for (T item : list) {
			K key = keyGetter.apply(item);
			if (key == null)
				continue;

			S sub = map.get(key);
			if (sub == null)
				continue;
			match.accept(item, sub);
		}

		return list;
	}
1232346
void loadAdditionalServices(ServiceRegistry registry) {
        for (ResourceLoader loader : getResourceLoaders()) {
            for (Metadata<Service> metadata : ServiceLoader.load(Service.class, loader)) {
                Service service = metadata.getValue();
                for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<>())) {
                    Services.put(registry, serviceInterface, service);
                }
            }
        }
    }
454165
public static <T> Iterable<T> load(Class<T> serviceType) {
    try {
      BundleContext coreBundle = EhcacheActivator.getCoreBundle();
      return coreBundle.getServiceReferences(serviceType, null).stream().map(coreBundle::getService).collect(toList());
    } catch (InvalidSyntaxException e) {
      throw new AssertionError(e);
    }
  }
1246985
@Override
    public <T> List<T> getServices(final Class<T> serviceType) {
        @SuppressWarnings("unchecked")
        List<T> found = (List<T>) servicesLoaded.get(serviceType);
        if (found != null) {
            return found;
        }

        return loadServices(serviceType);
    }
879811
@SuppressWarnings("unchecked")
    public <T> List<T> readListOf(Class<T> type) throws IOException
    {
        if (_parser.isExpectedStartArrayToken()) {
            return (List<T>) new CollectionReader(List.class, _readerLocator.findReader(type)).read(this, _parser);
        }
        if (_parser.hasToken(JsonToken.VALUE_NULL)) {
            return null;
        }
        throw JSONObjectException.from(_parser,
                "Can not read a List: expect to see START_ARRAY ('['), instead got: "+ValueReader._tokenDesc(_parser));
    }