commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1096367 - in /commons/proper/pool/trunk/src/test/org/apache/commons/pool2: VisitTracker.java VisitTrackerFactory.java
Date Sun, 24 Apr 2011 20:06:32 GMT
Author: simonetripodi
Date: Sun Apr 24 20:06:32 2011
New Revision: 1096367

URL: http://svn.apache.org/viewvc?rev=1096367&view=rev
Log:
added generics to VisitTracker and related Factory classes

Modified:
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTracker.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTrackerFactory.java

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTracker.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTracker.java?rev=1096367&r1=1096366&r2=1096367&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTracker.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTracker.java Sun Apr
24 20:06:32 2011
@@ -21,13 +21,13 @@ package org.apache.commons.pool2;
  * validated, activated, passivated.
  *
  */
-public class VisitTracker {
+public class VisitTracker<K> {
     private int validateCount = 0;
     private int activateCount = 0;
     private int passivateCount = 0;
     private boolean destroyed = false;
     private int id = 0;
-    private Object key = null;
+    private K key = null;
     
     public VisitTracker() {
         super();
@@ -40,7 +40,7 @@ public class VisitTracker {
         reset();
     }
     
-    public VisitTracker(int id, Object key) {
+    public VisitTracker(int id, K key) {
         super();
         this.id = id;
         this.key = key;
@@ -90,9 +90,10 @@ public class VisitTracker {
     public int getId() {
         return id;
     }
-    public Object getKey() {
+    public K getKey() {
         return key;
     }
+    @Override
     public String toString() {
         return "Key: " + key + " id: " + id;
     }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTrackerFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTrackerFactory.java?rev=1096367&r1=1096366&r2=1096367&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTrackerFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/VisitTrackerFactory.java Sun
Apr 24 20:06:32 2011
@@ -25,41 +25,41 @@ import org.apache.commons.pool2.Poolable
  * test Evictor runs.
  *
  */
-public class VisitTrackerFactory implements PoolableObjectFactory, 
-    KeyedPoolableObjectFactory {
+public class VisitTrackerFactory<K> implements PoolableObjectFactory<VisitTracker<K>>,

+    KeyedPoolableObjectFactory<K,VisitTracker<K>> {
     private int nextId = 0;
     public VisitTrackerFactory() {
         super();
     }
-    public Object makeObject() {
-        return new VisitTracker(nextId++);
+    public VisitTracker<K> makeObject() {
+        return new VisitTracker<K>(nextId++);
     }
-    public Object makeObject(Object key) {
-        return new VisitTracker(nextId++, key);
+    public VisitTracker<K> makeObject(K key) {
+        return new VisitTracker<K>(nextId++, key);
     }
-    public void destroyObject(Object obj) {
-        ((VisitTracker) obj).destroy();
+    public void destroyObject(VisitTracker<K> obj) {
+        obj.destroy();
     }
-    public void destroyObject(Object key, Object obj) {
-        ((VisitTracker) obj).destroy();
+    public void destroyObject(K key, VisitTracker<K> obj) {
+        obj.destroy();
     }
-    public boolean validateObject(Object obj) {
-        return ((VisitTracker) obj).validate();
+    public boolean validateObject(VisitTracker<K> obj) {
+        return obj.validate();
     }
-    public boolean validateObject(Object key, Object obj) {
-        return ((VisitTracker) obj).validate();
+    public boolean validateObject(K key, VisitTracker<K> obj) {
+        return obj.validate();
     }
-    public void activateObject(Object obj) throws Exception {
-        ((VisitTracker) obj).activate();
+    public void activateObject(VisitTracker<K> obj) throws Exception {
+        obj.activate();
     }
-    public void activateObject(Object key, Object obj) throws Exception {
-        ((VisitTracker) obj).activate();
+    public void activateObject(K key, VisitTracker<K> obj) throws Exception {
+        obj.activate();
     }
-    public void passivateObject(Object obj) throws Exception {
-        ((VisitTracker) obj).passivate();
+    public void passivateObject(VisitTracker<K> obj) throws Exception {
+        obj.passivate();
     }
-    public void passivateObject(Object key, Object obj) throws Exception {
-        ((VisitTracker) obj).passivate();
+    public void passivateObject(K key, VisitTracker<K> obj) throws Exception {
+        obj.passivate();
     }
     public void resetId() {
         nextId = 0;



Mime
View raw message