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