1 /*** 2 * 3 * Copyright 2004 Protique Ltd 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 19 package org.codehaus.activemq.transport; 20 import java.net.URI; 21 22 /*** 23 * A TransportStatusEvent is raised when the state of the underlying transport channel changes 24 * 25 * @version $Revision: 1.1 $ 26 */ 27 public class TransportStatusEvent { 28 /*** 29 * The channel has been intially and successfully connected 30 */ 31 public static final int CONNECTED = 1; 32 /*** 33 * The channel has been disconnected, but maybe reconnected 34 */ 35 public static final int DISCONNECTED = 2; 36 /*** 37 * The channel has successfully reconnected after a disconnect 38 */ 39 public static final int RECONNECTED = 3; 40 /*** 41 * The channel has failed 42 */ 43 public static final int FAILED = 4; 44 private URI remoteURI; 45 private int channelStatus; 46 47 /*** 48 * Default Constructor 49 */ 50 public TransportStatusEvent() { 51 } 52 53 /*** 54 * @return a pretty print of this 55 */ 56 public String toString() { 57 return "channel: " + remoteURI + " has " + getStatusAsString(channelStatus); 58 } 59 60 private String getStatusAsString(int status) { 61 String result = null; 62 switch (status) { 63 case CONNECTED : 64 result = "connected"; 65 break; 66 case DISCONNECTED : 67 result = "disconnected"; 68 break; 69 case RECONNECTED : 70 result = "reconnected"; 71 break; 72 case FAILED : 73 result = "failed"; 74 break; 75 default : 76 result = "unknown"; 77 } 78 return result; 79 } 80 81 /*** 82 * @return Returns the channelStatus. 83 */ 84 public int getChannelStatus() { 85 return channelStatus; 86 } 87 88 /*** 89 * @param channelStatus The channelStatus to set. 90 */ 91 public void setChannelStatus(int channelStatus) { 92 this.channelStatus = channelStatus; 93 } 94 95 /*** 96 * @return Returns the remoteURI. 97 */ 98 public URI getRemoteURI() { 99 return remoteURI; 100 } 101 102 /*** 103 * @param remoteURI The remoteURI to set. 104 */ 105 public void setRemoteURI(URI remoteURI) { 106 this.remoteURI = remoteURI; 107 } 108 }