KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > MutableBrokerFilter


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;
19
20 import org.apache.activemq.broker.region.Destination;
21 import org.apache.activemq.broker.region.Subscription;
22 import org.apache.activemq.broker.region.policy.PendingDurableSubscriberMessageStoragePolicy;
23 import org.apache.activemq.command.ActiveMQDestination;
24 import org.apache.activemq.command.BrokerId;
25 import org.apache.activemq.command.BrokerInfo;
26 import org.apache.activemq.command.ConnectionInfo;
27 import org.apache.activemq.command.ConsumerInfo;
28 import org.apache.activemq.command.DestinationInfo;
29 import org.apache.activemq.command.Message;
30 import org.apache.activemq.command.MessageAck;
31 import org.apache.activemq.command.MessageDispatch;
32 import org.apache.activemq.command.MessageDispatchNotification;
33 import org.apache.activemq.command.MessagePull;
34 import org.apache.activemq.command.ProducerInfo;
35 import org.apache.activemq.command.RemoveSubscriptionInfo;
36 import org.apache.activemq.command.Response;
37 import org.apache.activemq.command.SessionInfo;
38 import org.apache.activemq.command.TransactionId;
39 import org.apache.activemq.kaha.Store;
40
41 import java.net.URI JavaDoc;
42 import java.util.Map JavaDoc;
43 import java.util.Set JavaDoc;
44
45 /**
46  * Like a BrokerFilter but it allows you to switch the getNext().broker. This has more
47  * overhead than a BrokerFilter since access to the getNext().broker has to synchronized
48  * since it is mutable
49  *
50  * @version $Revision: 1.10 $
51  */

52 public class MutableBrokerFilter implements Broker {
53     
54     private Broker next;
55     private final Object JavaDoc mutext = new Object JavaDoc();
56
57     public MutableBrokerFilter(Broker next) {
58         this.next = next;
59     }
60     
61     public Broker getAdaptor(Class JavaDoc type){
62         if (type.isInstance(this)){
63             return this;
64         }
65         return next.getAdaptor(type);
66     }
67     
68     public Broker getNext() {
69         synchronized(mutext) {
70             return next;
71         }
72     }
73     
74     public void setNext(Broker next) {
75         synchronized(mutext) {
76             this.next=next;
77         }
78     }
79         
80     public Map JavaDoc getDestinationMap() {
81         return getNext().getDestinationMap();
82     }
83
84     public Set JavaDoc getDestinations(ActiveMQDestination destination) {
85         return getNext().getDestinations(destination);
86     }
87
88     public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception JavaDoc {
89         getNext().acknowledge(consumerExchange, ack);
90     }
91
92     public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception JavaDoc {
93         getNext().addConnection(context, info);
94     }
95
96     public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception JavaDoc {
97         return getNext().addConsumer(context, info);
98     }
99
100     public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception JavaDoc {
101         getNext().addProducer(context, info);
102     }
103
104     public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception JavaDoc {
105         getNext().commitTransaction(context, xid, onePhase);
106     }
107
108     public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception JavaDoc {
109         getNext().removeSubscription(context, info);
110     }
111
112     public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception JavaDoc {
113         return getNext().getPreparedTransactions(context);
114     }
115
116     public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception JavaDoc {
117         return getNext().prepareTransaction(context, xid);
118     }
119
120     public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable JavaDoc error) throws Exception JavaDoc {
121         getNext().removeConnection(context, info, error);
122     }
123
124     public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception JavaDoc {
125         getNext().removeConsumer(context, info);
126     }
127
128     public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception JavaDoc {
129         getNext().removeProducer(context, info);
130     }
131
132     public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws Exception JavaDoc {
133         getNext().rollbackTransaction(context, xid);
134     }
135
136     public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception JavaDoc {
137         getNext().send(producerExchange, messageSend);
138     }
139
140     public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception JavaDoc {
141         getNext().beginTransaction(context, xid);
142     }
143
144     public void forgetTransaction(ConnectionContext context, TransactionId transactionId) throws Exception JavaDoc {
145         getNext().forgetTransaction(context, transactionId);
146     }
147
148     public Connection[] getClients() throws Exception JavaDoc {
149         return getNext().getClients();
150     }
151
152     public Destination addDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception JavaDoc {
153         return getNext().addDestination(context, destination);
154     }
155
156     public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception JavaDoc {
157         getNext().removeDestination(context, destination, timeout);
158     }
159
160     public ActiveMQDestination[] getDestinations() throws Exception JavaDoc {
161         return getNext().getDestinations();
162     }
163
164     public void start() throws Exception JavaDoc {
165         getNext().start();
166     }
167
168     public void stop() throws Exception JavaDoc {
169         getNext().stop();
170     }
171
172     public void addSession(ConnectionContext context, SessionInfo info) throws Exception JavaDoc {
173         getNext().addSession(context, info);
174     }
175
176     public void removeSession(ConnectionContext context, SessionInfo info) throws Exception JavaDoc {
177         getNext().removeSession(context, info);
178     }
179
180     public BrokerId getBrokerId() {
181         return getNext().getBrokerId();
182     }
183
184     public String JavaDoc getBrokerName() {
185         return getNext().getBrokerName();
186     }
187     
188     public void gc() {
189         getNext().gc();
190     }
191
192     public void addBroker(Connection connection,BrokerInfo info){
193         getNext().addBroker(connection, info);
194     }
195     
196     public void removeBroker(Connection connection,BrokerInfo info){
197         getNext().removeBroker(connection, info);
198     }
199
200     public BrokerInfo[] getPeerBrokerInfos(){
201        return getNext().getPeerBrokerInfos();
202     }
203     
204     public void processDispatch(MessageDispatch messageDispatch){
205         getNext().processDispatch(messageDispatch);
206     }
207     
208     public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception JavaDoc{
209         getNext().processDispatchNotification(messageDispatchNotification);
210     }
211     
212     public boolean isSlaveBroker(){
213         return getNext().isSlaveBroker();
214     }
215     
216     public boolean isStopped(){
217         return getNext().isStopped();
218     }
219     
220     public Set JavaDoc getDurableDestinations(){
221         return getNext().getDurableDestinations();
222     }
223
224     public void addDestinationInfo(ConnectionContext context,DestinationInfo info) throws Exception JavaDoc{
225         getNext().addDestinationInfo(context, info);
226         
227     }
228
229     public void removeDestinationInfo(ConnectionContext context,DestinationInfo info) throws Exception JavaDoc{
230         getNext().removeDestinationInfo(context, info);
231         
232     }
233
234     public boolean isFaultTolerantConfiguration(){
235        return getNext().isFaultTolerantConfiguration();
236     }
237
238     public ConnectionContext getAdminConnectionContext() {
239         return getNext().getAdminConnectionContext();
240     }
241
242     public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
243         getNext().setAdminConnectionContext(adminConnectionContext);
244     }
245
246     public Response messagePull(ConnectionContext context, MessagePull pull) throws Exception JavaDoc {
247         return getNext().messagePull(context, pull);
248     }
249     
250     public Store getTempDataStore() {
251         return getNext().getTempDataStore();
252     }
253     
254     public URI JavaDoc getVmConnectorURI(){
255         return getNext().getVmConnectorURI();
256     }
257
258 }
259
Popular Tags