1 24 package org.objectweb.jalisto.se.jca; 25 26 import javax.resource.ResourceException ; 27 import javax.resource.spi.*; 28 import javax.transaction.xa.XAException ; 29 import javax.transaction.xa.Xid ; 30 31 public class JalistoConnectionManager implements ConnectionManager { 32 public Object allocateConnection(ManagedConnectionFactory factory, ConnectionRequestInfo info) 33 throws ResourceException { 34 if (managedConnectionFactory == null) { 35 managedConnectionFactory = factory; 36 } else { 37 if (managedConnectionFactory != factory) { 38 throw new ResourceException ( 39 "JalistoConnectionManager : should always use the same ManagedConnectionFactory."); 40 } 41 } 42 ManagedConnection mc = managedConnectionFactory.createManagedConnection(null, info); 43 Object res = mc.getConnection(null, info); 44 mc.associateConnection(res); 45 try { 46 Xid xid = new JalistoXid(); 47 ((JalistoXAResourceWrapper) mc.getXAResource()).boundUnderlyingXaResource(xid); 48 } catch (XAException e) { 49 throw new ResourceException (e.getMessage()); 50 } 51 return res; 52 } 53 54 ManagedConnectionFactory managedConnectionFactory; 55 } 56 | Popular Tags |