Load all component annotations and register them as components.

@param classLoader the class loader to use to look for component definitions
771328
public void initialize(ClassLoader classLoader)
    {
        ComponentAnnotationLoader loader = new ComponentAnnotationLoader();
        loader.initialize(this, classLoader);

        // Extension point to allow component to manipulate ComponentManager initialized state.
        try {
            List<ComponentManagerInitializer> initializers = this.getInstanceList(ComponentManagerInitializer.class);
            for (ComponentManagerInitializer initializer : initializers) {
                initializer.initialize(this);
            }
        } catch (ComponentLookupException e) {
            // Should never happen
            this.logger.error("Failed to lookup ComponentManagerInitializer components", e);
        }
    }
378872
private static void registerAllTypeFactories(GsonBuilder gsonBuilder) {
        ServiceLoader<TypeAdapterFactory> loader = ServiceLoader.load(TypeAdapterFactory.class);
        for (TypeAdapterFactory typeFactory : loader) {
            if (logger.isLoggable(Level.FINE)) {
                logger.fine("Add gson type factory: " + typeFactory.getClass().getName());
            }
            gsonBuilder.registerTypeAdapterFactory(typeFactory);
        }
    }
1318718
@SuppressWarnings("unchecked")
	public T newInstance(ClassLoader classLoader) {
		try {
			return (T) compile(classLoader).getConstructor(Object[].class)
					// Because Constructor.newInstance(Object... initargs), we need to load
					// references into a new Object[], otherwise it cannot be compiled.
					.newInstance(new Object[] {references});
		} catch (Exception e) {
			throw new RuntimeException(
				"Could not instantiate generated class '" + className + "'", e);
		}
	}
724680
public static Config load(final ClassLoader loader) {
        return ConfigImpl.computeCachedConfig(loader, "load", new Callable<Config>() {
            @Override
            public Config call() {
                return loadDefaultConfig(loader);
            }
        });
    }
