Repository: logging-log4j2
Updated Branches:
  refs/heads/master c52b432cd -> 22ada0a04


Revert "Add LifeCycle abstract class that uses AtomicReference."

This reverts commit 1a332afa33c55a72ae8ab5ec83cd5964de3fdc67.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/22ada0a0
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/22ada0a0
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/22ada0a0

Branch: refs/heads/master
Commit: 22ada0a045707899d4f166e87ef09db84af2f92d
Parents: c52b432
Author: Matt Sicker <[email protected]>
Authored: Wed Sep 24 20:22:49 2014 -0500
Committer: Matt Sicker <[email protected]>
Committed: Wed Sep 24 20:22:49 2014 -0500

----------------------------------------------------------------------
 .../log4j/core/AbstractAtomicLifeCycle.java     | 102 -------------------
 .../apache/logging/log4j/core/LifeCycle.java    |   9 +-
 2 files changed, 3 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/22ada0a0/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractAtomicLifeCycle.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractAtomicLifeCycle.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractAtomicLifeCycle.java
deleted file mode 100644
index 05a343a..0000000
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/AbstractAtomicLifeCycle.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package org.apache.logging.log4j.core;
-
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.logging.log4j.core.util.Throwables;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * An extensible {@link LifeCycle} using an {@link AtomicReference} to wrap 
its {@link LifeCycle.State}. Thus, classes
- * which extend this class will follow the finite state machine as follows:
- * <ol>
- * <li>When {@link #start()} is called, {@link #doStart()} is called if and 
only if this is in the INITIALIZED state or
- * the STOPPED state.</li>
- * <li>Before {@link #doStart()} is called, this will be in the STARTING 
state.</li>
- * <li>After {@link #doStart()} is called, this will be in the STARTED state 
if no exception was thrown; otherwise,
- * this will be in the INITIALIZED state again, and the exception thrown will 
be re-thrown (if unchecked) or wrapped
- * in an {@link java.lang.reflect.UndeclaredThrowableException} and then 
rethrown (if checked).</li>
- * <li>When {@link #stop()} is called, {@link #doStop()} is called if and only 
if this is in the STARTED state.</li>
- * <li>Before {@link #doStop()} is called, this will be in the STOPPING 
state.</li>
- * <li>After {@link #doStop()} is called, this will be in the STOPPED state. 
Any exceptions thrown will be re-thrown
- * as described above.</li>
- * </ol>
- *
- * @since 2.1
- */
-public abstract class AbstractAtomicLifeCycle implements LifeCycle, 
Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    protected static final StatusLogger LOGGER = StatusLogger.getLogger();
-
-    private final AtomicReference<State> state = new 
AtomicReference<State>(State.INITIALIZED);
-
-    @Override
-    public void start() {
-        if (state.compareAndSet(State.INITIALIZED, State.STARTING) ||
-            state.compareAndSet(State.STOPPED, State.STARTING)) {
-            try {
-                doStart();
-                state.set(State.STARTED);
-            } catch (final Exception e) {
-                state.set(State.INITIALIZED);
-                Throwables.rethrow(e);
-            }
-        }
-    }
-
-    /**
-     * Performs the start-up logic. This method is called only if this is in 
the INITIALIZED or STOPPED state.
-     *
-     * @throws Exception
-     */
-    protected abstract void doStart() throws Exception;
-
-    @Override
-    public void stop() {
-        if (state.compareAndSet(State.STARTED, State.STOPPING)) {
-            try {
-                doStop();
-            } catch (Exception e) {
-                Throwables.rethrow(e);
-            } finally {
-                state.set(State.STOPPED);
-            }
-        }
-    }
-
-    /**
-     * Performs the tear-down logic. This method is called only if this is in 
the STARTED state.
-     *
-     * @throws Exception
-     */
-    protected abstract void doStop() throws Exception;
-
-    @Override
-    public boolean isStarted() {
-        return state.get() == State.STARTED;
-    }
-
-    @Override
-    public boolean isStopped() {
-        return state.get() == State.STOPPED;
-    }
-
-    @Override
-    public boolean equals(final Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        final AbstractAtomicLifeCycle that = (AbstractAtomicLifeCycle) o;
-        return state.equals(that.state);
-    }
-
-    @Override
-    public int hashCode() {
-        return state.hashCode();
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/22ada0a0/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
index 191edcd..e75ebd5 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LifeCycle.java
@@ -18,7 +18,7 @@
 package org.apache.logging.log4j.core;
 
 /**
- * Generic object life cycle support interface. In Log4j, the main interface 
for handling
+ * All proper Java frameworks implement some sort of object life cycle. In 
Log4j, the main interface for handling
  * the life cycle context of an object is this one. An object first starts in 
the {@link State#INITIALIZED} state
  * by default to indicate the class has been loaded. From here, calling the 
{@link #start()} method will change this
  * state to {@link State#STARTING}. After successfully being started, this 
state is changed to {@link State#STARTED}.
@@ -26,12 +26,9 @@ package org.apache.logging.log4j.core;
  * stopped, this goes into the {@link State#STOPPED} state. In most 
circumstances, implementation classes should
  * store their {@link State} in a {@code volatile} field or inside an
  * {@link java.util.concurrent.atomic.AtomicReference} dependant on 
synchronization and concurrency requirements.
- *
- * @see AbstractLifeCycle
- * @see AbstractAtomicLifeCycle
  */
 public interface LifeCycle {
-
+    
     /**
      * Status of a life cycle like a {@link LoggerContext}.
      */
@@ -47,7 +44,7 @@ public interface LifeCycle {
         /** Has stopped. */
         STOPPED
     }
-
+    
     void start();
 
     void stop();

Reply via email to