1 /** 2 * 3 * Copyright 2003-2004 The Apache Software Foundation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * 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; 21 22 import javax.resource.spi.ConnectionRequestInfo; 23 import javax.resource.spi.ManagedConnection; 24 import javax.resource.spi.ManagedConnectionFactory; 25 import javax.security.auth.Subject; 26 import javax.transaction.xa.XAResource; 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 managedConnectionFactory; 39 private ConnectionRequestInfo connectionRequestInfo; 40 private Subject subject; 41 private ManagedConnection managedConnection; 42 private XAResource xares; 43 private long lastUsed; 44 private ConnectionInterceptor poolInterceptor; 45 46 private GeronimoConnectionEventListener listener; 47 48 public ManagedConnectionInfo( 49 ManagedConnectionFactory managedConnectionFactory, 50 ConnectionRequestInfo connectionRequestInfo) { 51 this.managedConnectionFactory = managedConnectionFactory; 52 this.connectionRequestInfo = connectionRequestInfo; 53 } 54 55 public ManagedConnectionFactory getManagedConnectionFactory() { 56 return managedConnectionFactory; 57 } 58 59 public void setManagedConnectionFactory(ManagedConnectionFactory managedConnectionFactory) { 60 this.managedConnectionFactory = managedConnectionFactory; 61 } 62 63 public ConnectionRequestInfo getConnectionRequestInfo() { 64 return connectionRequestInfo; 65 } 66 67 public void setConnectionRequestInfo(ConnectionRequestInfo cri) { 68 this.connectionRequestInfo = cri; 69 } 70 71 public Subject getSubject() { 72 return subject; 73 } 74 75 public void setSubject(Subject subject) { 76 this.subject = subject; 77 } 78 79 public ManagedConnection getManagedConnection() { 80 return managedConnection; 81 } 82 83 public void setManagedConnection(ManagedConnection managedConnection) { 84 assert this.managedConnection == null; 85 this.managedConnection = managedConnection; 86 } 87 88 public XAResource getXAResource() { 89 return xares; 90 } 91 92 public void setXAResource(XAResource 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 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 }