View Javadoc

1   /*
2    * $Id: ApplicationService.java 22409 2011-07-14 05:14:27Z dirk.olmes $
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.module.management.mbean;
11  
12  import org.mule.api.MuleContext;
13  import org.mule.management.stats.FlowConstructStatistics;
14  
15  import javax.management.ObjectName;
16  
17  import org.apache.commons.logging.Log;
18  import org.apache.commons.logging.LogFactory;
19  
20  /**
21   * The MBean for application-wide statistics
22   */
23  public class ApplicationService extends FlowConstructService implements FlowConstructServiceMBean
24  {
25      private static Log LOGGER = LogFactory.getLog(ApplicationService.class);
26  
27      public ApplicationService(String type, String name, MuleContext muleContext, FlowConstructStatistics statistics)
28      {
29          super(type, name, muleContext, statistics);
30      }
31  
32      @Override
33      public void postRegister(Boolean registrationDone)
34      {
35          try
36          {
37              statsName = new ObjectName(objectName.getDomain() + ":type=org.mule.Statistics," +
38                  statistics.getFlowConstructType() + "=" + getName());
39              // unregister old version if exists
40              if (this.server.isRegistered(statsName))
41              {
42                  this.server.unregisterMBean(statsName);
43              }
44  
45              this.server.registerMBean(new FlowConstructStats(statistics), this.statsName);
46          }
47          catch (Exception e)
48          {
49              LOGGER.error("Error post-registering the MBean", e);
50          }
51      }
52  }