1 8 9 package com.sleepycat.je.jca.ra; 10 11 import java.io.File ; 12 13 import javax.naming.NamingException ; 14 import javax.naming.Reference ; 15 import javax.resource.ResourceException ; 16 import javax.resource.spi.ConnectionManager ; 17 import javax.resource.spi.ManagedConnectionFactory ; 18 19 import com.sleepycat.je.EnvironmentConfig; 20 import com.sleepycat.je.TransactionConfig; 21 22 public class JEConnectionFactoryImpl implements JEConnectionFactory { 23 24 28 private ConnectionManager manager; 29 private ManagedConnectionFactory factory; 30 private Reference reference; 31 32 JEConnectionFactoryImpl(ConnectionManager manager, 33 ManagedConnectionFactory factory) { 34 this.manager = manager; 35 this.factory = factory; 36 } 37 38 public JEConnection getConnection(String jeRootDir, 39 EnvironmentConfig envConfig) 40 throws JEException { 41 42 return getConnection(jeRootDir, envConfig, null); 43 } 44 45 46 public JEConnection getConnection(String jeRootDir, 47 EnvironmentConfig envConfig, 48 TransactionConfig transConfig) 49 throws JEException { 50 51 JEConnection dc = null; 52 JERequestInfo jeInfo = 53 new JERequestInfo(new File (jeRootDir), envConfig, transConfig); 54 try { 55 dc = (JEConnection) manager.allocateConnection(factory, jeInfo); 56 } catch (ResourceException e) { 57 throw new JEException("Unable to get Connection: " + e); 58 } 59 60 return dc; 61 } 62 63 public void setReference(Reference reference) { 64 this.reference = reference; 65 } 66 67 public Reference getReference() 68 throws NamingException { 69 70 return reference; 71 } 72 } 73 | Popular Tags |