View Javadoc

1   /*
2    * $Id: NotificationListenerProcessor.java 20321 2010-11-24 15:21:24Z dfeist $
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  package org.mule.registry;
11  
12  import org.mule.api.MuleContext;
13  import org.mule.api.context.notification.ServerNotificationListener;
14  import org.mule.api.registry.PreInitProcessor;
15  
16  /**
17   * Will register any {@link org.mule.api.context.notification.ServerNotificationListener} instances with the MuleContext
18   * to receive notifications
19   */
20  public class NotificationListenerProcessor implements PreInitProcessor
21  {
22      private MuleContext context;
23  
24      public NotificationListenerProcessor(MuleContext context)
25      {
26          this.context = context;
27      }
28  
29      public Object process(Object object)
30      {
31          if (object instanceof ServerNotificationListener)
32          {
33              context.getNotificationManager().addListener((ServerNotificationListener) object);
34          }
35          return object;
36      }
37  }