View Javadoc

1   /*
2    * $Id: Sender.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.context.notification;
12  
13  import org.mule.api.context.notification.ServerNotification;
14  import org.mule.routing.filters.WildcardFilter;
15  
16  /**
17   * This does the work necessary to deliver events to a particular listener.  It is generated for a
18   * particular {@link Configuration} and stored in a
19   * {@link org.mule.context.notification.Policy}.
20   */
21  class Sender
22  {
23  
24      private ListenerSubscriptionPair pair;
25      private WildcardFilter subscriptionFilter;
26  
27      Sender(ListenerSubscriptionPair pair)
28      {
29          this.pair = pair;
30          subscriptionFilter = new WildcardFilter(pair.getSubscription());
31          subscriptionFilter.setCaseSensitive(false);
32      }
33  
34      public void dispatch(ServerNotification notification)
35      {
36          if (pair.isNullSubscription() ||
37                  (null != notification.getResourceIdentifier() &&
38                          subscriptionFilter.accept(notification.getResourceIdentifier())))
39          {
40              pair.getListener().onNotification(notification);
41          }
42      }
43  
44  }
45