ppkarwasz commented on code in PR #2230:
URL: https://github.com/apache/logging-log4j2/pull/2230#discussion_r1464974551


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java:
##########
@@ -732,12 +705,12 @@ protected void doConfigure() {
                 final List<CustomLevelConfig> copy = new 
ArrayList<>(customLevels);
                 copy.add(child.getObject(CustomLevelConfig.class));
                 customLevels = copy;
-            } else if 
(child.isInstanceOf(AsyncWaitStrategyFactoryConfig.class)) {
-                AsyncWaitStrategyFactoryConfig awsfc = 
child.getObject(AsyncWaitStrategyFactoryConfig.class);
-                if (awsfc == null) {
-                    LOGGER.error("Unable to load 
AsyncWaitStrategyFactoryConfig");
+            } else if (child.isInstanceOf(ConfigurationExtension.class)) {
+                final ConfigurationExtension extension = 
child.getObject(ConfigurationExtension.class);
+                if (extension == null) {

Review Comment:
   I had the same doubt, but I copypasted the `CustomLevels` code. ;-)
   
   Besides `getObject()` can not be `null` due to the null-check above these 
lines.



##########
log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorConfiguration.java:
##########
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.async;
+
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.AbstractLifeCycle;
+import org.apache.logging.log4j.core.config.ConfigurationExtension;
+import org.apache.logging.log4j.plugins.Configurable;
+import org.apache.logging.log4j.plugins.Plugin;
+import org.apache.logging.log4j.plugins.PluginAliases;
+import org.apache.logging.log4j.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.plugins.PluginFactory;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.LoaderUtil;
+
+@Configurable(printObject = true)
+@Plugin("Disruptor")
+@PluginAliases("AsyncWaitStrategyFactory")
+public final class DisruptorConfiguration extends AbstractLifeCycle implements 
ConfigurationExtension {
+
+    private static final Logger LOGGER = StatusLogger.getLogger();
+
+    private final AsyncWaitStrategyFactory waitStrategyFactory;
+    private AsyncLoggerConfigDisruptor loggerConfigDisruptor;
+
+    private DisruptorConfiguration(final AsyncWaitStrategyFactory 
waitStrategyFactory) {
+        this.waitStrategyFactory = waitStrategyFactory;
+    }
+
+    public AsyncWaitStrategyFactory getWaitStrategyFactory() {
+        return waitStrategyFactory;
+    }
+
+    public AsyncLoggerConfigDelegate getAsyncLoggerConfigDelegate() {
+        if (loggerConfigDisruptor == null) {
+            loggerConfigDisruptor = new 
AsyncLoggerConfigDisruptor(waitStrategyFactory);
+        }
+        return loggerConfigDisruptor;
+    }
+
+    @Override
+    public void start() {
+        if (loggerConfigDisruptor != null) {
+            LOGGER.info("Starting AsyncLoggerConfigDisruptor.");
+            loggerConfigDisruptor.start();
+        }
+        super.start();
+    }
+
+    @Override
+    public boolean stop(long timeout, TimeUnit timeUnit) {
+        if (loggerConfigDisruptor != null) {
+            LOGGER.info("Stopping AsyncLoggerConfigDisruptor.");
+            loggerConfigDisruptor.stop(timeout, timeUnit);
+        }
+        return super.stop(timeout, timeUnit);
+    }
+
+    @PluginFactory
+    public static Builder newBuilder() {
+        return new Builder();
+    }
+
+    public static final class Builder implements 
org.apache.logging.log4j.plugins.util.Builder<DisruptorConfiguration> {
+
+        @PluginBuilderAttribute("class")
+        private String factoryClassName;
+
+        @PluginBuilderAttribute
+        private String waitFactory;
+
+        public Builder setFactoryClassName(final String factoryClassName) {
+            this.factoryClassName = factoryClassName;
+            return this;
+        }
+
+        public Builder setWaitFactory(final String waitFactory) {
+            this.waitFactory = waitFactory;
+            return this;
+        }
+
+        @Override
+        public DisruptorConfiguration build() {
+            final String effectiveClassName = Objects.toString(waitFactory, 
factoryClassName);
+            final AsyncWaitStrategyFactory effectiveFactory;
+            if (effectiveClassName != null) {
+                effectiveFactory = 
createWaitStrategyFactory(effectiveClassName);
+            } else {
+                effectiveFactory = null;
+            }
+            if (effectiveFactory != null) {
+                LOGGER.info("Using configured AsyncWaitStrategy factory {}.", 
effectiveClassName);
+            } else {
+                LOGGER.info("Using default AsyncWaitStrategy factory.");
+            }

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to