Author: shawkins
Date: 2011-12-20 10:25:24 -0500 (Tue, 20 Dec 2011)
New Revision: 3752
Modified:
trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
Log:
minor cleanup of listeners
Modified: trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2011-12-19 20:24:05
UTC (rev 3751)
+++ trunk/client/src/main/java/org/teiid/jdbc/XAConnectionImpl.java 2011-12-20 15:25:24
UTC (rev 3752)
@@ -28,8 +28,10 @@
import java.lang.reflect.Proxy;
import java.sql.Connection;
import java.sql.SQLException;
-import java.util.HashSet;
+import java.util.Collections;
+import java.util.IdentityHashMap;
import java.util.Iterator;
+import java.util.Set;
import javax.sql.ConnectionEvent;
import javax.sql.ConnectionEventListener;
@@ -99,7 +101,7 @@
}
}
- private HashSet listeners;
+ private Set<ConnectionEventListener> listeners;
private XAResource resource;
private ConnectionImpl connection;
private ConnectionSource cs;
@@ -141,7 +143,7 @@
public synchronized void addConnectionEventListener(ConnectionEventListener listener){
if(listeners == null){
- listeners = new HashSet();
+ listeners = Collections.newSetFromMap(new IdentityHashMap<ConnectionEventListener,
Boolean>());
}
this.listeners.add(listener);
}
@@ -174,9 +176,9 @@
*/
protected synchronized void notifyListener(SQLException e){
if(listeners != null && !listeners.isEmpty()){
- Iterator iter = listeners.iterator();
+ Iterator<ConnectionEventListener> iter = listeners.iterator();
while(iter.hasNext()){
- ConnectionEventListener listener = (ConnectionEventListener)iter.next();
+ ConnectionEventListener listener = iter.next();
if(e == null){
//no exception
listener.connectionClosed(new ConnectionEvent(this));
Show replies by date