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