001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.activemq.broker;
018
019import java.net.URI;
020import java.util.Map;
021import java.util.Set;
022import java.util.concurrent.ThreadPoolExecutor;
023
024import org.apache.activemq.broker.region.Destination;
025import org.apache.activemq.broker.region.MessageReference;
026import org.apache.activemq.broker.region.Subscription;
027import org.apache.activemq.broker.region.virtual.VirtualDestination;
028import org.apache.activemq.command.ActiveMQDestination;
029import org.apache.activemq.command.BrokerId;
030import org.apache.activemq.command.BrokerInfo;
031import org.apache.activemq.command.ConnectionInfo;
032import org.apache.activemq.command.ConsumerControl;
033import org.apache.activemq.command.ConsumerInfo;
034import org.apache.activemq.command.DestinationInfo;
035import org.apache.activemq.command.Message;
036import org.apache.activemq.command.MessageAck;
037import org.apache.activemq.command.MessageDispatch;
038import org.apache.activemq.command.MessageDispatchNotification;
039import org.apache.activemq.command.MessagePull;
040import org.apache.activemq.command.ProducerInfo;
041import org.apache.activemq.command.RemoveSubscriptionInfo;
042import org.apache.activemq.command.Response;
043import org.apache.activemq.command.SessionInfo;
044import org.apache.activemq.command.TransactionId;
045import org.apache.activemq.store.PListStore;
046import org.apache.activemq.thread.Scheduler;
047import org.apache.activemq.usage.Usage;
048
049/**
050 * Allows you to intercept broker operation so that features such as security
051 * can be implemented as a pluggable filter.
052 *
053 *
054 */
055public class BrokerFilter implements Broker {
056
057    protected final Broker next;
058
059    public BrokerFilter(Broker next) {
060        this.next = next;
061    }
062
063    public Broker getNext() {
064        return next;
065    }
066
067    @Override
068    public Broker getAdaptor(Class<?> type) {
069        return type.isInstance(this) ? this : getNext().getAdaptor(type);
070    }
071
072    @Override
073    public Map<ActiveMQDestination, Destination> getDestinationMap() {
074        return getNext().getDestinationMap();
075    }
076
077    @Override
078    public Map<ActiveMQDestination, Destination> getDestinationMap(ActiveMQDestination destination) {
079        return getNext().getDestinationMap(destination);
080    }
081
082    @Override
083    public Set<Destination> getDestinations(ActiveMQDestination destination) {
084        return getNext().getDestinations(destination);
085    }
086
087    @Override
088    public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception {
089        getNext().acknowledge(consumerExchange, ack);
090    }
091
092    @Override
093    public Response messagePull(ConnectionContext context, MessagePull pull) throws Exception {
094        return getNext().messagePull(context, pull);
095    }
096
097    @Override
098    public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception {
099        getNext().addConnection(context, info);
100    }
101
102    @Override
103    public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
104        return getNext().addConsumer(context, info);
105    }
106
107    @Override
108    public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception {
109        getNext().addProducer(context, info);
110    }
111
112    @Override
113    public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception {
114        getNext().commitTransaction(context, xid, onePhase);
115    }
116
117    @Override
118    public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception {
119        getNext().removeSubscription(context, info);
120    }
121
122    @Override
123    public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception {
124        return getNext().getPreparedTransactions(context);
125    }
126
127    @Override
128    public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception {
129        return getNext().prepareTransaction(context, xid);
130    }
131
132    @Override
133    public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception {
134        getNext().removeConnection(context, info, error);
135    }
136
137    @Override
138    public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception {
139        getNext().removeConsumer(context, info);
140    }
141
142    @Override
143    public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception {
144        getNext().removeProducer(context, info);
145    }
146
147    @Override
148    public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws Exception {
149        getNext().rollbackTransaction(context, xid);
150    }
151
152    @Override
153    public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception {
154        getNext().send(producerExchange, messageSend);
155    }
156
157    @Override
158    public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception {
159        getNext().beginTransaction(context, xid);
160    }
161
162    @Override
163    public void forgetTransaction(ConnectionContext context, TransactionId transactionId) throws Exception {
164        getNext().forgetTransaction(context, transactionId);
165    }
166
167    @Override
168    public Connection[] getClients() throws Exception {
169        return getNext().getClients();
170    }
171
172    @Override
173    public Destination addDestination(ConnectionContext context, ActiveMQDestination destination,boolean createIfTemporary) throws Exception {
174        return getNext().addDestination(context, destination,createIfTemporary);
175    }
176
177    @Override
178    public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception {
179        getNext().removeDestination(context, destination, timeout);
180    }
181
182    @Override
183    public ActiveMQDestination[] getDestinations() throws Exception {
184        return getNext().getDestinations();
185    }
186
187    @Override
188    public void start() throws Exception {
189        getNext().start();
190    }
191
192    @Override
193    public void stop() throws Exception {
194        getNext().stop();
195    }
196
197    @Override
198    public void addSession(ConnectionContext context, SessionInfo info) throws Exception {
199        getNext().addSession(context, info);
200    }
201
202    @Override
203    public void removeSession(ConnectionContext context, SessionInfo info) throws Exception {
204        getNext().removeSession(context, info);
205    }
206
207    @Override
208    public BrokerId getBrokerId() {
209        return getNext().getBrokerId();
210    }
211
212    @Override
213    public String getBrokerName() {
214        return getNext().getBrokerName();
215    }
216
217    @Override
218    public void gc() {
219        getNext().gc();
220    }
221
222    @Override
223    public void addBroker(Connection connection, BrokerInfo info) {
224        getNext().addBroker(connection, info);
225    }
226
227    @Override
228    public void removeBroker(Connection connection, BrokerInfo info) {
229        getNext().removeBroker(connection, info);
230    }
231
232    @Override
233    public BrokerInfo[] getPeerBrokerInfos() {
234        return getNext().getPeerBrokerInfos();
235    }
236
237    @Override
238    public void preProcessDispatch(MessageDispatch messageDispatch) {
239        getNext().preProcessDispatch(messageDispatch);
240    }
241
242    @Override
243    public void postProcessDispatch(MessageDispatch messageDispatch) {
244        getNext().postProcessDispatch(messageDispatch);
245    }
246
247    @Override
248    public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception {
249        getNext().processDispatchNotification(messageDispatchNotification);
250    }
251
252    @Override
253    public boolean isStopped() {
254        return getNext().isStopped();
255    }
256
257    @Override
258    public Set<ActiveMQDestination> getDurableDestinations() {
259        return getNext().getDurableDestinations();
260    }
261
262    @Override
263    public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
264        getNext().addDestinationInfo(context, info);
265    }
266
267    @Override
268    public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception {
269        getNext().removeDestinationInfo(context, info);
270    }
271
272    @Override
273    public boolean isFaultTolerantConfiguration() {
274        return getNext().isFaultTolerantConfiguration();
275    }
276
277    @Override
278    public ConnectionContext getAdminConnectionContext() {
279        return getNext().getAdminConnectionContext();
280    }
281
282    @Override
283    public void setAdminConnectionContext(ConnectionContext adminConnectionContext) {
284        getNext().setAdminConnectionContext(adminConnectionContext);
285    }
286
287    @Override
288    public PListStore getTempDataStore() {
289        return getNext().getTempDataStore();
290    }
291
292    @Override
293    public URI getVmConnectorURI() {
294        return getNext().getVmConnectorURI();
295    }
296
297    @Override
298    public void brokerServiceStarted() {
299        getNext().brokerServiceStarted();
300    }
301
302    @Override
303    public BrokerService getBrokerService() {
304        return getNext().getBrokerService();
305    }
306
307    @Override
308    public boolean isExpired(MessageReference messageReference) {
309        return getNext().isExpired(messageReference);
310    }
311
312    @Override
313    public void messageExpired(ConnectionContext context, MessageReference message, Subscription subscription) {
314        getNext().messageExpired(context, message, subscription);
315    }
316
317    @Override
318    public boolean sendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference,
319                                         Subscription subscription, Throwable poisonCause) {
320        return getNext().sendToDeadLetterQueue(context, messageReference, subscription, poisonCause);
321    }
322
323    @Override
324    public Broker getRoot() {
325        return getNext().getRoot();
326    }
327
328    @Override
329    public long getBrokerSequenceId() {
330        return getNext().getBrokerSequenceId();
331    }
332
333
334    @Override
335    public void fastProducer(ConnectionContext context,ProducerInfo producerInfo,ActiveMQDestination destination) {
336        getNext().fastProducer(context, producerInfo, destination);
337    }
338
339    @Override
340    public void isFull(ConnectionContext context,Destination destination, Usage<?> usage) {
341        getNext().isFull(context,destination, usage);
342    }
343
344    @Override
345    public void messageConsumed(ConnectionContext context,MessageReference messageReference) {
346        getNext().messageConsumed(context, messageReference);
347    }
348
349    @Override
350    public void messageDelivered(ConnectionContext context,MessageReference messageReference) {
351        getNext().messageDelivered(context, messageReference);
352    }
353
354    @Override
355    public void messageDiscarded(ConnectionContext context,Subscription sub, MessageReference messageReference) {
356        getNext().messageDiscarded(context, sub, messageReference);
357    }
358
359    @Override
360    public void slowConsumer(ConnectionContext context, Destination destination,Subscription subs) {
361        getNext().slowConsumer(context, destination,subs);
362    }
363
364    @Override
365    public void virtualDestinationAdded(ConnectionContext context,
366            VirtualDestination virtualDestination) {
367        getNext().virtualDestinationAdded(context, virtualDestination);
368    }
369
370    @Override
371    public void virtualDestinationRemoved(ConnectionContext context,
372            VirtualDestination virtualDestination) {
373        getNext().virtualDestinationRemoved(context, virtualDestination);
374    }
375
376    @Override
377    public void nowMasterBroker() {
378        getNext().nowMasterBroker();
379    }
380
381    @Override
382    public void processConsumerControl(ConsumerBrokerExchange consumerExchange,
383            ConsumerControl control) {
384        getNext().processConsumerControl(consumerExchange, control);
385    }
386
387    @Override
388    public void reapplyInterceptor() {
389        getNext().reapplyInterceptor();
390    }
391
392    @Override
393    public Scheduler getScheduler() {
394       return getNext().getScheduler();
395    }
396
397    @Override
398    public ThreadPoolExecutor getExecutor() {
399       return getNext().getExecutor();
400    }
401
402    @Override
403    public void networkBridgeStarted(BrokerInfo brokerInfo, boolean createdByDuplex, String remoteIp) {
404        getNext().networkBridgeStarted(brokerInfo, createdByDuplex, remoteIp);
405    }
406
407    @Override
408    public void networkBridgeStopped(BrokerInfo brokerInfo) {
409        getNext().networkBridgeStopped(brokerInfo);
410    }
411}