protected UMOMessageReceiver getReceiverByEndpoint(UMOEndpointURI endpointUri) throws EndpointException { if (logger.isDebugEnabled()) logger.debug("Looking up vm receiver for address: " + endpointUri.toString()); UMOMessageReceiver receiver; // If we have an exact match, use it receiver = (UMOMessageReceiver) receivers.get(endpointUri.getAddress()); if (receiver != null) { logger.debug("Found exact receiver match on endpointUri: " + endpointUri); return receiver; } // otherwise check each one against a wildcard match for (Iterator iterator = receivers.values().iterator(); iterator.hasNext(); ) { receiver = (UMOMessageReceiver) iterator.next(); String filterAddress = receiver.getEndpointURI().getAddress(); WildcardFilter filter = new WildcardFilter(filterAddress); if (filter.accept(endpointUri.getAddress())) { receiver.getEndpoint().setEndpointURI(new MuleEndpointURI(endpointUri, filterAddress)); logger.debug( "Found receiver match on endpointUri: " + receiver.getEndpointURI() + " against " + endpointUri); return receiver; } } logger.debug("No receiver found for endpointUri: " + endpointUri); return null; }
public void testNotFilter() { WildcardFilter filter = new WildcardFilter("blah.blah.*"); NotFilter notFilter = new NotFilter(filter); assertNotNull(notFilter.getFilter()); assertTrue(filter.accept(new MuleMessage("blah.blah.blah", null))); assertTrue(!notFilter.accept(new MuleMessage("blah.blah.blah", null))); notFilter = new NotFilter(); notFilter.setFilter(filter); assertTrue(filter.accept(new MuleMessage("blah.blah.blah", null))); assertTrue(!notFilter.accept(new MuleMessage("blah.blah.blah", null))); }
public void testAndFilter() { WildcardFilter left = new WildcardFilter("blah.blah.*"); WildcardFilter right = new WildcardFilter("blah.*"); AndFilter filter = new AndFilter(left, right); assertNotNull(filter.getLeftFilter()); assertNotNull(filter.getRightFilter()); assertTrue(filter.accept(new MuleMessage("blah.blah.blah", null))); assertTrue(right.accept(new MuleMessage("blah.blah", null))); assertTrue(!left.accept(new MuleMessage("blah.blah", null))); assertTrue(!filter.accept(new MuleMessage("blah.blah", null))); filter = new AndFilter(); filter.setLeftFilter(left); filter.setRightFilter(right); assertTrue(filter.accept(new MuleMessage("blah.blah.blah", null))); assertTrue(!filter.accept(new MuleMessage("blah.blah", null))); }