View Javadoc

1   /*
2    * $Id: ListenerSubscriptionPair.java 10884 2008-02-19 16:02:29Z acooke $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.ServerNotificationListener;
14  
15  /**
16   * A simple tuple that stores a listener with an optional subscription (used to match a resource ID).
17   */
18  public class ListenerSubscriptionPair
19  {
20  
21      private ServerNotificationListener listener;
22      private String subscription = ServerNotificationManager.NULL_SUBSCRIPTION;
23      private boolean nullSubscription = true;
24  
25      /**
26       * For config - must be constructed using the setters
27       */
28      public ListenerSubscriptionPair()
29      {
30          // empty
31      }
32  
33      public ListenerSubscriptionPair(ServerNotificationListener listener)
34      {
35          setListener(listener);
36      }
37  
38      public ListenerSubscriptionPair(ServerNotificationListener listener, String subscription)
39      {
40          setListener(listener);
41          setSubscription(subscription);
42      }
43  
44      public void setListener(ServerNotificationListener listener)
45      {
46          this.listener = listener;
47      }
48  
49      public void setSubscription(String subscription)
50      {
51          if (null != subscription)
52          {
53              this.subscription = subscription;
54              nullSubscription = false;
55          }
56      }
57  
58      public ServerNotificationListener getListener()
59      {
60          return listener;
61      }
62  
63      public String getSubscription()
64      {
65          return subscription;
66      }
67  
68      public boolean isNullSubscription()
69      {
70          return nullSubscription;
71      }
72  
73  }