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 */ 017 package org.apache.activemq.broker; 018 019 import java.net.URI; 020 import java.util.Map; 021 import java.util.Set; 022 import org.apache.activemq.broker.region.Destination; 023 import org.apache.activemq.broker.region.MessageReference; 024 import org.apache.activemq.broker.region.Subscription; 025 import org.apache.activemq.command.ActiveMQDestination; 026 import org.apache.activemq.command.BrokerId; 027 import org.apache.activemq.command.BrokerInfo; 028 import org.apache.activemq.command.ConnectionInfo; 029 import org.apache.activemq.command.ConsumerInfo; 030 import org.apache.activemq.command.DestinationInfo; 031 import org.apache.activemq.command.Message; 032 import org.apache.activemq.command.MessageAck; 033 import org.apache.activemq.command.MessageDispatch; 034 import org.apache.activemq.command.MessageDispatchNotification; 035 import org.apache.activemq.command.MessagePull; 036 import org.apache.activemq.command.ProducerInfo; 037 import org.apache.activemq.command.RemoveSubscriptionInfo; 038 import org.apache.activemq.command.Response; 039 import org.apache.activemq.command.SessionInfo; 040 import org.apache.activemq.command.TransactionId; 041 import org.apache.activemq.kaha.Store; 042 import org.apache.activemq.usage.Usage; 043 044 /** 045 * Allows you to intercept broker operation so that features such as security 046 * can be implemented as a pluggable filter. 047 * 048 * @version $Revision: 1.10 $ 049 */ 050 public class BrokerFilter implements Broker { 051 052 protected final Broker next; 053 054 public BrokerFilter(Broker next) { 055 this.next = next; 056 } 057 058 public Broker getAdaptor(Class type) { 059 if (type.isInstance(this)) { 060 return this; 061 } 062 return next.getAdaptor(type); 063 } 064 065 public Map<ActiveMQDestination, Destination> getDestinationMap() { 066 return next.getDestinationMap(); 067 } 068 069 public Set <Destination>getDestinations(ActiveMQDestination destination) { 070 return next.getDestinations(destination); 071 } 072 073 public void acknowledge(ConsumerBrokerExchange consumerExchange, MessageAck ack) throws Exception { 074 next.acknowledge(consumerExchange, ack); 075 } 076 077 public Response messagePull(ConnectionContext context, MessagePull pull) throws Exception { 078 return next.messagePull(context, pull); 079 } 080 081 public void addConnection(ConnectionContext context, ConnectionInfo info) throws Exception { 082 next.addConnection(context, info); 083 } 084 085 public Subscription addConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { 086 return next.addConsumer(context, info); 087 } 088 089 public void addProducer(ConnectionContext context, ProducerInfo info) throws Exception { 090 next.addProducer(context, info); 091 } 092 093 public void commitTransaction(ConnectionContext context, TransactionId xid, boolean onePhase) throws Exception { 094 next.commitTransaction(context, xid, onePhase); 095 } 096 097 public void removeSubscription(ConnectionContext context, RemoveSubscriptionInfo info) throws Exception { 098 next.removeSubscription(context, info); 099 } 100 101 public TransactionId[] getPreparedTransactions(ConnectionContext context) throws Exception { 102 return next.getPreparedTransactions(context); 103 } 104 105 public int prepareTransaction(ConnectionContext context, TransactionId xid) throws Exception { 106 return next.prepareTransaction(context, xid); 107 } 108 109 public void removeConnection(ConnectionContext context, ConnectionInfo info, Throwable error) throws Exception { 110 next.removeConnection(context, info, error); 111 } 112 113 public void removeConsumer(ConnectionContext context, ConsumerInfo info) throws Exception { 114 next.removeConsumer(context, info); 115 } 116 117 public void removeProducer(ConnectionContext context, ProducerInfo info) throws Exception { 118 next.removeProducer(context, info); 119 } 120 121 public void rollbackTransaction(ConnectionContext context, TransactionId xid) throws Exception { 122 next.rollbackTransaction(context, xid); 123 } 124 125 public void send(ProducerBrokerExchange producerExchange, Message messageSend) throws Exception { 126 next.send(producerExchange, messageSend); 127 } 128 129 public void beginTransaction(ConnectionContext context, TransactionId xid) throws Exception { 130 next.beginTransaction(context, xid); 131 } 132 133 public void forgetTransaction(ConnectionContext context, TransactionId transactionId) throws Exception { 134 next.forgetTransaction(context, transactionId); 135 } 136 137 public Connection[] getClients() throws Exception { 138 return next.getClients(); 139 } 140 141 public Destination addDestination(ConnectionContext context, ActiveMQDestination destination) throws Exception { 142 return next.addDestination(context, destination); 143 } 144 145 public void removeDestination(ConnectionContext context, ActiveMQDestination destination, long timeout) throws Exception { 146 next.removeDestination(context, destination, timeout); 147 } 148 149 public ActiveMQDestination[] getDestinations() throws Exception { 150 return next.getDestinations(); 151 } 152 153 public void start() throws Exception { 154 next.start(); 155 } 156 157 public void stop() throws Exception { 158 next.stop(); 159 } 160 161 public void addSession(ConnectionContext context, SessionInfo info) throws Exception { 162 next.addSession(context, info); 163 } 164 165 public void removeSession(ConnectionContext context, SessionInfo info) throws Exception { 166 next.removeSession(context, info); 167 } 168 169 public BrokerId getBrokerId() { 170 return next.getBrokerId(); 171 } 172 173 public String getBrokerName() { 174 return next.getBrokerName(); 175 } 176 177 public void gc() { 178 next.gc(); 179 } 180 181 public void addBroker(Connection connection, BrokerInfo info) { 182 next.addBroker(connection, info); 183 } 184 185 public void removeBroker(Connection connection, BrokerInfo info) { 186 next.removeBroker(connection, info); 187 } 188 189 public BrokerInfo[] getPeerBrokerInfos() { 190 return next.getPeerBrokerInfos(); 191 } 192 193 public void preProcessDispatch(MessageDispatch messageDispatch) { 194 next.preProcessDispatch(messageDispatch); 195 } 196 197 public void postProcessDispatch(MessageDispatch messageDispatch) { 198 next.postProcessDispatch(messageDispatch); 199 } 200 201 public void processDispatchNotification(MessageDispatchNotification messageDispatchNotification) throws Exception { 202 next.processDispatchNotification(messageDispatchNotification); 203 } 204 205 public boolean isStopped() { 206 return next.isStopped(); 207 } 208 209 public Set<ActiveMQDestination> getDurableDestinations() { 210 return next.getDurableDestinations(); 211 } 212 213 public void addDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception { 214 next.addDestinationInfo(context, info); 215 } 216 217 public void removeDestinationInfo(ConnectionContext context, DestinationInfo info) throws Exception { 218 next.removeDestinationInfo(context, info); 219 } 220 221 public boolean isFaultTolerantConfiguration() { 222 return next.isFaultTolerantConfiguration(); 223 } 224 225 public ConnectionContext getAdminConnectionContext() { 226 return next.getAdminConnectionContext(); 227 } 228 229 public void setAdminConnectionContext(ConnectionContext adminConnectionContext) { 230 next.setAdminConnectionContext(adminConnectionContext); 231 } 232 233 public Store getTempDataStore() { 234 return next.getTempDataStore(); 235 } 236 237 public URI getVmConnectorURI() { 238 return next.getVmConnectorURI(); 239 } 240 241 public void brokerServiceStarted() { 242 next.brokerServiceStarted(); 243 } 244 245 public BrokerService getBrokerService() { 246 return next.getBrokerService(); 247 } 248 249 public boolean isExpired(MessageReference messageReference) { 250 return next.isExpired(messageReference); 251 } 252 253 public void messageExpired(ConnectionContext context, MessageReference message) { 254 next.messageExpired(context, message); 255 } 256 257 public void sendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference) { 258 next.sendToDeadLetterQueue(context, messageReference); 259 } 260 261 public Broker getRoot() { 262 return next.getRoot(); 263 } 264 265 public long getBrokerSequenceId() { 266 return next.getBrokerSequenceId(); 267 } 268 269 270 public void fastProducer(ConnectionContext context,ProducerInfo producerInfo) { 271 next.fastProducer(context, producerInfo); 272 } 273 274 public void isFull(ConnectionContext context,Destination destination, Usage usage) { 275 next.isFull(context,destination, usage); 276 } 277 278 public void messageConsumed(ConnectionContext context,MessageReference messageReference) { 279 next.messageConsumed(context, messageReference); 280 } 281 282 public void messageDelivered(ConnectionContext context,MessageReference messageReference) { 283 next.messageDelivered(context, messageReference); 284 } 285 286 public void messageDiscarded(ConnectionContext context,MessageReference messageReference) { 287 next.messageDiscarded(context, messageReference); 288 } 289 290 public void slowConsumer(ConnectionContext context, Destination destination,Subscription subs) { 291 next.slowConsumer(context, destination,subs); 292 } 293 294 public void nowMasterBroker() { 295 next.nowMasterBroker(); 296 } 297 }