66959
@SuppressWarnings("static-method")
	protected ClassLoader createClassLoader(Iterable<File> jarsAndFolders, ClassLoader parentClassLoader) {
		return new URLClassLoader(Iterables.toArray(Iterables.transform(jarsAndFolders, from -> {
			try {
				final URL url = from.toURI().toURL();
				assert url != null;
				return url;
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}), URL.class), parentClassLoader);
	}
410008
public static <T> Class<T> loadClass(String className, ClassLoader classloader) {
        if(className == null) {
            throw new IllegalArgumentException("className cannot be null");
        }

        if(classloader == null) {
            throw new IllegalArgumentException("classloader cannot be null");
        }

        try {
            return (Class<T>) Class.forName(className, false, classloader);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
277699
private static ClassLoader[] getClassLoaders(ClassLoader classLoader) {
		return new ClassLoader[] { classLoader, Thread.currentThread().getContextClassLoader(), ClassLoaderUtils.class.getClassLoader(),
				systemClassLoader };
	}
40578
public void addLoader(I_CmsResourceLoader loader) throws CmsConfigurationException {

        // check if new loaders can still be added
        if (m_frozen) {
            throw new CmsConfigurationException(Messages.get().container(Messages.ERR_NO_CONFIG_AFTER_STARTUP_0));
        }

        // add the loader to the internal list of loaders
        int pos = loader.getLoaderId();
        if (pos >= m_loaders.length) {
            I_CmsResourceLoader[] buffer = new I_CmsResourceLoader[pos * 2];
            System.arraycopy(m_loaders, 0, buffer, 0, m_loaders.length);
            m_loaders = buffer;
        }
        m_loaders[pos] = loader;
        m_loaderList.add(loader);
        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(
                Messages.get().getBundle().key(
                    Messages.INIT_ADD_LOADER_2,
                    loader.getClass().getName(),
                    new Integer(pos)));
        }
    }
557322
public static <T> List<T> load(ClassLoader classLoader, Class<T> serviceType) {
        List<T> foundServices = new ArrayList<>();
        Iterator<T> iterator = ServiceLoader.load(serviceType, classLoader).iterator();

        while (checkHasNextSafely(iterator)) {
            try {
                T item = iterator.next();
                foundServices.add(item);
                LOGGER.debug(String.format("Found %s [%s]", serviceType.getSimpleName(), item.toString()));
            } catch (ServiceConfigurationError e) {
                LOGGER.trace("Can't find services using Java SPI", e);
                LOGGER.error(e.getMessage());
            }
        }
        return foundServices;
    }
875203
public static void preload(@NonNull ClassLoader classLoader) {
      Resource r = new ClasspathResource("META-INF/preload.classes", classLoader);
      if (r.exists()) {
         try {
            r.readLines().forEach(ReflectionUtils::getClassForNameQuietly);
         } catch (IOException e) {
            e.printStackTrace();
         }
      }
   }
700851
protected function _loadComponents()
    {
        if (empty($this->components)) {
            return;
        }
        $registry = $this->components();
        $components = $registry->normalizeArray($this->components);
        foreach ($components as $properties) {
            $this->loadComponent($properties['class'], $properties['config']);
        }
    }
62121
private void checkAnnotationClasses(ClassLoader loader) // d676633
    {
        boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isDebugEnabled())
            Tr.entry(tc, "checkAnnotationClasses: " + loader);

        // All EJBs in an application share the same class loader.  Only check
        // a given class loader once.
        if (ivCheckedAnnotationClassLoaders.add(loader))
        {
            for (Class<?> processorClass : ivProcessorProviders.keySet())
            {
                String className = processorClass.getName();

                Class<?> loaderClass;
                try
                {
                    loaderClass = loader.loadClass(className);
                } catch (ClassNotFoundException ex)
                {
                    // At least it hasn't been overridden, so ignore per WAB.  F53641
                    if (isTraceOn && tc.isDebugEnabled())
                        Tr.debug(tc, "ignoring " + className + " : " + ex);
                    continue;
                }

                if (loaderClass != processorClass)
                {
                    Set<String> warnedAnnotations = null;
                    ClassLoader loaderClassLoader = loaderClass.getClassLoader();

                    if (isTraceOn && tc.isDebugEnabled())
                        Tr.debug(tc, "loaded " + loaderClass + " from application class loader " + loaderClassLoader);

                    synchronized (this)
                    {
                        if (ivWarnedClassLoaderAnnotations == null)
                        {
                            ivWarnedClassLoaderAnnotations = new WeakHashMap<ClassLoader, Set<String>>();
                        }

                        warnedAnnotations = ivWarnedClassLoaderAnnotations.get(loaderClassLoader);
                        if (warnedAnnotations == null)
                        {
                            warnedAnnotations = Collections.synchronizedSet(new HashSet<String>());
                            ivWarnedClassLoaderAnnotations.put(loaderClassLoader, warnedAnnotations);
                        }
                    }

                    // Only warn once about a particular class loader loading a
                    // particular annotation class.  We do not want a PARENT_LAST
                    // application to generate warnings for every child WAR class
                    // loader.  Similarly for application server class loaders.
                    if (warnedAnnotations == null || warnedAnnotations.add(className))
                    {
                        CodeSource codeSource = loaderClass.getProtectionDomain().getCodeSource();
                        String codeSourceLocation = codeSource == null ? null : String.valueOf(codeSource.getLocation());

                        Tr.warning(tc, "INCOMPATIBLE_ANNOTATION_CLASS_CWNEN0070W",
                                   className, codeSourceLocation);
                    }
                }
            }
        }

        if (isTraceOn && tc.isDebugEnabled())
            Tr.exit(tc, "checkAnnotationClasses");
    }
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;
	}
918763
@SuppressWarnings("unchecked")
    private Class<? extends T> loadClass(ClassLoader classLoader, String generatedName)
            throws ClassNotFoundException {
        return (Class<? extends T>) classLoader.loadClass(generatedName);
    }
1309304
public void setClassLoaderProvider(String id, ClassLoaderProvider classLoaderProvider) {
        if (classLoaderProvider != null) {
            classLoaderProviderMap.put(id, classLoaderProvider);
        } else {
            classLoaderProviderMap.remove(id);
        }
    }
833974
public static void setPreferredClassLoader(ClassLoader classLoader) {
		if (classLoader != dynamicLoader) {
			dynamicLoader = classLoader;
			final Thread[] threads = new Thread[Thread.activeCount()];
			Thread.enumerate(threads);
			for (final Thread t : threads) {
				if (t != null) {
					t.setContextClassLoader(classLoader);
				}
			}
		}
	}
1340664
public void setClassLoader (ClassLoader loader)
    {
        _loader = loader;
        if (_comm != null) {
            _comm.setClassLoader(loader);
        }
    }