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.region.virtual;
018
019import java.util.Collection;
020
021import org.apache.activemq.broker.Broker;
022import org.apache.activemq.broker.ConnectionContext;
023import org.apache.activemq.broker.region.Destination;
024import org.apache.activemq.command.ActiveMQDestination;
025
026/**
027 * 
028 * 
029 */
030public abstract class CompositeDestination implements VirtualDestination {
031
032    private String name;
033    private Collection forwardTo;
034    private boolean forwardOnly = true;
035    private boolean copyMessage = true;
036
037    public Destination intercept(Destination destination) {
038        return new CompositeDestinationFilter(destination, getForwardTo(), isForwardOnly(), isCopyMessage());
039    }
040    
041    public void create(Broker broker, ConnectionContext context, ActiveMQDestination destination) {
042    }
043
044    public void remove(Destination destination) {        
045    }
046
047    public String getName() {
048        return name;
049    }
050
051    /**
052     * Sets the name of this composite destination
053     */
054    public void setName(String name) {
055        this.name = name;
056    }
057
058    public Collection getForwardTo() {
059        return forwardTo;
060    }
061
062    /**
063     * Sets the list of destinations to forward to
064     */
065    public void setForwardTo(Collection forwardDestinations) {
066        this.forwardTo = forwardDestinations;
067    }
068
069    public boolean isForwardOnly() {
070        return forwardOnly;
071    }
072
073    /**
074     * Sets if the virtual destination is forward only (and so there is no
075     * physical queue to match the virtual queue) or if there is also a physical
076     * queue with the same name).
077     */
078    public void setForwardOnly(boolean forwardOnly) {
079        this.forwardOnly = forwardOnly;
080    }
081
082    public boolean isCopyMessage() {
083        return copyMessage;
084    }
085
086    /**
087     * Sets whether a copy of the message will be sent to each destination.
088     * Defaults to true so that the forward destination is set as the
089     * destination of the message
090     */
091    public void setCopyMessage(boolean copyMessage) {
092        this.copyMessage = copyMessage;
093    }
094
095}