KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > outbound > ManagedConnectionInfo


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.outbound;
19
20 import java.util.Collection JavaDoc;
21
22 import javax.resource.spi.ConnectionRequestInfo JavaDoc;
23 import javax.resource.spi.ManagedConnection JavaDoc;
24 import javax.resource.spi.ManagedConnectionFactory JavaDoc;
25 import javax.security.auth.Subject JavaDoc;
26 import javax.transaction.xa.XAResource JavaDoc;
27
28 /**
29  * ConnectionRequest.java
30  *
31  *
32  * Created: Thu Sep 25 14:29:07 2003
33  *
34  * @version 1.0
35  */

36 public class ManagedConnectionInfo {
37
38     private ManagedConnectionFactory JavaDoc managedConnectionFactory;
39     private ConnectionRequestInfo JavaDoc connectionRequestInfo;
40     private Subject JavaDoc subject;
41     private ManagedConnection JavaDoc managedConnection;
42     private XAResource JavaDoc xares;
43     private long lastUsed;
44     private ConnectionInterceptor poolInterceptor;
45
46     private GeronimoConnectionEventListener listener;
47
48     public ManagedConnectionInfo(
49             ManagedConnectionFactory JavaDoc managedConnectionFactory,
50             ConnectionRequestInfo JavaDoc connectionRequestInfo) {
51         this.managedConnectionFactory = managedConnectionFactory;
52         this.connectionRequestInfo = connectionRequestInfo;
53     }
54
55     public ManagedConnectionFactory JavaDoc getManagedConnectionFactory() {
56         return managedConnectionFactory;
57     }
58
59     public void setManagedConnectionFactory(ManagedConnectionFactory JavaDoc managedConnectionFactory) {
60         this.managedConnectionFactory = managedConnectionFactory;
61     }
62
63     public ConnectionRequestInfo JavaDoc getConnectionRequestInfo() {
64         return connectionRequestInfo;
65     }
66
67     public void setConnectionRequestInfo(ConnectionRequestInfo JavaDoc cri) {
68         this.connectionRequestInfo = cri;
69     }
70
71     public Subject JavaDoc getSubject() {
72         return subject;
73     }
74
75     public void setSubject(Subject JavaDoc subject) {
76         this.subject = subject;
77     }
78
79     public ManagedConnection JavaDoc getManagedConnection() {
80         return managedConnection;
81     }
82
83     public void setManagedConnection(ManagedConnection JavaDoc managedConnection) {
84         assert this.managedConnection == null;
85         this.managedConnection = managedConnection;
86     }
87
88     public XAResource JavaDoc getXAResource() {
89         return xares;
90     }
91
92     public void setXAResource(XAResource JavaDoc xares) {
93         this.xares = xares;
94     }
95
96     public long getLastUsed() {
97         return lastUsed;
98     }
99
100     public void setLastUsed(long lastUsed) {
101         this.lastUsed = lastUsed;
102     }
103
104     public void setPoolInterceptor(ConnectionInterceptor poolInterceptor) {
105         this.poolInterceptor = poolInterceptor;
106     }
107
108     public ConnectionInterceptor getPoolInterceptor() {
109         return poolInterceptor;
110     }
111
112     public void setConnectionEventListener(GeronimoConnectionEventListener listener) {
113         this.listener = listener;
114     }
115
116     public void addConnectionHandle(ConnectionInfo connectionInfo) {
117         listener.addConnectionInfo(connectionInfo);
118     }
119
120     public void removeConnectionHandle(ConnectionInfo connectionInfo) {
121         listener.removeConnectionInfo(connectionInfo);
122     }
123
124     public boolean hasConnectionHandles() {
125         return listener.hasConnectionInfos();
126     }
127
128     public void clearConnectionHandles() {
129         listener.clearConnectionInfos();
130     }
131
132     public Collection JavaDoc getConnectionInfos() {
133         return listener.getConnectionInfos();
134     }
135
136     public boolean securityMatches(ManagedConnectionInfo other) {
137         return (
138                 subject == null
139                 ? other.getSubject() == null
140                 : subject.equals(other.getSubject()))
141                 && (connectionRequestInfo == null
142                 ? other.getConnectionRequestInfo() == null
143                 : connectionRequestInfo.equals(other.getConnectionRequestInfo()));
144     }
145
146     public boolean hasConnectionInfo(ConnectionInfo connectionInfo) {
147         return listener.hasConnectionInfo(connectionInfo);
148     }
149
150     public boolean isFirstConnectionInfo(ConnectionInfo connectionInfo) {
151         return listener.isFirstConnectionInfo(connectionInfo);
152     }
153
154 }
155
Popular Tags