KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > mock > MockConnection


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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  */

17
18 package org.apache.geronimo.connector.mock;
19
20 import javax.resource.ResourceException JavaDoc;
21 import javax.resource.cci.Connection JavaDoc;
22 import javax.resource.cci.ConnectionMetaData JavaDoc;
23 import javax.resource.cci.Interaction JavaDoc;
24 import javax.resource.cci.LocalTransaction JavaDoc;
25 import javax.resource.cci.ResultSetInfo JavaDoc;
26 import javax.security.auth.Subject JavaDoc;
27
28 /**
29  *
30  *
31  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
32  *
33  * */

34 public class MockConnection implements Connection JavaDoc {
35
36     private MockManagedConnection managedConnection;
37     private Subject JavaDoc subject;
38     private MockConnectionRequestInfo connectionRequestInfo;
39
40     private boolean closed;
41
42
43     public MockConnection(MockManagedConnection managedConnection, Subject JavaDoc subject, MockConnectionRequestInfo connectionRequestInfo) {
44         this.managedConnection = managedConnection;
45         this.subject = subject;
46         this.connectionRequestInfo = connectionRequestInfo;
47     }
48
49     public Interaction JavaDoc createInteraction() throws ResourceException JavaDoc {
50         return null;
51     }
52
53     public LocalTransaction JavaDoc getLocalTransaction() throws ResourceException JavaDoc {
54         return new MockCCILocalTransaction(this);
55     }
56
57     public ConnectionMetaData JavaDoc getMetaData() throws ResourceException JavaDoc {
58         return null;
59     }
60
61     public ResultSetInfo JavaDoc getResultSetInfo() throws ResourceException JavaDoc {
62         return null;
63     }
64
65     public void close() throws ResourceException JavaDoc {
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 JavaDoc 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