1 8 9 package com.sleepycat.je.jca.ra; 10 11 import java.io.PrintWriter ; 12 import java.io.Serializable ; 13 import java.util.Iterator ; 14 import java.util.Set ; 15 16 import javax.resource.ResourceException ; 17 import javax.resource.spi.ConnectionManager ; 18 import javax.resource.spi.ConnectionRequestInfo ; 19 import javax.resource.spi.ManagedConnection ; 20 import javax.resource.spi.ManagedConnectionFactory ; 21 import javax.security.auth.Subject ; 22 23 import com.sleepycat.je.DbInternal; 24 import com.sleepycat.je.dbi.EnvironmentImpl; 25 26 public class JEManagedConnectionFactory 27 implements ManagedConnectionFactory , Serializable { 28 29 public JEManagedConnectionFactory() { 30 } 31 32 public Object createConnectionFactory(ConnectionManager cxManager) 33 throws ResourceException { 34 35 return new JEConnectionFactoryImpl(cxManager, this); 36 } 37 38 public Object createConnectionFactory() 39 throws ResourceException { 40 41 throw new UnsupportedOperationException ("must supply a connMgr"); 42 } 43 44 public ManagedConnection 45 createManagedConnection(Subject subject, 46 ConnectionRequestInfo info) 47 throws ResourceException { 48 49 JERequestInfo jeInfo = (JERequestInfo) info; 50 return new JEManagedConnection(subject, jeInfo); 51 } 52 53 public ManagedConnection 54 matchManagedConnections(Set connectionSet, 55 Subject subject, 56 ConnectionRequestInfo info) 57 throws ResourceException { 58 59 JERequestInfo jeInfo = (JERequestInfo) info; 60 Iterator iter = connectionSet.iterator(); 61 while (iter.hasNext()) { 62 Object next = iter.next(); 63 if (next instanceof JEManagedConnection) { 64 JEManagedConnection mc = (JEManagedConnection) next; 65 EnvironmentImpl nextEnvImpl = 66 DbInternal.envGetEnvironmentImpl(mc.getEnvironment()); 67 68 if (nextEnvImpl.getEnvironmentHome(). 69 equals(jeInfo.getJERootDir()) && 70 nextEnvImpl.isReadOnly() == 71 jeInfo.getEnvConfig().getReadOnly()) { 72 return mc; 73 } 74 } 75 } 76 return null; 77 } 78 79 public void setLogWriter(PrintWriter out) 80 throws ResourceException { 81 82 } 83 84 public PrintWriter getLogWriter() 85 throws ResourceException { 86 87 return null; 88 } 89 90 public boolean equals(Object obj) { 91 if (obj == null) { 92 return false; 93 } 94 95 if (obj instanceof JEManagedConnectionFactory) { 96 return true; 97 } else { 98 return false; 99 } 100 } 101 102 public int hashCode() { 103 return 0; 104 } 105 } 106 | Popular Tags |