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 *
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 clientIp;
033 protected String userName;
034 protected String password;
035 protected BrokerId[] brokerPath;
036 protected boolean brokerMasterConnector;
037 protected boolean manageable;
038 protected boolean clientMaster = true;
039 protected boolean faultTolerant = false;
040 protected boolean failoverReconnect;
041 protected transient Object transportContext;
042
043 public ConnectionInfo() {
044 }
045
046 public ConnectionInfo(ConnectionId connectionId) {
047 this.connectionId = connectionId;
048 }
049
050 public byte getDataStructureType() {
051 return DATA_STRUCTURE_TYPE;
052 }
053
054 public ConnectionInfo copy() {
055 ConnectionInfo copy = new ConnectionInfo();
056 copy(copy);
057 return copy;
058 }
059
060 private void copy(ConnectionInfo copy) {
061 super.copy(copy);
062 copy.connectionId = connectionId;
063 copy.clientId = clientId;
064 copy.userName = userName;
065 copy.password = password;
066 copy.brokerPath = brokerPath;
067 copy.brokerMasterConnector = brokerMasterConnector;
068 copy.manageable = manageable;
069 copy.clientMaster = clientMaster;
070 copy.transportContext = transportContext;
071 copy.faultTolerant= faultTolerant;
072 copy.clientIp = clientIp;
073 }
074
075 /**
076 * @openwire:property version=1 cache=true
077 */
078 public ConnectionId getConnectionId() {
079 return connectionId;
080 }
081
082 public void setConnectionId(ConnectionId connectionId) {
083 this.connectionId = connectionId;
084 }
085
086 /**
087 * @openwire:property version=1
088 */
089 public String getClientId() {
090 return clientId;
091 }
092
093 public void setClientId(String clientId) {
094 this.clientId = clientId;
095 }
096
097 public RemoveInfo createRemoveCommand() {
098 RemoveInfo command = new RemoveInfo(getConnectionId());
099 command.setResponseRequired(isResponseRequired());
100 return command;
101 }
102
103 /**
104 * @openwire:property version=1
105 */
106 public String getPassword() {
107 return password;
108 }
109
110 public void setPassword(String password) {
111 this.password = password;
112 }
113
114 /**
115 * @openwire:property version=1
116 */
117 public String getUserName() {
118 return userName;
119 }
120
121 public void setUserName(String userName) {
122 this.userName = userName;
123 }
124
125 /**
126 * The route of brokers the command has moved through.
127 *
128 * @openwire:property version=1 cache=true
129 */
130 public BrokerId[] getBrokerPath() {
131 return brokerPath;
132 }
133
134 public void setBrokerPath(BrokerId[] brokerPath) {
135 this.brokerPath = brokerPath;
136 }
137
138 public Response visit(CommandVisitor visitor) throws Exception {
139 return visitor.processAddConnection(this);
140 }
141
142 /**
143 * @openwire:property version=1
144 */
145 public boolean isBrokerMasterConnector() {
146 return brokerMasterConnector;
147 }
148
149 /**
150 * @param slaveBroker The brokerMasterConnector to set.
151 */
152 public void setBrokerMasterConnector(boolean slaveBroker) {
153 this.brokerMasterConnector = slaveBroker;
154 }
155
156 /**
157 * @openwire:property version=1
158 */
159 public boolean isManageable() {
160 return manageable;
161 }
162
163 /**
164 * @param manageable The manageable to set.
165 */
166 public void setManageable(boolean manageable) {
167 this.manageable = manageable;
168 }
169
170 /**
171 * Transports may wish to associate additional data with the connection. For
172 * example, an SSL transport may use this field to attach the client
173 * certificates used when the conection was established.
174 *
175 * @return the transport context.
176 */
177 public Object getTransportContext() {
178 return transportContext;
179 }
180
181 /**
182 * Transports may wish to associate additional data with the connection. For
183 * example, an SSL transport may use this field to attach the client
184 * certificates used when the conection was established.
185 *
186 * @param transportContext value used to set the transport context
187 */
188 public void setTransportContext(Object transportContext) {
189 this.transportContext = transportContext;
190 }
191
192 /**
193 * @openwire:property version=2
194 * @return the clientMaster
195 */
196 public boolean isClientMaster() {
197 return this.clientMaster;
198 }
199
200 /**
201 * @param clientMaster the clientMaster to set
202 */
203 public void setClientMaster(boolean clientMaster) {
204 this.clientMaster = clientMaster;
205 }
206
207 /**
208 * @openwire:property version=6 cache=false
209 * @return the faultTolerant
210 */
211 public boolean isFaultTolerant() {
212 return this.faultTolerant;
213 }
214
215 /**
216 * @param faultTolerant the faultTolerant to set
217 */
218 public void setFaultTolerant(boolean faultTolerant) {
219 this.faultTolerant = faultTolerant;
220 }
221
222 /**
223 * @openwire:property version=6 cache=false
224 * @return failoverReconnect true if this is a reconnect
225 */
226 public boolean isFailoverReconnect() {
227 return this.failoverReconnect;
228 }
229
230 public void setFailoverReconnect(boolean failoverReconnect) {
231 this.failoverReconnect = failoverReconnect;
232 }
233
234 /**
235 * @openwire:property version=8
236 */
237 public String getClientIp() {
238 return clientIp;
239 }
240
241 public void setClientIp(String clientIp) {
242 this.clientIp = clientIp;
243 }
244 }