1 /*** 2 * 3 * Copyright 2004 Protique Ltd 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 **/ 18 package org.codehaus.activemq.filter; 19 20 import org.codehaus.activemq.message.ActiveMQDestination; 21 22 import javax.jms.Destination; 23 import java.util.ArrayList; 24 import java.util.Iterator; 25 import java.util.List; 26 27 /*** 28 * A {@link DestinationFilter} used for composite destinations 29 * 30 * @version $Revision: 1.1 $ 31 */ 32 public class CompositeDestinationFilter extends DestinationFilter { 33 private List filters; 34 35 public CompositeDestinationFilter(ActiveMQDestination destination) { 36 List childDestinations = destination.getChildDestinations(); 37 filters = new ArrayList(childDestinations.size()); 38 for (Iterator iter = childDestinations.iterator(); iter.hasNext();) { 39 Destination childDestination = (Destination) iter.next(); 40 filters.add(DestinationFilter.parseFilter(childDestination)); 41 } 42 } 43 44 public boolean matches(Destination destination) { 45 for (Iterator iter = filters.iterator(); iter.hasNext();) { 46 DestinationFilter filter = (DestinationFilter) iter.next(); 47 if (filter.matches(destination)) { 48 return true; 49 } 50 } 51 return false; 52 } 53 54 public boolean isWildcard() { 55 return true; 56 } 57 }