use of org.apache.logging.log4j.core.script.ScriptManagerFactory in project logging-log4j2 by apache.
the class AbstractConfiguration method initialize.
/**
* Initialize the configuration.
*/
@Override
public void initialize() {
LOGGER.debug(Version.getProductString() + " initializing configuration {}", this);
runtimeStrSubstitutor.setConfiguration(this);
configurationStrSubstitutor.setConfiguration(this);
try {
ServiceLoaderUtil.loadServices(ScriptManagerFactory.class, layer -> ServiceLoader.load(layer, ScriptManagerFactory.class), null).stream().findFirst().ifPresent(scriptManagerFactory -> scriptManager = scriptManagerFactory.createScriptManager(this, watchManager));
} catch (final LinkageError | Exception e) {
// LOG4J2-1920 ScriptEngineManager is not available in Android
LOGGER.info("Cannot initialize scripting support because this JRE does not support it.", e);
}
pluginManager.collectPlugins(pluginPackages);
final PluginManager levelPlugins = new PluginManager(Level.CATEGORY);
levelPlugins.collectPlugins(pluginPackages);
final Map<String, PluginType<?>> plugins = levelPlugins.getPlugins();
if (plugins != null) {
for (final PluginType<?> type : plugins.values()) {
try {
// Cause the class to be initialized if it isn't already.
Loader.initializeClass(type.getPluginClass().getName(), type.getPluginClass().getClassLoader());
} catch (final Exception e) {
LOGGER.error("Unable to initialize {} due to {}", type.getPluginClass().getName(), e.getClass().getSimpleName(), e);
}
}
}
setup();
setupAdvertisement();
doConfigure();
setState(State.INITIALIZED);
LOGGER.debug("Configuration {} initialized", this);
}
Aggregations