001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018 package org.apache.geronimo.connector.outbound;
019
020 import java.util.Collection;
021
022 import javax.resource.spi.ConnectionRequestInfo;
023 import javax.resource.spi.ManagedConnection;
024 import javax.resource.spi.ManagedConnectionFactory;
025 import javax.security.auth.Subject;
026 import javax.transaction.xa.XAResource;
027
028 /**
029 * ConnectionRequest.java
030 *
031 *
032 * Created: Thu Sep 25 14:29:07 2003
033 *
034 * @version 1.0
035 */
036 public class ManagedConnectionInfo {
037
038 private ManagedConnectionFactory managedConnectionFactory;
039 private ConnectionRequestInfo connectionRequestInfo;
040 private Subject subject;
041 private ManagedConnection managedConnection;
042 private XAResource xares;
043 private long lastUsed;
044 private ConnectionInterceptor poolInterceptor;
045
046 private GeronimoConnectionEventListener listener;
047
048 public ManagedConnectionInfo(
049 ManagedConnectionFactory managedConnectionFactory,
050 ConnectionRequestInfo connectionRequestInfo) {
051 this.managedConnectionFactory = managedConnectionFactory;
052 this.connectionRequestInfo = connectionRequestInfo;
053 }
054
055 public ManagedConnectionFactory getManagedConnectionFactory() {
056 return managedConnectionFactory;
057 }
058
059 public void setManagedConnectionFactory(ManagedConnectionFactory managedConnectionFactory) {
060 this.managedConnectionFactory = managedConnectionFactory;
061 }
062
063 public ConnectionRequestInfo getConnectionRequestInfo() {
064 return connectionRequestInfo;
065 }
066
067 public void setConnectionRequestInfo(ConnectionRequestInfo cri) {
068 this.connectionRequestInfo = cri;
069 }
070
071 public Subject getSubject() {
072 return subject;
073 }
074
075 public void setSubject(Subject subject) {
076 this.subject = subject;
077 }
078
079 public ManagedConnection getManagedConnection() {
080 return managedConnection;
081 }
082
083 public void setManagedConnection(ManagedConnection managedConnection) {
084 assert this.managedConnection == null;
085 this.managedConnection = managedConnection;
086 }
087
088 public XAResource getXAResource() {
089 return xares;
090 }
091
092 public void setXAResource(XAResource xares) {
093 this.xares = xares;
094 }
095
096 public long getLastUsed() {
097 return lastUsed;
098 }
099
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<ConnectionInfo> 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 }