1 28 29 package org.apache.commons.transaction.memory.jca; 30 31 import java.io.PrintWriter ; 32 import java.util.Iterator ; 33 import java.util.Set ; 34 35 import javax.resource.ResourceException ; 36 import javax.resource.spi.ConnectionManager ; 37 import javax.resource.spi.ConnectionRequestInfo ; 38 import javax.resource.spi.ManagedConnection ; 39 import javax.resource.spi.ManagedConnectionFactory ; 40 import javax.security.auth.Subject ; 41 42 43 48 public class MapManagedConnectionFactory implements ManagedConnectionFactory { 49 50 private PrintWriter writer; 51 52 55 public Object createConnectionFactory(ConnectionManager cm) 56 throws ResourceException { 57 58 return new MapConnectionFactory(this, cm); 59 } 60 61 64 public Object createConnectionFactory() throws ResourceException { 65 66 return new MapConnectionFactory(this, null); 67 } 68 69 72 public ManagedConnection createManagedConnection( 73 Subject subject, 74 ConnectionRequestInfo cxRequestInfo) 75 throws ResourceException { 76 77 return new MapManagedConnection(cxRequestInfo); 78 } 79 80 83 public ManagedConnection matchManagedConnections( 84 Set connectionSet, 85 Subject subject, 86 ConnectionRequestInfo cxRequestInfo) 87 throws ResourceException { 88 89 ManagedConnection match = null; 90 Iterator iterator = connectionSet.iterator(); 91 if (iterator.hasNext()) { 92 match = (ManagedConnection ) iterator.next(); 93 } 94 95 return match; 96 } 97 98 101 public void setLogWriter(PrintWriter writer) throws ResourceException { 102 103 this.writer = writer; 104 } 105 106 109 public PrintWriter getLogWriter() throws ResourceException { 110 111 return writer; 112 } 113 114 public boolean equals(Object other) { 115 116 if (other instanceof MapManagedConnectionFactory) { 117 return true; 118 } 119 return false; 120 } 121 122 public int hashCode() { 123 124 return 0; 125 } 126 } 127 | Popular Tags |