You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2016/09/04 18:38:28 UTC
[12/36] logging-log4j2 git commit: Move BlockingQueueFactory classes
to async package
Move BlockingQueueFactory classes to async package
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0848d7a5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0848d7a5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0848d7a5
Branch: refs/heads/master
Commit: 0848d7a558050afa6a1b5ca41a5b82339285d729
Parents: 5bce076
Author: Matt Sicker <bo...@gmail.com>
Authored: Fri Jun 17 18:16:39 2016 -0500
Committer: Matt Sicker <bo...@gmail.com>
Committed: Fri Jun 17 18:16:39 2016 -0500
----------------------------------------------------------------------
.../log4j/core/appender/AsyncAppender.java | 2 +-
.../core/async/ArrayBlockingQueueFactory.java | 16 +++++++
.../log4j/core/async/BlockingQueueFactory.java | 15 +++++++
.../core/async/BlockingQueueFactoryUtil.java | 46 ++++++++++++++++++++
.../async/DisruptorBlockingQueueFactory.java | 17 ++++++++
.../core/async/LinkedTransferQueueFactory.java | 33 ++++++++++++++
.../core/util/ArrayBlockingQueueFactory.java | 16 -------
.../log4j/core/util/BlockingQueueFactory.java | 15 -------
.../core/util/BlockingQueueFactoryUtil.java | 46 --------------------
.../util/DisruptorBlockingQueueFactory.java | 17 --------
.../core/util/LinkedTransferQueueFactory.java | 33 --------------
.../log4j/core/appender/AsyncAppenderTest.java | 8 ++--
src/site/xdoc/manual/appenders.xml | 6 +--
src/site/xdoc/manual/configuration.xml.vm | 2 +-
14 files changed, 136 insertions(+), 136 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java
index 2ac1ac7..3c9c37c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AsyncAppender.java
@@ -42,7 +42,7 @@ import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.core.util.BlockingQueueFactoryUtil;
+import org.apache.logging.log4j.core.async.BlockingQueueFactoryUtil;
import org.apache.logging.log4j.core.util.Constants;
/**
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/async/ArrayBlockingQueueFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/ArrayBlockingQueueFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/ArrayBlockingQueueFactory.java
new file mode 100644
index 0000000..e9c99b8
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/ArrayBlockingQueueFactory.java
@@ -0,0 +1,16 @@
+package org.apache.logging.log4j.core.async;
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * Factory for creating instances of {@link ArrayBlockingQueue}.
+ *
+ * @since 2.7
+ */
+public class ArrayBlockingQueueFactory<E> implements BlockingQueueFactory<E> {
+ @Override
+ public BlockingQueue<E> create(int capacity) {
+ return new ArrayBlockingQueue<>(capacity);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactory.java
new file mode 100644
index 0000000..ccd1625
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactory.java
@@ -0,0 +1,15 @@
+package org.apache.logging.log4j.core.async;
+
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * Factory for creating instances of {@link BlockingQueue}.
+ *
+ * @since 2.7
+ */
+public interface BlockingQueueFactory<E> {
+
+ String PROPERTY = "log4j.BlockingQueueFactory";
+
+ BlockingQueue<E> create(int capacity);
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactoryUtil.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactoryUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactoryUtil.java
new file mode 100644
index 0000000..4684b54
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/BlockingQueueFactoryUtil.java
@@ -0,0 +1,46 @@
+package org.apache.logging.log4j.core.async;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.util.LoaderUtil;
+
+/**
+ * Utility class for obtaining a {@link BlockingQueueFactory}. By default, {@link ArrayBlockingQueueFactory} is used,
+ * but this can be overridden by the system property {@code log4j.BlockingQueueFactory}.
+ *
+ * @since 2.7
+ */
+public final class BlockingQueueFactoryUtil {
+
+ private static final Logger LOGGER = StatusLogger.getLogger();
+
+ /**
+ * Returns a new BlockingQueueFactory.
+ *
+ * @return a BlockingQueueFactory instance
+ */
+ public static <E> BlockingQueueFactory<E> getBlockingQueueFactory() {
+ BlockingQueueFactory<E> factory = null;
+ try {
+ factory = newBlockingQueueFactory();
+ } catch (final ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
+ LOGGER.error("Specified log4j.BlockingQueueFactory could not be instantiated.", e);
+ }
+ if (factory == null) {
+ factory = new ArrayBlockingQueueFactory<>();
+ }
+ return factory;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <E> BlockingQueueFactory<E> newBlockingQueueFactory()
+ throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException,
+ InvocationTargetException {
+ return LoaderUtil.newCheckedInstanceOfProperty(BlockingQueueFactory.PROPERTY, BlockingQueueFactory.class);
+ }
+
+ private BlockingQueueFactoryUtil() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorBlockingQueueFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorBlockingQueueFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorBlockingQueueFactory.java
new file mode 100644
index 0000000..8fb3707
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorBlockingQueueFactory.java
@@ -0,0 +1,17 @@
+package org.apache.logging.log4j.core.async;
+
+import java.util.concurrent.BlockingQueue;
+
+import com.conversantmedia.util.concurrent.DisruptorBlockingQueue;
+
+/**
+ * Factory for creating instances of {@link DisruptorBlockingQueue}.
+ *
+ * @since 2.7
+ */
+public class DisruptorBlockingQueueFactory<E> implements BlockingQueueFactory<E> {
+ @Override
+ public BlockingQueue<E> create(int capacity) {
+ return new DisruptorBlockingQueue<E>(capacity);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/async/LinkedTransferQueueFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/LinkedTransferQueueFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/LinkedTransferQueueFactory.java
new file mode 100644
index 0000000..862fab3
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/LinkedTransferQueueFactory.java
@@ -0,0 +1,33 @@
+/*
+ * 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.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedTransferQueue;
+
+/**
+ * Factory for creating instances of {@link LinkedTransferQueue}.
+ *
+ * @since 2.7
+ */
+public class LinkedTransferQueueFactory<E> implements BlockingQueueFactory<E> {
+ @Override
+ public BlockingQueue<E> create(int capacity) {
+ return new LinkedTransferQueue<>();
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ArrayBlockingQueueFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ArrayBlockingQueueFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ArrayBlockingQueueFactory.java
deleted file mode 100644
index c669b84..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ArrayBlockingQueueFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.apache.logging.log4j.core.util;
-
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-
-/**
- * Factory for creating instances of {@link ArrayBlockingQueue}.
- *
- * @since 2.7
- */
-public class ArrayBlockingQueueFactory<E> implements BlockingQueueFactory<E> {
- @Override
- public BlockingQueue<E> create(int capacity) {
- return new ArrayBlockingQueue<>(capacity);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BlockingQueueFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BlockingQueueFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BlockingQueueFactory.java
deleted file mode 100644
index 6cfdd14..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BlockingQueueFactory.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.apache.logging.log4j.core.util;
-
-import java.util.concurrent.BlockingQueue;
-
-/**
- * Factory for creating instances of {@link BlockingQueue}.
- *
- * @since 2.7
- */
-public interface BlockingQueueFactory<E> {
-
- String PROPERTY = "log4j.BlockingQueueFactory";
-
- BlockingQueue<E> create(int capacity);
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BlockingQueueFactoryUtil.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BlockingQueueFactoryUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BlockingQueueFactoryUtil.java
deleted file mode 100644
index ebef319..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/BlockingQueueFactoryUtil.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.apache.logging.log4j.core.util;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-
-/**
- * Utility class for obtaining a {@link BlockingQueueFactory}. By default, {@link ArrayBlockingQueueFactory} is used,
- * but this can be overridden by the system property {@code log4j.BlockingQueueFactory}.
- *
- * @since 2.7
- */
-public final class BlockingQueueFactoryUtil {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- /**
- * Returns a new BlockingQueueFactory.
- *
- * @return a BlockingQueueFactory instance
- */
- public static <E> BlockingQueueFactory<E> getBlockingQueueFactory() {
- BlockingQueueFactory<E> factory = null;
- try {
- factory = newBlockingQueueFactory();
- } catch (final ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
- LOGGER.error("Specified log4j.BlockingQueueFactory could not be instantiated.", e);
- }
- if (factory == null) {
- factory = new ArrayBlockingQueueFactory<>();
- }
- return factory;
- }
-
- @SuppressWarnings("unchecked")
- private static <E> BlockingQueueFactory<E> newBlockingQueueFactory()
- throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException,
- InvocationTargetException {
- return LoaderUtil.newCheckedInstanceOfProperty(BlockingQueueFactory.PROPERTY, BlockingQueueFactory.class);
- }
-
- private BlockingQueueFactoryUtil() {
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DisruptorBlockingQueueFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DisruptorBlockingQueueFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DisruptorBlockingQueueFactory.java
deleted file mode 100644
index 3f80816..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/DisruptorBlockingQueueFactory.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.logging.log4j.core.util;
-
-import java.util.concurrent.BlockingQueue;
-
-import com.conversantmedia.util.concurrent.DisruptorBlockingQueue;
-
-/**
- * Factory for creating instances of {@link DisruptorBlockingQueue}.
- *
- * @since 2.7
- */
-public class DisruptorBlockingQueueFactory<E> implements BlockingQueueFactory<E> {
- @Override
- public BlockingQueue<E> create(int capacity) {
- return new DisruptorBlockingQueue<E>(capacity);
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/main/java/org/apache/logging/log4j/core/util/LinkedTransferQueueFactory.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/LinkedTransferQueueFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/LinkedTransferQueueFactory.java
deleted file mode 100644
index 4b29077..0000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/LinkedTransferQueueFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.util;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedTransferQueue;
-
-/**
- * Factory for creating instances of {@link LinkedTransferQueue}.
- *
- * @since 2.7
- */
-public class LinkedTransferQueueFactory<E> implements BlockingQueueFactory<E> {
- @Override
- public BlockingQueue<E> create(int capacity) {
- return new LinkedTransferQueue<>();
- }
-}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
index 73ae08e..3066f38 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderTest.java
@@ -21,10 +21,10 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LoggingException;
-import org.apache.logging.log4j.core.util.ArrayBlockingQueueFactory;
-import org.apache.logging.log4j.core.util.BlockingQueueFactory;
-import org.apache.logging.log4j.core.util.DisruptorBlockingQueueFactory;
-import org.apache.logging.log4j.core.util.LinkedTransferQueueFactory;
+import org.apache.logging.log4j.core.async.ArrayBlockingQueueFactory;
+import org.apache.logging.log4j.core.async.BlockingQueueFactory;
+import org.apache.logging.log4j.core.async.DisruptorBlockingQueueFactory;
+import org.apache.logging.log4j.core.async.LinkedTransferQueueFactory;
import org.apache.logging.log4j.junit.LoggerContextRule;
import org.apache.logging.log4j.test.appender.ListAppender;
import org.junit.After;
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/src/site/xdoc/manual/appenders.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/appenders.xml b/src/site/xdoc/manual/appenders.xml
index 806e578..9af6a57 100644
--- a/src/site/xdoc/manual/appenders.xml
+++ b/src/site/xdoc/manual/appenders.xml
@@ -77,14 +77,14 @@
<th>Description</th>
</tr>
<tr>
- <td><tt>org.apache.logging.log4j.core.util.ArrayBlockingQueueFactory</tt></td>
+ <td><tt>org.apache.logging.log4j.core.async.ArrayBlockingQueueFactory</tt></td>
<td>
This is the default implementation that uses
<a class="javadoc" href="https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ArrayBlockingQueue.html">ArrayBlockingQueue</a>.
</td>
</tr>
<tr>
- <td><tt>org.apache.logging.log4j.core.util.DisruptorBlockingQueueFactory</tt></td>
+ <td><tt>org.apache.logging.log4j.core.async.DisruptorBlockingQueueFactory</tt></td>
<td>
This uses the <a href="https://github.com/conversant/disruptor">Conversant Disruptor</a> implementation
of <tt>BlockingQueue</tt>.
@@ -92,7 +92,7 @@
</td>
</tr>
<tr>
- <td><tt>org.apache.logging.log4j.core.util.LinkedTransferQueueFactory</tt></td>
+ <td><tt>org.apache.logging.log4j.core.async.LinkedTransferQueueFactory</tt></td>
<td>
This uses the new in Java 7 implementation
<a class="javadoc" href="https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/LinkedTransferQueue.html">LinkedTransferQueue</a>.
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0848d7a5/src/site/xdoc/manual/configuration.xml.vm
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm
index d7d281c..88edd0e 100644
--- a/src/site/xdoc/manual/configuration.xml.vm
+++ b/src/site/xdoc/manual/configuration.xml.vm
@@ -2006,7 +2006,7 @@ public class AwesomeTest {
</tr>
<tr>
<td><a name="log4j.BlockingQueueFactory"/>log4j.BlockingQueueFactory</td>
- <td>org.apache.logging.log4j.core.util.ArrayBlockingQueueFactory</td>
+ <td>org.apache.logging.log4j.core.async.ArrayBlockingQueueFactory</td>
<td>Specifies what type of <tt>BlockingQueue</tt> implementation to use with
<a href="appenders.html#AsyncAppender">AsyncAppender</a>.</td>
</tr>