1 22 package org.jboss.test.jca.adapter; 23 24 import javax.naming.NamingException ; 25 import javax.naming.Reference ; 26 import javax.resource.ResourceException ; 27 import javax.resource.cci.Connection ; 28 import javax.resource.cci.ConnectionFactory ; 29 import javax.resource.cci.ConnectionSpec ; 30 import javax.resource.cci.RecordFactory ; 31 import javax.resource.cci.ResourceAdapterMetaData ; 32 import javax.resource.spi.ConnectionManager ; 33 import javax.resource.Referenceable ; 34 35 import org.jboss.resource.connectionmanager.BaseConnectionManager2; 36 37 46 47 public class TestConnectionFactory implements ConnectionFactory , Referenceable 48 { 49 50 51 private static final long serialVersionUID = 1L; 52 53 private final ConnectionManager cm; 54 55 private final TestManagedConnectionFactory mcf; 56 57 private Reference ref; 58 59 public TestConnectionFactory(final ConnectionManager cm, final TestManagedConnectionFactory mcf) 60 { 61 this.cm = cm; 62 this.mcf = mcf; 63 } 64 65 67 71 public void setReference(Reference ref) 72 { 73 this.ref = ref; 74 } 75 76 78 83 public Reference getReference() throws NamingException 84 { 85 return ref; 86 } 87 88 90 95 public Connection getConnection() throws ResourceException 96 { 97 return (Connection ) cm.allocateConnection(mcf, null); 98 } 99 100 106 public Connection getConnection(ConnectionSpec ignore) throws ResourceException 107 { 108 return (Connection ) cm.allocateConnection(mcf, null); 109 } 110 111 public Connection getConnection(String failure) throws ResourceException 112 { 113 return (Connection ) cm.allocateConnection(mcf, new TestConnectionRequestInfo(failure)); 114 } 115 116 121 public RecordFactory getRecordFactory() throws ResourceException 122 { 123 return null; 125 } 126 127 132 public ResourceAdapterMetaData getMetaData() throws ResourceException 133 { 134 return null; 136 } 137 138 public void setFailure(String failure) 139 { 140 mcf.setFailure(failure); 141 } 142 143 } 144 | Popular Tags |