KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > command > DestinationInfo


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.command;
19
20 import java.io.IOException JavaDoc;
21
22 import org.apache.activemq.state.CommandVisitor;
23
24 /**
25  * Used to create and destroy destinations on the broker.
26  *
27  * @openwire:marshaller code="8"
28  * @version $Revision: 1.9 $
29  */

30 public class DestinationInfo extends BaseCommand {
31
32     public static final byte DATA_STRUCTURE_TYPE=CommandTypes.DESTINATION_INFO;
33
34     public static final byte ADD_OPERATION_TYPE=0;
35     public static final byte REMOVE_OPERATION_TYPE=1;
36     
37     protected ConnectionId connectionId;
38     protected ActiveMQDestination destination;
39     protected byte operationType;
40     protected long timeout;
41     protected BrokerId[] brokerPath;
42     
43     public DestinationInfo() {
44     }
45
46     public DestinationInfo(ConnectionId connectionId, byte operationType, ActiveMQDestination destination) {
47         this.connectionId=connectionId;
48         this.operationType=operationType;
49         this.destination=destination;
50     }
51
52     public byte getDataStructureType() {
53         return DATA_STRUCTURE_TYPE;
54     }
55     
56     public boolean isAddOperation() {
57         return operationType == ADD_OPERATION_TYPE;
58     }
59     
60     public boolean isRemoveOperation() {
61         return operationType == REMOVE_OPERATION_TYPE;
62     }
63     
64     /**
65      * @openwire:property version=1 cache=true
66      */

67     public ConnectionId getConnectionId() {
68         return connectionId;
69     }
70     public void setConnectionId(ConnectionId connectionId) {
71         this.connectionId = connectionId;
72     }
73
74     /**
75      * @openwire:property version=1 cache=true
76      */

77     public ActiveMQDestination getDestination() {
78         return destination;
79     }
80
81     public void setDestination(ActiveMQDestination destination) {
82         this.destination = destination;
83     }
84
85     /**
86      * @openwire:property version=1
87      */

88     public byte getOperationType() {
89         return operationType;
90     }
91
92     public void setOperationType(byte operationType) {
93         this.operationType = operationType;
94     }
95
96     /**
97      * @openwire:property version=1
98      */

99     public long getTimeout() {
100         return timeout;
101     }
102
103     public void setTimeout(long timeout) {
104         this.timeout = timeout;
105     }
106     
107     /**
108      * The route of brokers the command has moved through.
109      *
110      * @openwire:property version=1 cache=true
111      */

112     public BrokerId[] getBrokerPath() {
113         return brokerPath;
114     }
115     public void setBrokerPath(BrokerId[] brokerPath) {
116         this.brokerPath = brokerPath;
117     }
118
119     public Response visit(CommandVisitor visitor) throws Exception JavaDoc {
120         if( isAddOperation() ) {
121             return visitor.processAddDestination( this );
122         } else if( isRemoveOperation() ) {
123             return visitor.processRemoveDestination( this );
124         }
125         throw new IOException JavaDoc("Unknown operation type: "+getOperationType());
126     }
127     
128 }
129
Popular Tags