Author: markt
Date: Wed Aug 31 22:06:15 2011
New Revision: 1163839
URL: http://svn.apache.org/viewvc?rev=1163839&view=rev
Log:
Add creation time to support additional stats and custom eviction policies.
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/PooledObject.java
Modified:
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/PooledObject.java
URL:
http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/PooledObject.java?rev=1163839&r1=1163838&r2=1163839&view=diff
==============================================================================
---
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/PooledObject.java
(original)
+++
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/PooledObject.java
Wed Aug 31 22:06:15 2011
@@ -25,6 +25,7 @@ public class PooledObject<T> implements
private T object = null;
private volatile PooledObjectState state = PooledObjectState.IDLE;
+ private long createTime = System.currentTimeMillis();
private long lastBorrowTime = System.currentTimeMillis();
private long lastReturnTime = System.currentTimeMillis();
@@ -41,6 +42,14 @@ public class PooledObject<T> implements
}
/**
+ * Obtain the time (using the same basis as
+ * {@link System#currentTimeMillis()}) that this object was created.
+ */
+ public long getCreateTime() {
+ return createTime;
+ }
+
+ /**
* Obtain the time in milliseconds that this object last spend in the the
* active state (it may still be active in which case subsequent calls will
* return an increased value).