1 22 package org.jboss.test.jca.fs; 23 24 import javax.resource.spi.ConnectionManager ; 25 import javax.resource.spi.ManagedConnectionFactory ; 26 import javax.resource.ResourceException ; 27 import javax.naming.NamingException ; 28 import javax.naming.Reference ; 29 import javax.naming.directory.DirContext ; 30 31 import org.jboss.logging.Logger; 32 33 37 public class DirContextFactoryImpl implements DirContextFactory 38 { 39 static Logger log = Logger.getLogger(DirContextFactoryImpl.class); 40 private transient ConnectionManager manager; 41 private transient ManagedConnectionFactory factory; 42 private transient FSRequestInfo fsInfo; 43 private Reference reference; 44 45 DirContextFactoryImpl(ConnectionManager manager, 46 ManagedConnectionFactory factory, FSRequestInfo fsInfo) 47 { 48 this.manager = manager; 49 this.factory = factory; 50 this.fsInfo = fsInfo; 51 log.debug("ctor, fsInfo="+fsInfo); 52 } 53 54 public DirContext getConnection() throws NamingException 55 { 56 log.debug("getConnection", new Exception ("CalledBy:")); 57 DirContext dc = null; 58 try 59 { 60 dc = (DirContext ) manager.allocateConnection(factory, fsInfo); 61 } 62 catch(ResourceException e) 63 { 64 throw new NamingException ("Unable to get Connection: "+e); 65 } 66 return dc; 67 } 68 public DirContext getConnection(String user, String password) throws NamingException 69 { 70 log.debug("getConnection, user="+user); 71 DirContext dc = null; 72 try 73 { 74 dc = (DirContext ) manager.allocateConnection(factory, fsInfo); 75 } 76 catch(ResourceException e) 77 { 78 throw new NamingException ("Unable to get Connection: "+e); 79 } 80 return dc; 81 } 82 83 public void setReference(Reference reference) 84 { 85 log.debug("setReference, reference="+reference, new Exception ("CalledBy:")); 86 this.reference = reference; 87 } 88 89 public Reference getReference() throws NamingException 90 { 91 log.debug("getReference"); 92 return reference; 93 } 94 } 95 | Popular Tags |