01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.connector.mock;
17:
18: import javax.resource.ResourceException;
19: import javax.resource.cci.Connection;
20: import javax.resource.cci.ConnectionMetaData;
21: import javax.resource.cci.Interaction;
22: import javax.resource.cci.LocalTransaction;
23: import javax.resource.cci.ResultSetInfo;
24: import javax.security.auth.Subject;
25:
26: /**
27: *
28: *
29: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
30: *
31: * */
32: public class MockConnection implements Connection {
33:
34: private MockManagedConnection managedConnection;
35: private Subject subject;
36: private MockConnectionRequestInfo connectionRequestInfo;
37:
38: private boolean closed;
39:
40: public MockConnection(MockManagedConnection managedConnection,
41: Subject subject,
42: MockConnectionRequestInfo connectionRequestInfo) {
43: this .managedConnection = managedConnection;
44: this .subject = subject;
45: this .connectionRequestInfo = connectionRequestInfo;
46: }
47:
48: public Interaction createInteraction() throws ResourceException {
49: return null;
50: }
51:
52: public LocalTransaction getLocalTransaction()
53: 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
97: .getConnectionRequestInfo();
98: }
99: }
|