commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1690450 - in /commons/proper/jcs/trunk/commons-jcs-core/src: main/java/org/apache/commons/jcs/engine/control/ main/java/org/apache/commons/jcs/engine/control/event/ main/java/org/apache/commons/jcs/engine/control/event/behavior/ test/java/...
Date Sun, 12 Jul 2015 12:00:30 GMT
Author: tv
Date: Sun Jul 12 12:00:30 2015
New Revision: 1690450

URL: http://svn.apache.org/r1690450
Log:
Generify events

Modified:
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEvent.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEventQueue.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEvent.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventHandler.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventQueue.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/ElementEventHandlerMockImpl.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/SimpleEventHandlingUnitTest.java

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java?rev=1690450&r1=1690449&r2=1690450&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java
Sun Jul 12 12:00:30 2015
@@ -1684,7 +1684,7 @@ public class CompositeCache<K, V>
                 log.warn("No element event queue available for cache " + getCacheName());
                 return;
             }
-            IElementEvent event = new ElementEvent( element, eventType );
+            IElementEvent<ICacheElement<K, V>> event = new ElementEvent<ICacheElement<K,
V>>( element, eventType );
             for (IElementEventHandler hand : eventHandlers)
             {
                 try

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEvent.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEvent.java?rev=1690450&r1=1690449&r2=1690450&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEvent.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEvent.java
Sun Jul 12 12:00:30 2015
@@ -19,18 +19,18 @@ package org.apache.commons.jcs.engine.co
  * under the License.
  */
 
+import java.util.EventObject;
+
 import org.apache.commons.jcs.engine.control.event.behavior.ElementEventType;
 import org.apache.commons.jcs.engine.control.event.behavior.IElementEvent;
 
-import java.util.EventObject;
-
 /**
  * Element events will trigger the creation of Element Event objects. This is a wrapper around
the
  * cache element that indicates the event triggered.
  */
-public class ElementEvent
+public class ElementEvent<T>
     extends EventObject
-    implements IElementEvent
+    implements IElementEvent<T>
 {
     /** Don't change */
     private static final long serialVersionUID = -5364117411457467056L;
@@ -41,10 +41,10 @@ public class ElementEvent
     /**
      * Constructor for the ElementEvent object
      * <p>
-     * @param source The Cache Element (should restrict?)
+     * @param source The Cache Element
      * @param elementEvent The event id defined in the enum class.
      */
-    public ElementEvent( Object source, ElementEventType elementEvent )
+    public ElementEvent( T source, ElementEventType elementEvent )
     {
         super( source );
         this.elementEvent = elementEvent;
@@ -60,4 +60,15 @@ public class ElementEvent
     {
         return elementEvent;
     }
+
+    /**
+     * @return the source of the event.
+     */
+    @SuppressWarnings("unchecked") // Generified
+    @Override
+    public T getSource()
+    {
+        return (T) super.getSource();
+
+    }
 }

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEventQueue.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEventQueue.java?rev=1690450&r1=1690449&r2=1690450&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEventQueue.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/ElementEventQueue.java
Sun Jul 12 12:00:30 2015
@@ -19,6 +19,11 @@ package org.apache.commons.jcs.engine.co
  * under the License.
  */
 
+import java.io.IOException;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.commons.jcs.engine.control.event.behavior.IElementEvent;
 import org.apache.commons.jcs.engine.control.event.behavior.IElementEventHandler;
 import org.apache.commons.jcs.engine.control.event.behavior.IElementEventQueue;
@@ -26,11 +31,6 @@ import org.apache.commons.jcs.utils.thre
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.io.IOException;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
 /**
  * An event queue is used to propagate ordered cache events to one and only one target listener.
  */
@@ -95,7 +95,7 @@ public class ElementEventQueue
      * @throws IOException
      */
     @Override
-    public void addElementEvent( IElementEventHandler hand, IElementEvent event )
+    public <T> void addElementEvent( IElementEventHandler hand, IElementEvent<T>
event )
         throws IOException
     {
 
@@ -167,7 +167,7 @@ public class ElementEventQueue
         private final IElementEventHandler hand;
 
         /** event */
-        private final IElementEvent event;
+        private final IElementEvent<?> event;
 
         /**
          * Constructor for the PutEvent object.
@@ -177,7 +177,7 @@ public class ElementEventQueue
          * @throws IOException
          */
         @SuppressWarnings("synthetic-access")
-        ElementEventRunner( IElementEventHandler hand, IElementEvent event )
+        ElementEventRunner( IElementEventHandler hand, IElementEvent<?> event )
             throws IOException
         {
             if ( log.isDebugEnabled() )

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEvent.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEvent.java?rev=1690450&r1=1690449&r2=1690450&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEvent.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEvent.java
Sun Jul 12 12:00:30 2015
@@ -24,7 +24,7 @@ import java.io.Serializable;
 /**
  * Defines how an element event object should behave.
  */
-public interface IElementEvent
+public interface IElementEvent<T>
     extends Serializable
 {
     /**
@@ -38,5 +38,5 @@ public interface IElementEvent
     /**
      * @return the source of the event.
      */
-    Object getSource();
+    T getSource();
 }

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventHandler.java?rev=1690450&r1=1690449&r2=1690450&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventHandler.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventHandler.java
Sun Jul 12 12:00:30 2015
@@ -36,5 +36,5 @@ public interface IElementEventHandler
      * @param event
      *            The event created by the cache.
      */
-    void handleElementEvent( IElementEvent event );
+    <T> void handleElementEvent( IElementEvent<T> event );
 }

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventQueue.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventQueue.java?rev=1690450&r1=1690449&r2=1690450&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventQueue.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/event/behavior/IElementEventQueue.java
Sun Jul 12 12:00:30 2015
@@ -37,7 +37,7 @@ public interface IElementEventQueue
      *            The IElementEventHandler IElementEvent event
      * @throws IOException
      */
-    void addElementEvent( IElementEventHandler hand, IElementEvent event )
+    <T> void addElementEvent( IElementEventHandler hand, IElementEvent<T> event
)
         throws IOException;
 
     /**

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/ElementEventHandlerMockImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/ElementEventHandlerMockImpl.java?rev=1690450&r1=1690449&r2=1690450&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/ElementEventHandlerMockImpl.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/ElementEventHandlerMockImpl.java
Sun Jul 12 12:00:30 2015
@@ -56,7 +56,7 @@ public class ElementEventHandlerMockImpl
      * @param event
      */
     @Override
-    public synchronized void handleElementEvent( IElementEvent event )
+    public synchronized <T> void handleElementEvent( IElementEvent<T> event )
     {
         setCallCount( getCallCount() + 1 );
 

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/SimpleEventHandlingUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/SimpleEventHandlingUnitTest.java?rev=1690450&r1=1690449&r2=1690450&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/SimpleEventHandlingUnitTest.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/event/SimpleEventHandlingUnitTest.java
Sun Jul 12 12:00:30 2015
@@ -20,6 +20,7 @@ package org.apache.commons.jcs.engine.co
  */
 
 import junit.framework.TestCase;
+
 import org.apache.commons.jcs.JCS;
 import org.apache.commons.jcs.access.CacheAccess;
 import org.apache.commons.jcs.engine.behavior.IElementAttributes;
@@ -279,7 +280,7 @@ public class SimpleEventHandlingUnitTest
          * @param event
          */
         @Override
-        public synchronized void handleElementEvent( IElementEvent event )
+        public synchronized <T> void handleElementEvent( IElementEvent<T> event
)
         {
             //System.out.println( "Handling Event of Type " +
             // event.getElementEvent() );
@@ -307,6 +308,12 @@ public class SimpleEventHandlingUnitTest
                 case EXCEEDED_IDLETIME_ONREQUEST:
                 exceededIdletimeCount++;
                 break;
+
+                case EXCEEDED_IDLETIME_BACKGROUND:
+                break;
+
+                case EXCEEDED_MAXLIFE_BACKGROUND:
+                break;
             }
         }
 



Mime
View raw message