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 package org.apache.activemq.command; 018 019 import org.apache.activemq.state.CommandVisitor; 020 021 /** 022 * 023 * @openwire:marshaller code="3" 024 * @version $Revision: 1.11 $ 025 */ 026 public class ConnectionInfo extends BaseCommand { 027 028 public static final byte DATA_STRUCTURE_TYPE = CommandTypes.CONNECTION_INFO; 029 030 protected ConnectionId connectionId; 031 protected String clientId; 032 protected String userName; 033 protected String password; 034 protected BrokerId[] brokerPath; 035 protected boolean brokerMasterConnector; 036 protected boolean manageable; 037 protected boolean clientMaster = true; 038 protected transient Object transportContext; 039 040 public ConnectionInfo() { 041 } 042 043 public ConnectionInfo(ConnectionId connectionId) { 044 this.connectionId = connectionId; 045 } 046 047 public byte getDataStructureType() { 048 return DATA_STRUCTURE_TYPE; 049 } 050 051 public ConnectionInfo copy() { 052 ConnectionInfo copy = new ConnectionInfo(); 053 copy(copy); 054 return copy; 055 } 056 057 private void copy(ConnectionInfo copy) { 058 super.copy(copy); 059 copy.connectionId = connectionId; 060 copy.clientId = clientId; 061 copy.userName = userName; 062 copy.password = password; 063 copy.brokerPath = brokerPath; 064 copy.brokerMasterConnector = brokerMasterConnector; 065 copy.manageable = manageable; 066 copy.clientMaster = clientMaster; 067 copy.transportContext = transportContext; 068 } 069 070 /** 071 * @openwire:property version=1 cache=true 072 */ 073 public ConnectionId getConnectionId() { 074 return connectionId; 075 } 076 077 public void setConnectionId(ConnectionId connectionId) { 078 this.connectionId = connectionId; 079 } 080 081 /** 082 * @openwire:property version=1 083 */ 084 public String getClientId() { 085 return clientId; 086 } 087 088 public void setClientId(String clientId) { 089 this.clientId = clientId; 090 } 091 092 public RemoveInfo createRemoveCommand() { 093 RemoveInfo command = new RemoveInfo(getConnectionId()); 094 command.setResponseRequired(isResponseRequired()); 095 return command; 096 } 097 098 /** 099 * @openwire:property version=1 100 */ 101 public String getPassword() { 102 return password; 103 } 104 105 public void setPassword(String password) { 106 this.password = password; 107 } 108 109 /** 110 * @openwire:property version=1 111 */ 112 public String getUserName() { 113 return userName; 114 } 115 116 public void setUserName(String userName) { 117 this.userName = userName; 118 } 119 120 /** 121 * The route of brokers the command has moved through. 122 * 123 * @openwire:property version=1 cache=true 124 */ 125 public BrokerId[] getBrokerPath() { 126 return brokerPath; 127 } 128 129 public void setBrokerPath(BrokerId[] brokerPath) { 130 this.brokerPath = brokerPath; 131 } 132 133 public Response visit(CommandVisitor visitor) throws Exception { 134 return visitor.processAddConnection(this); 135 } 136 137 /** 138 * @openwire:property version=1 139 */ 140 public boolean isBrokerMasterConnector() { 141 return brokerMasterConnector; 142 } 143 144 /** 145 * @param slaveBroker The brokerMasterConnector to set. 146 */ 147 public void setBrokerMasterConnector(boolean slaveBroker) { 148 this.brokerMasterConnector = slaveBroker; 149 } 150 151 /** 152 * @openwire:property version=1 153 */ 154 public boolean isManageable() { 155 return manageable; 156 } 157 158 /** 159 * @param manageable The manageable to set. 160 */ 161 public void setManageable(boolean manageable) { 162 this.manageable = manageable; 163 } 164 165 /** 166 * Transports may wish to associate additional data with the connection. For 167 * example, an SSL transport may use this field to attach the client 168 * certificates used when the conection was established. 169 * 170 * @return the transport context. 171 */ 172 public Object getTransportContext() { 173 return transportContext; 174 } 175 176 /** 177 * Transports may wish to associate additional data with the connection. For 178 * example, an SSL transport may use this field to attach the client 179 * certificates used when the conection was established. 180 * 181 * @param transportContext value used to set the transport context 182 */ 183 public void setTransportContext(Object transportContext) { 184 this.transportContext = transportContext; 185 } 186 187 /** 188 * @openwire:property version=2 189 * @return the clientMaster 190 */ 191 public boolean isClientMaster() { 192 return this.clientMaster; 193 } 194 195 /** 196 * @param clientMaster the clientMaster to set 197 */ 198 public void setClientMaster(boolean clientMaster) { 199 this.clientMaster = clientMaster; 200 } 201 202 }