KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > virtual > VirtualTopic


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.broker.region.virtual;
19
20 import org.apache.activemq.broker.region.Destination;
21 import org.apache.activemq.command.ActiveMQDestination;
22 import org.apache.activemq.command.ActiveMQQueue;
23 import org.apache.activemq.command.ActiveMQTopic;
24
25 /**
26  * Creates <a HREF="http://activemq.org/site/virtual-destinations.html">Virtual
27  * Topics</a> using a prefix and postfix. The virtual destination creates a
28  * wildcard that is then used to look up all active queue subscriptions which
29  * match.
30  *
31  * @org.apache.xbean.XBean
32  *
33  * @version $Revision: 426366 $
34  */

35 public class VirtualTopic implements VirtualDestination {
36
37     private String JavaDoc prefix = "Consumer.*.";
38     private String JavaDoc postfix = "";
39     private String JavaDoc name = ">";
40
41
42     public ActiveMQDestination getVirtualDestination() {
43         return new ActiveMQTopic(getName());
44     }
45
46     public Destination intercept(Destination destination) {
47         return new VirtualTopicInterceptor(destination, getPrefix(), getPostfix());
48     }
49     
50     // Properties
51
// -------------------------------------------------------------------------
52

53     public String JavaDoc getPostfix() {
54         return postfix;
55     }
56
57     /**
58      * Sets any postix used to identify the queue consumers
59      */

60     public void setPostfix(String JavaDoc postfix) {
61         this.postfix = postfix;
62     }
63
64     public String JavaDoc getPrefix() {
65         return prefix;
66     }
67
68     /**
69      * Sets the prefix wildcard used to identify the queue consumers for a given
70      * topic
71      */

72     public void setPrefix(String JavaDoc prefix) {
73         this.prefix = prefix;
74     }
75
76     public String JavaDoc getName() {
77         return name;
78     }
79
80     public void setName(String JavaDoc name) {
81         this.name = name;
82     }
83
84     // Implementation methods
85
// -------------------------------------------------------------------------
86
protected ActiveMQDestination getQueueConsumersWildcard(ActiveMQDestination original) {
87         return new ActiveMQQueue(prefix + original.getPhysicalName() + postfix);
88     }
89
90
91 }
92
Popular Tags