View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.management.mbean;
8   
9   import org.mule.api.MuleContext;
10  import org.mule.management.stats.FlowConstructStatistics;
11  
12  import org.apache.commons.logging.Log;
13  import org.apache.commons.logging.LogFactory;
14  
15  /**
16   * The MBean for application-wide statistics
17   */
18  public class ApplicationService extends FlowConstructService implements FlowConstructServiceMBean
19  {
20      private static Log LOGGER = LogFactory.getLog(ApplicationService.class);
21  
22      public ApplicationService(String type, String name, MuleContext muleContext, FlowConstructStatistics statistics)
23      {
24          super(type, name, muleContext, statistics);
25      }
26  
27      @Override
28      public void postRegister(Boolean registrationDone)
29      {
30          try
31          {
32              statsName = jmxSupport.getObjectName(String.format("%s:type=org.mule.Statistics,%s=%s", objectName.getDomain(), 
33                  statistics.getFlowConstructType(), jmxSupport.escape(getName())));
34              
35              // unregister old version if exists
36              if (this.server.isRegistered(statsName))
37              {
38                  this.server.unregisterMBean(statsName);
39              }
40  
41              this.server.registerMBean(new FlowConstructStats(statistics), this.statsName);
42          }
43          catch (Exception e)
44          {
45              LOGGER.error("Error post-registering the MBean", e);
46          }
47      }
48  }