User: mulder
Date: 00/09/29 08:48:37
Modified: src/main/org/jboss/minerva/xa XAClientConnection.java
XAConnectionImpl.java
Log:
Implement PooledObject for XAConnectionImpl so it can pass along last-used
updates.
Revision Changes Path
1.3 +3 -1 jboss/src/main/org/jboss/minerva/xa/XAClientConnection.java
Index: XAClientConnection.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/minerva/xa/XAClientConnection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XAClientConnection.java 2000/08/30 16:17:06 1.2
+++ XAClientConnection.java 2000/09/29 15:48:36 1.3
@@ -22,6 +22,7 @@
import org.jboss.minerva.jdbc.PreparedStatementInPool;
import org.jboss.minerva.jdbc.PSCacheKey;
import org.jboss.minerva.jdbc.StatementInPool;
+import org.jboss.minerva.pools.PoolEvent;
/**
* Wrapper for database connections used by an XAConnection. When close is
@@ -30,7 +31,7 @@
* returned to the pool) until the transactional details are taken care of.
* This instance only lives as long as one client is using it - though we
* probably want to consider reusing it to save object allocations.
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
* @author Aaron Mulder ([EMAIL PROTECTED])
*/
public class XAClientConnection implements ConnectionWrapper {
@@ -79,6 +80,7 @@
* This is not used by the current implementation.
*/
public void setLastUsed() {
+ xaCon.firePoolEvent(new PoolEvent(xaCon, PoolEvent.OBJECT_USED));
}
/**
1.6 +32 -3 jboss/src/main/org/jboss/minerva/xa/XAConnectionImpl.java
Index: XAConnectionImpl.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/minerva/xa/XAConnectionImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XAConnectionImpl.java 2000/09/29 13:50:17 1.5
+++ XAConnectionImpl.java 2000/09/29 15:48:37 1.6
@@ -14,6 +14,9 @@
import javax.transaction.xa.XAResource;
import org.jboss.minerva.jdbc.PreparedStatementInPool;
import org.jboss.minerva.jdbc.PSCacheKey;
+import org.jboss.minerva.pools.PooledObject;
+import org.jboss.minerva.pools.PoolEvent;
+import org.jboss.minerva.pools.PoolEventListener;
/**
* A transaction wrapper around a java.sql.Connection. This provides access to
@@ -40,14 +43,14 @@
* also register a TransactionListener that will be notified when the
* Transaction is finished, and release the XAConnection at that time.</P>
* @see org.jboss.minerva.xa.TransactionListener
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
* @author Aaron Mulder ([EMAIL PROTECTED])
*/
-public class XAConnectionImpl implements XAConnection {
+public class XAConnectionImpl implements XAConnection, PooledObject {
private final static String CLOSED = "Connection has been closed!";
private Connection con;
private XAResourceImpl resource;
- private Vector listeners;
+ private Vector listeners, poolListeners;
private TransactionListener transListener;
private int clientConnectionCount = 0;
@@ -61,6 +64,7 @@
this.con = con;
this.resource = resource;
listeners = new Vector();
+ poolListeners = new Vector();
}
/**
@@ -175,4 +179,29 @@
++clientConnectionCount;
return new XAClientConnection(this, con);
}
+
+ // ---- Implementation of javax.sql.XAConnection ----
+
+ public void addPoolEventListener(PoolEventListener listener) {
+ poolListeners.addElement(listener);
+ }
+
+ public void removePoolEventListener(PoolEventListener listener) {
+ poolListeners.removeElement(listener);
+ }
+
+ /**
+ * Dispatches an event to the pool event listeners.
+ */
+ void firePoolEvent(PoolEvent evt) {
+ Vector local = (Vector)poolListeners.clone();
+ for(int i=local.size()-1; i >= 0; i--)
+ if(evt.getType() == PoolEvent.OBJECT_CLOSED)
+ ((PoolEventListener)local.elementAt(i)).objectClosed(evt);
+ else if(evt.getType() == PoolEvent.OBJECT_ERROR)
+ ((PoolEventListener)local.elementAt(i)).objectError(evt);
+ else
+ ((PoolEventListener)local.elementAt(i)).objectUsed(evt);
+ }
}
+