Deprecate isAlive() logic

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/jcs/trunk@1779350 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
index 216a94d..9f37b0c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
@@ -64,9 +64,6 @@
     /** in milliseconds */
     private int waitBeforeRetry;
 
-    /** this is true if there is any worker thread. */
-    private final AtomicBoolean alive = new AtomicBoolean(false);
-
     /**
      * This means that the queue is functional. If we reached the max number of failures, the queue
      * is marked as non functional and will never work again.
@@ -108,21 +105,27 @@
      * If they queue has an active thread it is considered alive.
      * <p>
      * @return The alive value
+     * 
+     * @deprecated The alive-logic is not used 
      */
-    @Override
+    @Deprecated
+	@Override
     public boolean isAlive()
     {
-        return alive.get();
+        return true;
     }
 
     /**
      * Sets whether the queue is actively processing -- if there are working threads.
      * <p>
      * @param aState
+     * 
+     * @deprecated The alive-logic is not used 
      */
-    public void setAlive( boolean aState )
+    @Deprecated
+	public void setAlive( boolean aState )
     {
-        alive.set(aState);
+        // do nothing
     }
 
     /**
@@ -179,17 +182,9 @@
      * @throws IOException
      */
     @Override
-    public synchronized void addPutEvent( ICacheElement<K, V> ce )
-        throws IOException
+    public void addPutEvent( ICacheElement<K, V> ce )
     {
-        if ( isWorking() )
-        {
-            put( new PutEvent( ce ) );
-        }
-        else if ( log.isWarnEnabled() )
-        {
-            log.warn( "Not enqueuing Put Event for [" + this + "] because it's non-functional." );
-        }
+        put( new PutEvent( ce ) );
     }
 
     /**
@@ -200,54 +195,28 @@
      * @throws IOException
      */
     @Override
-    public synchronized void addRemoveEvent( K key )
-        throws IOException
+    public void addRemoveEvent( K key )
     {
-        if ( isWorking() )
-        {
-            put( new RemoveEvent( key ) );
-        }
-        else if ( log.isWarnEnabled() )
-        {
-            log.warn( "Not enqueuing Remove Event for [" + this + "] because it's non-functional." );
-        }
+        put( new RemoveEvent( key ) );
     }
 
     /**
      * This adds a remove all event to the queue. When it is processed, all elements will be removed
      * from the cache.
-     * <p>
-     * @throws IOException
      */
     @Override
-    public synchronized void addRemoveAllEvent()
-        throws IOException
+    public void addRemoveAllEvent()
     {
-        if ( isWorking() )
-        {
-            put( new RemoveAllEvent() );
-        }
-        else if ( log.isWarnEnabled() )
-        {
-            log.warn( "Not enqueuing RemoveAll Event for [" + this + "] because it's non-functional." );
-        }
+        put( new RemoveAllEvent() );
     }
 
     /**
-     * @throws IOException
+     * This adds a dispose event to the queue. When it is processed, the cache is shut down
      */
     @Override
-    public synchronized void addDisposeEvent()
-        throws IOException
+    public void addDisposeEvent()
     {
-        if ( isWorking() )
-        {
-            put( new DisposeEvent() );
-        }
-        else if ( log.isWarnEnabled() )
-        {
-            log.warn( "Not enqueuing Dispose Event for [" + this + "] because it's non-functional." );
-        }
+        put( new DisposeEvent() );
     }
 
     /**
@@ -293,8 +262,7 @@
                         log.warn( "Error while running event from Queue: " + this
                             + ". Dropping Event and marking Event Queue as non-functional." );
                     }
-                    setWorking( false );
-                    setAlive( false );
+                    destroy();
                     return;
                 }
                 if ( log.isInfoEnabled() )
@@ -312,10 +280,7 @@
                     {
                         log.warn( "Interrupted while sleeping for retry on event " + this + "." );
                     }
-                    // TODO consider if this is best. maybe we should just
-                    // destroy
-                    setWorking( false );
-                    setAlive( false );
+                    destroy();
                 }
             }
         }
@@ -342,10 +307,8 @@
          * Constructor for the PutEvent object.
          * <p>
          * @param ice
-         * @throws IOException
          */
         PutEvent( ICacheElement<K, V> ice )
-            throws IOException
         {
             this.ice = ice;
         }
@@ -391,10 +354,8 @@
          * Constructor for the RemoveEvent object
          * <p>
          * @param key
-         * @throws IOException
          */
         RemoveEvent( K key )
-            throws IOException
         {
             this.key = key;
         }
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueue.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueue.java
index 62126eb..92b55e3 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueue.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueue.java
@@ -88,7 +88,6 @@
             TimeUnit.MILLISECONDS,
             queue,
             new DaemonThreadFactory("CacheEventQueue.QProcessor-" + getCacheName()));
-        setAlive(true);
     }
 
     /**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java
index d59c6c2..b7edda3 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java
@@ -88,7 +88,6 @@
         // this will share the same pool with other event queues by default.
         pool = ThreadPoolManager.getInstance().getPool(
                 (threadPoolName == null) ? "cache_event_queue" : threadPoolName );
-        setAlive(true);
     }
 
     /**
@@ -106,9 +105,9 @@
     @Override
     public synchronized void destroy()
     {
-        if ( isAlive() )
+        if ( isWorking() )
         {
-            setAlive(false);
+            setWorking(false);
             pool.shutdownNow();
             if ( log.isInfoEnabled() )
             {
@@ -139,8 +138,7 @@
 
         ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
 
-        elems.add(new StatElement<Boolean>( "Working", Boolean.valueOf(super.isWorking()) ) );
-        elems.add(new StatElement<Boolean>( "Alive", Boolean.valueOf(this.isAlive()) ) );
+        elems.add(new StatElement<Boolean>( "Working", Boolean.valueOf(isWorking()) ) );
         elems.add(new StatElement<Boolean>( "Empty", Boolean.valueOf(this.isEmpty()) ) );
 
         if ( pool.getQueue() != null )