KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Removes a consumer, producer, session or connection.
26  *
27  * @openwire:marshaller code="12"
28  * @version $Revision$
29  */

30 public class RemoveInfo extends BaseCommand {
31     
32     public static final byte DATA_STRUCTURE_TYPE=CommandTypes.REMOVE_INFO;
33
34     protected DataStructure objectId;
35
36     public byte getDataStructureType() {
37         return DATA_STRUCTURE_TYPE;
38     }
39
40     public RemoveInfo() {
41     }
42     public RemoveInfo(DataStructure objectId) {
43         this.objectId=objectId;
44     }
45     
46     /**
47      * @openwire:property version=1 cache=true
48      */

49     public DataStructure getObjectId() {
50         return objectId;
51     }
52
53     public void setObjectId(DataStructure objectId) {
54         this.objectId = objectId;
55     }
56
57     public Response visit(CommandVisitor visitor) throws Exception JavaDoc {
58         switch (objectId.getDataStructureType()) {
59         case ConnectionId.DATA_STRUCTURE_TYPE:
60             return visitor.processRemoveConnection((ConnectionId) objectId);
61         case SessionId.DATA_STRUCTURE_TYPE:
62             return visitor.processRemoveSession((SessionId) objectId);
63         case ConsumerId.DATA_STRUCTURE_TYPE:
64             return visitor.processRemoveConsumer((ConsumerId) objectId);
65         case ProducerId.DATA_STRUCTURE_TYPE:
66             return visitor.processRemoveProducer((ProducerId) objectId);
67         default:
68             throw new IOException JavaDoc("Unknown remove command type: "+ objectId.getDataStructureType());
69         }
70     }
71     
72     /**
73      * Returns true if this event is for a removed connection
74      */

75     public boolean isConnectionRemove() {
76         return objectId.getDataStructureType() == ConnectionId.DATA_STRUCTURE_TYPE;
77     }
78     
79     /**
80      * Returns true if this event is for a removed session
81      */

82     public boolean isSessionRemove() {
83         return objectId.getDataStructureType() == SessionId.DATA_STRUCTURE_TYPE;
84     }
85     
86     /**
87      * Returns true if this event is for a removed consumer
88      */

89     public boolean isConsumerRemove() {
90         return objectId.getDataStructureType() == ConsumerId.DATA_STRUCTURE_TYPE;
91     }
92
93     /**
94      * Returns true if this event is for a removed producer
95      */

96     public boolean isProducerRemove() {
97         return objectId.getDataStructureType() == ProducerId.DATA_STRUCTURE_TYPE;
98     }
99
100 }
101
Popular Tags