Java Code Examples for org.apache.logging.log4j.util.LoaderUtil#getClassLoaders()
The following examples show how to use
org.apache.logging.log4j.util.LoaderUtil#getClassLoaders() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginRegistry.java From logging-log4j2 with Apache License 2.0 | 5 votes |
/** * Load plugins across all ClassLoaders. * @param map The Map of the lists of plugins organized by category. * @since 3.0 */ public void loadPlugins(Map<String, List<PluginType<?>>> map) { for (ClassLoader classLoader : LoaderUtil.getClassLoaders()) { try { loadPlugins(classLoader, map); } catch (Throwable ex) { LOGGER.debug("Unable to retrieve provider from ClassLoader {}", classLoader, ex); } } }
Example 2
Source File: WatchManager.java From logging-log4j2 with Apache License 2.0 | 5 votes |
private List<WatchEventService> getEventServices() { List<WatchEventService> list = new ArrayList<>(); for (final ClassLoader classLoader : LoaderUtil.getClassLoaders()) { try { final ServiceLoader<WatchEventService> serviceLoader = ServiceLoader.load(WatchEventService.class, classLoader); for (final WatchEventService service : serviceLoader) { list.add(service); } } catch (final Throwable ex) { LOGGER.debug("Unable to retrieve WatchEventService from ClassLoader {}", classLoader, ex); } } return list; }
Example 3
Source File: ThreadContextDataInjector.java From logging-log4j2 with Apache License 2.0 | 5 votes |
private static List<ContextDataProvider> getServiceProviders() { List<ContextDataProvider> providers = new ArrayList<>(); for (final ClassLoader classLoader : LoaderUtil.getClassLoaders()) { try { for (final ContextDataProvider provider : ServiceLoader.load(ContextDataProvider.class, classLoader)) { if (providers.stream().noneMatch((p) -> p.getClass().isAssignableFrom(provider.getClass()))) { providers.add(provider); } } } catch (final Throwable ex) { LOGGER.debug("Unable to access Context Data Providers {}", ex.getMessage()); } } return providers; }