1 package example; 2 3 import java.io.*; 4 import java.util.*; 5 6 import javax.resource.spi.ResourceAdapter ; 7 8 import javax.resource.spi.ManagedConnectionFactory ; 9 import javax.resource.spi.ManagedConnection ; 10 import javax.resource.spi.ConnectionManager ; 11 12 import javax.resource.spi.ManagedConnectionMetaData ; 13 import javax.resource.spi.ConnectionRequestInfo ; 14 15 import javax.security.auth.Subject ; 16 17 24 public class ManagedConnectionFactoryImpl implements ManagedConnectionFactory { 25 private String _name; 26 27 private int _mcCount; 30 31 private int _cCount; 34 35 38 public void setName(String name) 39 { 40 _name = name; 41 } 42 43 56 public Object createConnectionFactory(ConnectionManager manager) 57 { 58 return new ConnectionFactoryImpl(this, manager); 59 } 60 61 76 public ManagedConnection  77 createManagedConnection(Subject subject, ConnectionRequestInfo reqInfo) 78 { 79 return new ManagedConnectionImpl(_name + "-" + _mcCount++, this); 80 } 81 82 102 public ManagedConnection  103 matchManagedConnections(Set set, 104 Subject subject, 105 ConnectionRequestInfo reqInfo) 106 { 107 Iterator iter = set.iterator(); 108 109 while (iter.hasNext()) { 110 ManagedConnectionImpl mConn = (ManagedConnectionImpl) iter.next(); 111 112 return mConn; 114 } 115 116 return null; 117 } 118 119 127 public void setResourceAdapter(ResourceAdapter ra) 128 { 129 } 130 131 139 public ResourceAdapter getResourceAdapter() 140 { 141 return null; 142 } 143 144 149 public Object createConnectionFactory() 150 { 151 throw new UnsupportedOperationException (); 152 } 153 154 157 public PrintWriter getLogWriter() 158 { 159 return null; 160 } 161 162 165 public void setLogWriter(PrintWriter out) 166 { 167 } 168 169 172 public String generateConnectionName() 173 { 174 return _name + "-" + _cCount++ + "-conn"; 175 } 176 177 public String toString() 178 { 179 return "ManagedConnectionFactoryImpl[" + _name + "]"; 180 } 181 } 182
| Popular Tags
|