KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > DestinationFilter


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;
19
20 import org.apache.activemq.broker.Broker;
21 import org.apache.activemq.broker.ConnectionContext;
22 import org.apache.activemq.broker.ProducerBrokerExchange;
23 import org.apache.activemq.broker.region.policy.DeadLetterStrategy;
24 import org.apache.activemq.command.ActiveMQDestination;
25 import org.apache.activemq.command.Message;
26 import org.apache.activemq.command.MessageAck;
27 import org.apache.activemq.memory.UsageManager;
28
29 import java.io.IOException JavaDoc;
30 import java.util.Iterator JavaDoc;
31 import java.util.Set JavaDoc;
32
33 /**
34  *
35  * @version $Revision: 516444 $
36  */

37 public class DestinationFilter implements Destination {
38
39     private Destination next;
40
41     public DestinationFilter(Destination next) {
42         this.next = next;
43     }
44
45     public void acknowledge(ConnectionContext context, Subscription sub, MessageAck ack, MessageReference node) throws IOException JavaDoc {
46         next.acknowledge(context, sub, ack, node);
47     }
48
49     public void addSubscription(ConnectionContext context, Subscription sub) throws Exception JavaDoc {
50         next.addSubscription(context, sub);
51     }
52
53     public Message[] browse() {
54         return next.browse();
55     }
56
57     public void dispose(ConnectionContext context) throws IOException JavaDoc {
58         next.dispose(context);
59     }
60
61     public void gc() {
62         next.gc();
63     }
64
65     public ActiveMQDestination getActiveMQDestination() {
66         return next.getActiveMQDestination();
67     }
68
69     public DeadLetterStrategy getDeadLetterStrategy() {
70         return next.getDeadLetterStrategy();
71     }
72
73     public DestinationStatistics getDestinationStatistics() {
74         return next.getDestinationStatistics();
75     }
76
77     public String JavaDoc getName() {
78         return next.getName();
79     }
80
81     public UsageManager getUsageManager() {
82         return next.getUsageManager();
83     }
84
85     public boolean lock(MessageReference node, LockOwner lockOwner) {
86         return next.lock(node, lockOwner);
87     }
88
89     public void removeSubscription(ConnectionContext context, Subscription sub) throws Exception JavaDoc {
90         next.removeSubscription(context, sub);
91     }
92
93     public void send(ProducerBrokerExchange context, Message messageSend) throws Exception JavaDoc {
94         next.send(context, messageSend);
95     }
96
97     public void start() throws Exception JavaDoc {
98         next.start();
99     }
100
101     public void stop() throws Exception JavaDoc {
102         next.stop();
103     }
104
105     /**
106      * Sends a message to the given destination which may be a wildcard
107      */

108     protected void send(ProducerBrokerExchange context, Message message, ActiveMQDestination destination) throws Exception JavaDoc {
109         Broker broker = context.getConnectionContext().getBroker();
110         Set JavaDoc destinations = broker.getDestinations(destination);
111
112         for (Iterator JavaDoc iter = destinations.iterator(); iter.hasNext();) {
113             Destination dest = (Destination) iter.next();
114             dest.send(context, message);
115         }
116     }
117 }
118
Popular Tags