Search in sources :

Example 1 with ScriptManagerFactory

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);
}
Also used : Arrays(java.util.Arrays) Source(org.apache.logging.log4j.core.util.Source) LoggerContext(org.apache.logging.log4j.core.LoggerContext) Arbiter(org.apache.logging.log4j.core.config.arbiters.Arbiter) Level(org.apache.logging.log4j.Level) AsyncLoggerConfig(org.apache.logging.log4j.core.async.AsyncLoggerConfig) LogEvent(org.apache.logging.log4j.core.LogEvent) PluginType(org.apache.logging.log4j.plugins.util.PluginType) AsyncLoggerConfigDisruptor(org.apache.logging.log4j.core.async.AsyncLoggerConfigDisruptor) Map(java.util.Map) AsyncLoggerConfigDelegate(org.apache.logging.log4j.core.async.AsyncLoggerConfigDelegate) Loader(org.apache.logging.log4j.core.util.Loader) DummyNanoClock(org.apache.logging.log4j.core.time.internal.DummyNanoClock) PluginManager(org.apache.logging.log4j.plugins.util.PluginManager) LifeCycle(org.apache.logging.log4j.core.LifeCycle) Filter(org.apache.logging.log4j.core.Filter) AsyncAppender(org.apache.logging.log4j.core.appender.AsyncAppender) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Node(org.apache.logging.log4j.plugins.Node) Set(java.util.Set) ServiceLoader(java.util.ServiceLoader) ScriptManagerFactory(org.apache.logging.log4j.core.script.ScriptManagerFactory) NanoClock(org.apache.logging.log4j.core.time.NanoClock) Serializable(java.io.Serializable) Objects(java.util.Objects) Advertiser(org.apache.logging.log4j.core.net.Advertiser) List(java.util.List) Interpolator(org.apache.logging.log4j.core.lookup.Interpolator) ConfigurationStrSubstitutor(org.apache.logging.log4j.core.lookup.ConfigurationStrSubstitutor) PropertiesLookup(org.apache.logging.log4j.core.lookup.PropertiesLookup) StrLookup(org.apache.logging.log4j.core.lookup.StrLookup) Layout(org.apache.logging.log4j.core.Layout) PatternLayout(org.apache.logging.log4j.core.layout.PatternLayout) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) StrSubstitutor(org.apache.logging.log4j.core.lookup.StrSubstitutor) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NameUtil(org.apache.logging.log4j.util.NameUtil) Appender(org.apache.logging.log4j.core.Appender) AbstractFilterable(org.apache.logging.log4j.core.filter.AbstractFilterable) PropertiesUtil(org.apache.logging.log4j.util.PropertiesUtil) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) WatcherFactory(org.apache.logging.log4j.core.util.WatcherFactory) ScriptManager(org.apache.logging.log4j.core.script.ScriptManager) Version(org.apache.logging.log4j.core.Version) SelectArbiter(org.apache.logging.log4j.core.config.arbiters.SelectArbiter) WeakReference(java.lang.ref.WeakReference) PluginBuilder(org.apache.logging.log4j.core.config.plugins.util.PluginBuilder) RuntimeStrSubstitutor(org.apache.logging.log4j.core.lookup.RuntimeStrSubstitutor) Constants(org.apache.logging.log4j.core.util.Constants) WatchManager(org.apache.logging.log4j.core.util.WatchManager) IOException(java.io.IOException) Watcher(org.apache.logging.log4j.core.util.Watcher) TimeUnit(java.util.concurrent.TimeUnit) ConsoleAppender(org.apache.logging.log4j.core.appender.ConsoleAppender) ServiceLoaderUtil(org.apache.logging.log4j.util.ServiceLoaderUtil) Collections(java.util.Collections) InputStream(java.io.InputStream) PluginManager(org.apache.logging.log4j.plugins.util.PluginManager) ScriptManagerFactory(org.apache.logging.log4j.core.script.ScriptManagerFactory) PluginType(org.apache.logging.log4j.plugins.util.PluginType) IOException(java.io.IOException)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Serializable (java.io.Serializable)1 WeakReference (java.lang.ref.WeakReference)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ServiceLoader (java.util.ServiceLoader)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 TimeUnit (java.util.concurrent.TimeUnit)1