diff options
Diffstat (limited to 'java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChainedClusterMethodHandler.java')
-rw-r--r-- | java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChainedClusterMethodHandler.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChainedClusterMethodHandler.java b/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChainedClusterMethodHandler.java new file mode 100644 index 0000000000..5ee07af596 --- /dev/null +++ b/java/cluster/src/main/java/org/apache/qpid/server/cluster/handler/ChainedClusterMethodHandler.java @@ -0,0 +1,69 @@ +/* + * + * Copyright (c) 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.qpid.server.cluster.handler; + +import org.apache.qpid.server.state.AMQStateManager; +import org.apache.qpid.server.queue.QueueRegistry; +import org.apache.qpid.server.exchange.ExchangeRegistry; +import org.apache.qpid.server.protocol.AMQProtocolSession; +import org.apache.qpid.server.protocol.AMQMethodEvent; +import org.apache.qpid.AMQException; +import org.apache.qpid.framing.AMQMethodBody; + +import java.util.List; +import java.util.ArrayList; + +public class ChainedClusterMethodHandler <A extends AMQMethodBody> extends ClusterMethodHandler<A> +{ + private final List<ClusterMethodHandler<A>> _handlers; + + private ChainedClusterMethodHandler() + { + this(new ArrayList<ClusterMethodHandler<A>>()); + } + + public ChainedClusterMethodHandler(List<ClusterMethodHandler<A>> handlers) + { + _handlers = handlers; + } + + public ChainedClusterMethodHandler(ClusterMethodHandler<A>... handlers) + { + this(); + for(ClusterMethodHandler<A>handler: handlers) + { + _handlers.add(handler); + } + } + + protected final void peer(AMQStateManager stateMgr, QueueRegistry queues, ExchangeRegistry exchanges, AMQProtocolSession session, AMQMethodEvent<A> evt) throws AMQException + { + for(ClusterMethodHandler<A> handler : _handlers) + { + handler.peer(stateMgr, queues, exchanges, session, evt); + } + } + + protected final void client(AMQStateManager stateMgr, QueueRegistry queues, ExchangeRegistry exchanges, AMQProtocolSession session, AMQMethodEvent<A> evt) throws AMQException + { + for(ClusterMethodHandler<A> handler : _handlers) + { + handler.client(stateMgr, queues, exchanges, session, evt); + } + } +} |