1 17 18 package org.apache.geronimo.connector.mock; 19 20 import javax.resource.ResourceException ; 21 import javax.resource.cci.Connection ; 22 import javax.resource.cci.ConnectionMetaData ; 23 import javax.resource.cci.Interaction ; 24 import javax.resource.cci.LocalTransaction ; 25 import javax.resource.cci.ResultSetInfo ; 26 import javax.security.auth.Subject ; 27 28 34 public class MockConnection implements Connection { 35 36 private MockManagedConnection managedConnection; 37 private Subject subject; 38 private MockConnectionRequestInfo connectionRequestInfo; 39 40 private boolean closed; 41 42 43 public MockConnection(MockManagedConnection managedConnection, Subject subject, MockConnectionRequestInfo connectionRequestInfo) { 44 this.managedConnection = managedConnection; 45 this.subject = subject; 46 this.connectionRequestInfo = connectionRequestInfo; 47 } 48 49 public Interaction createInteraction() throws ResourceException { 50 return null; 51 } 52 53 public LocalTransaction getLocalTransaction() throws ResourceException { 54 return new MockCCILocalTransaction(this); 55 } 56 57 public ConnectionMetaData getMetaData() throws ResourceException { 58 return null; 59 } 60 61 public ResultSetInfo getResultSetInfo() throws ResourceException { 62 return null; 63 } 64 65 public void close() throws ResourceException { 66 closed = true; 67 managedConnection.removeHandle(this); 68 managedConnection.closedEvent(this); 69 } 70 71 public void error() { 72 managedConnection.errorEvent(this); 73 } 74 75 public MockManagedConnection getManagedConnection() { 76 return managedConnection; 77 } 78 79 public Subject getSubject() { 80 return subject; 81 } 82 83 public MockConnectionRequestInfo getConnectionRequestInfo() { 84 return connectionRequestInfo; 85 } 86 87 public boolean isClosed() { 88 return closed; 89 } 90 91 public void reassociate(MockManagedConnection mockManagedConnection) { 92 assert managedConnection != null; 93 managedConnection.removeHandle(this); 94 managedConnection = mockManagedConnection; 95 subject = mockManagedConnection.getSubject(); 96 connectionRequestInfo = mockManagedConnection.getConnectionRequestInfo(); 97 } 98 } 99 | Popular Tags |