1 package example; 2 3 import java.io.*; 4 import java.util.*; 5 6 import javax.resource.spi.ManagedConnection ; 7 import javax.resource.spi.ConnectionRequestInfo ; 8 import javax.resource.spi.ConnectionEventListener ; 9 import javax.resource.spi.ConnectionEvent ; 10 11 import javax.resource.spi.ManagedConnectionMetaData ; 12 import javax.resource.spi.LocalTransaction ; 13 14 import javax.transaction.xa.XAResource ; 15 16 import javax.security.auth.Subject ; 17 18 25 public class ManagedConnectionImpl implements ManagedConnection { 26 private ManagedConnectionFactoryImpl _factory; 27 28 private String _name; 30 31 private ArrayList _listeners = new ArrayList(); 33 34 39 ManagedConnectionImpl(String name, ManagedConnectionFactoryImpl factory) 40 { 41 _name = name; 42 _factory = factory; 43 } 44 45 61 public Object getConnection(Subject subject, ConnectionRequestInfo info) 62 { 63 return new ConnectionImpl(_factory.generateConnectionName(), this); 64 } 65 66 74 public void associateConnection(Object conn) 75 { 76 } 77 78 84 public void addConnectionEventListener(ConnectionEventListener listener) 85 { 86 _listeners.add(listener); 87 } 88 89 90 96 public void removeConnectionEventListener(ConnectionEventListener listener) 97 { 98 _listeners.remove(listener); 99 } 100 101 107 void close(ConnectionImpl conn) 108 { 109 ConnectionEvent evt; 110 evt = new ConnectionEvent (this, ConnectionEvent.CONNECTION_CLOSED); 111 112 for (int i = 0; i < _listeners.size(); i++) { 113 ConnectionEventListener listener; 114 listener = (ConnectionEventListener ) _listeners.get(i); 115 116 listener.connectionClosed(evt); 117 } 118 } 119 120 124 public ManagedConnectionMetaData getMetaData() 125 { 126 return null; 127 } 128 129 133 public XAResource getXAResource() 134 { 135 return null; 136 } 137 138 143 public LocalTransaction getLocalTransaction() 144 { 145 return null; 146 } 147 148 151 public void cleanup() 152 { 153 } 154 155 159 public void destroy() 160 { 161 } 162 163 166 public PrintWriter getLogWriter() 167 { 168 return null; 169 } 170 171 174 public void setLogWriter(PrintWriter log) 175 { 176 } 177 178 public String toString() 179 { 180 return "ManagedConnectionImpl[" + _name + "]"; 181 } 182 } 183 | Popular Tags |