KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > filter > DestinationMapEntry


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.filter;
19
20 import org.apache.activemq.command.ActiveMQDestination;
21 import org.apache.activemq.command.ActiveMQQueue;
22 import org.apache.activemq.command.ActiveMQTopic;
23 import org.springframework.beans.factory.InitializingBean;
24
25 /**
26  * A base class for entry objects used to construct a destination based policy
27  * map.
28  *
29  * @version $Revision: 1.1 $
30  */

31 public abstract class DestinationMapEntry implements InitializingBean, Comparable JavaDoc {
32
33     private ActiveMQDestination destination;
34
35     
36     public int compareTo(Object JavaDoc that) {
37         if (that instanceof DestinationMapEntry) {
38             DestinationMapEntry thatEntry = (DestinationMapEntry) that;
39             return ActiveMQDestination.compare(destination, thatEntry.destination);
40         }
41         else if (that == null) {
42             return 1;
43         }
44         else {
45             return getClass().getName().compareTo(that.getClass().getName());
46         }
47     }
48
49     /**
50      * A helper method to set the destination from a configuration file
51      */

52     public void setQueue(String JavaDoc name) {
53         setDestination(new ActiveMQQueue(name));
54     }
55
56     /**
57      * A helper method to set the destination from a configuration file
58      */

59     public void setTopic(String JavaDoc name) {
60         setDestination(new ActiveMQTopic(name));
61     }
62
63     public ActiveMQDestination getDestination() {
64         return destination;
65     }
66
67     public void setDestination(ActiveMQDestination destination) {
68         this.destination = destination;
69     }
70
71     public void afterPropertiesSet() throws Exception JavaDoc {
72         if (destination == null) {
73             throw new IllegalArgumentException JavaDoc("You must specify the 'destination' property");
74         }
75     }
76
77     public Object JavaDoc getValue() {
78         return this;
79     }
80 }
81
Popular Tags