1 23 24 package org.objectweb.perseus.connector.manager.standalone; 25 26 import javax.resource.ResourceException ; 27 import javax.resource.spi.ConnectionManager ; 28 import javax.resource.spi.ConnectionRequestInfo ; 29 import javax.resource.spi.ManagedConnection ; 30 import javax.resource.spi.ManagedConnectionFactory ; 31 32 35 public class SaManager 36 implements ConnectionManager , SaManagerAttributeControler { 37 41 ManagedConnectionFactory managedConnectionFactory = null; 42 43 45 49 public Object allocateConnection( 50 ManagedConnectionFactory factory, 51 ConnectionRequestInfo info) 52 throws ResourceException { 53 if (managedConnectionFactory == null) 54 managedConnectionFactory = factory; 55 else if (managedConnectionFactory != factory) 56 throw new ResourceException ("SAM: should always use the same ManagedConnectionFactory."); 57 ManagedConnection mc 59 = managedConnectionFactory.createManagedConnection(null, info); 60 Object res = mc.getConnection(null, info); 61 mc.associateConnection(res); 62 return res; 63 } 64 65 67 71 public ManagedConnectionFactory getManagedConnectionFactory() { 72 return managedConnectionFactory; 73 } 74 75 82 public void setManagedConnectionFactory(ManagedConnectionFactory mcf) { 83 managedConnectionFactory = mcf; 84 } 85 } | Popular Tags |