logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1583222 - in /logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core: LifeCycleStatus.java LoggerContext.java impl/Log4jContextFactory.java web/Log4jWebInitializerImpl.java
Date Sun, 30 Mar 2014 23:02:36 GMT
Author: mattsicker
Date: Sun Mar 30 23:02:36 2014
New Revision: 1583222

URL: http://svn.apache.org/r1583222
Log:
Extract Status enum to its own class.

Added:
    logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycleStatus.java
  (with props)
Modified:
    logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
    logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
    logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java

Added: logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycleStatus.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycleStatus.java?rev=1583222&view=auto
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycleStatus.java
(added)
+++ logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycleStatus.java
Sun Mar 30 23:02:36 2014
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+/**
+ * Status of the LoggerContext.
+ */
+public enum LifeCycleStatus {
+    /** Initialized but not yet started. */
+    INITIALIZED,
+    /** In the process of starting. */
+    STARTING,
+    /** Is active. */
+    STARTED,
+    /** Shutdown is in progress. */
+    STOPPING,
+    /** Has shutdown. */
+    STOPPED
+}

Propchange: logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycleStatus.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java?rev=1583222&r1=1583221&r2=1583222&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
Sun Mar 30 23:02:36 2014
@@ -78,23 +78,7 @@ public class LoggerContext implements or
      */
     private Reference<Thread> shutdownThread;
 
-    /**
-     * Status of the LoggerContext.
-     */
-    public enum Status {
-        /** Initialized but not yet started. */
-        INITIALIZED,
-        /** In the process of starting. */
-        STARTING,
-        /** Is active. */
-        STARTED,
-        /** Shutdown is in progress. */
-        STOPPING,
-        /** Has shutdown. */
-        STOPPED
-    }
-
-    private volatile Status status = Status.INITIALIZED;
+    private volatile LifeCycleStatus status = LifeCycleStatus.INITIALIZED;
 
     private final Lock configLock = new ReentrantLock();
 
@@ -155,11 +139,11 @@ public class LoggerContext implements or
     public void start() {
         if (configLock.tryLock()) {
             try {
-                if (status == Status.INITIALIZED || status == Status.STOPPED) {
-                    status = Status.STARTING;
+                if (status == LifeCycleStatus.INITIALIZED || status == LifeCycleStatus.STOPPED)
{
+                    status = LifeCycleStatus.STARTING;
                     reconfigure();
                     setUpShutdownHook();
-                    status = Status.STARTED;
+                    status = LifeCycleStatus.STARTED;
                 }
             } finally {
                 configLock.unlock();
@@ -174,9 +158,9 @@ public class LoggerContext implements or
     public void start(final Configuration config) {
         if (configLock.tryLock()) {
             try {
-                if (status == Status.INITIALIZED || status == Status.STOPPED) {
+                if (status == LifeCycleStatus.INITIALIZED || status == LifeCycleStatus.STOPPED)
{
                     setUpShutdownHook();
-                    status = Status.STARTED;
+                    status = LifeCycleStatus.STARTED;
                 }
             } finally {
                 configLock.unlock();
@@ -216,10 +200,10 @@ public class LoggerContext implements or
     public void stop() {
         configLock.lock();
         try {
-            if (status == Status.STOPPED) {
+            if (status == LifeCycleStatus.STOPPED) {
                 return;
             }
-            status = Status.STOPPING;
+            status = LifeCycleStatus.STOPPING;
             tearDownShutdownHook();
             final Configuration prev = config;
             config = NULL_CONFIGURATION;
@@ -227,7 +211,7 @@ public class LoggerContext implements or
             prev.stop();
             externalContext = null;
             LogManager.getFactory().removeContext(this);
-            status = Status.STOPPED;
+            status = LifeCycleStatus.STOPPED;
         } finally {
             configLock.unlock();
 
@@ -252,13 +236,13 @@ public class LoggerContext implements or
         return name;
     }
 
-    public Status getStatus() {
+    public LifeCycleStatus getStatus() {
         return status;
     }
 
     @Override
     public boolean isStarted() {
-        return status == Status.STARTED;
+        return status == LifeCycleStatus.STARTED;
     }
 
     /**
@@ -294,7 +278,7 @@ public class LoggerContext implements or
      * Whether this collection is a copy of the underlying collection or not is undefined.
Therefore, modify this collection at your own
      * risk.
      * </p>
-     * 
+     *
      * @return a collection of the current loggers.
      */
     public Collection<Logger> getLoggers() {

Modified: logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java?rev=1583222&r1=1583221&r2=1583222&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
Sun Mar 30 23:02:36 2014
@@ -18,6 +18,7 @@ package org.apache.logging.log4j.core.im
 
 import java.net.URI;
 
+import org.apache.logging.log4j.core.LifeCycleStatus;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configuration;
 import org.apache.logging.log4j.core.config.ConfigurationFactory;
@@ -72,7 +73,7 @@ public class Log4jContextFactory impleme
                                     final boolean currentContext) {
         final LoggerContext ctx = selector.getContext(fqcn, loader, currentContext);
         ctx.setExternalContext(externalContext);
-        if (ctx.getStatus() == LoggerContext.Status.INITIALIZED) {
+        if (ctx.getStatus() == LifeCycleStatus.INITIALIZED) {
             ctx.start();
         }
         return ctx;
@@ -94,7 +95,7 @@ public class Log4jContextFactory impleme
         if (externalContext != null && ctx.getExternalContext() == null) {
             ctx.setExternalContext(externalContext);
         }
-        if (ctx.getStatus() == LoggerContext.Status.INITIALIZED) {
+        if (ctx.getStatus() == LifeCycleStatus.INITIALIZED) {
             if (source != null) {
                 ContextAnchor.THREAD_CONTEXT.set(ctx);
                 final Configuration config = ConfigurationFactory.getInstance().getConfiguration(source);
@@ -124,7 +125,7 @@ public class Log4jContextFactory impleme
         if (externalContext != null && ctx.getExternalContext() == null) {
             ctx.setExternalContext(externalContext);
         }
-        if (ctx.getStatus() == LoggerContext.Status.INITIALIZED) {
+        if (ctx.getStatus() == LifeCycleStatus.INITIALIZED) {
             if (configLocation != null || name != null) {
                 ContextAnchor.THREAD_CONTEXT.set(ctx);
                 final Configuration config = ConfigurationFactory.getInstance().getConfiguration(name,
configLocation);

Modified: logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java?rev=1583222&r1=1583221&r2=1583222&view=diff
==============================================================================
--- logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java
(original)
+++ logging/log4j/log4j2/branches/LOG4J2-577/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java
Sun Mar 30 23:02:36 2014
@@ -23,6 +23,7 @@ import javax.servlet.ServletContext;
 import javax.servlet.UnavailableException;
 
 import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.LifeCycleStatus;
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configurator;
 import org.apache.logging.log4j.core.helpers.FileUtils;
@@ -116,7 +117,7 @@ final class Log4jWebInitializerImpl impl
                 this.selector = (NamedContextSelector) selector;
                 loggerContext = this.selector.locateContext(this.name, this.servletContext,
configLocation);
                 ContextAnchor.THREAD_CONTEXT.set(loggerContext);
-                if (loggerContext.getStatus() == LoggerContext.Status.INITIALIZED) {
+                if (loggerContext.getStatus() == LifeCycleStatus.INITIALIZED) {
                     loggerContext.start();
                 }
                 ContextAnchor.THREAD_CONTEXT.remove();



Mime
View raw message