1 package org.apache.ojb.otm.connector; 2 3 17 18 import org.apache.ojb.broker.Identity; 19 import org.apache.ojb.broker.PBKey; 20 import org.apache.ojb.otm.Kit; 21 import org.apache.ojb.otm.OTMConnection; 22 import org.apache.ojb.otm.copy.ObjectCopyStrategy; 23 import org.apache.ojb.otm.core.Transaction; 24 import org.apache.ojb.otm.lock.map.LockMap; 25 import org.apache.ojb.otm.lock.wait.LockWaitStrategy; 26 import org.apache.ojb.otm.swizzle.Swizzling; 27 28 import javax.naming.Reference ; 29 import javax.resource.Referenceable ; 30 import javax.resource.ResourceException ; 31 import javax.resource.spi.ConnectionManager ; 32 import javax.resource.spi.ManagedConnectionFactory ; 33 import java.io.Serializable ; 34 35 40 41 public class JCAKit implements Kit, Serializable , Referenceable 42 { 43 private OTMJCAManagedConnectionFactory m_managedConnectionFactory; 44 private ConnectionManager m_connectionManager; 45 private Reference m_reference; 46 47 public JCAKit(ManagedConnectionFactory mcf, ConnectionManager cm) 48 { 49 Util.log("In JCAKit"); 50 m_managedConnectionFactory = (OTMJCAManagedConnectionFactory) mcf; 51 52 if (cm == null) 53 m_connectionManager = new OTMConnectionManager(); 54 else 55 m_connectionManager = cm; 56 } 57 58 private Kit getKit() 59 { 60 try 61 { 62 return m_managedConnectionFactory.getKit(); 63 } 64 catch (ResourceException e) 65 { 66 throw new OTMConnectionRuntimeException(e); 67 } 68 } 69 70 73 public OTMConnection acquireConnection(PBKey pbkey) 74 { 75 Util.log("In JCAKit.getConnection,1"); 76 try 77 { 78 OTMConnectionRequestInfo info = new OTMConnectionRequestInfo(pbkey); 79 return (OTMConnection) m_connectionManager.allocateConnection(m_managedConnectionFactory, info); 80 } 81 catch (ResourceException ex) 82 { 83 throw new OTMConnectionRuntimeException(ex); 84 } 85 } 86 87 public Transaction getTransaction(OTMConnection otmConnection) 88 { 89 if (otmConnection instanceof OTMJCAConnection) 90 { 91 return getKit().getTransaction(((OTMJCAConnection)otmConnection).getConnection()); 92 } 93 else 94 return getKit().getTransaction(otmConnection); 95 } 96 97 public Swizzling getSwizzlingStrategy() 98 { 99 return getKit().getSwizzlingStrategy(); 100 } 101 102 public LockWaitStrategy getLockWaitStrategy() 103 { 104 return getKit().getLockWaitStrategy(); 105 } 106 107 public LockMap getLockMap() 108 { 109 return getKit().getLockMap(); 110 } 111 112 public ObjectCopyStrategy getCopyStrategy(Identity identity) 113 { 114 return getKit().getCopyStrategy(identity); 115 } 116 117 118 public boolean isImplicitLockingUsed() 119 { 120 return getKit().isImplicitLockingUsed(); 121 } 122 123 126 127 public void setReference(Reference reference) 128 { 129 this.m_reference = reference; 130 } 131 132 public Reference getReference() 133 { 134 return m_reference; 135 } 136 } 137 | Popular Tags |