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 java.util.List;
10  
11  import javax.management.MBeanServer;
12  
13  public class MBeanServerFactory 
14  {
15      public static MBeanServer getOrCreateMBeanServer()
16      {
17          MBeanServer server;
18          
19          List servers = javax.management.MBeanServerFactory.findMBeanServer(null);
20          if (servers != null && servers.size() > 0)
21          {
22              server = (MBeanServer) servers.get(0);
23          }
24          else
25          {
26              server = javax.management.MBeanServerFactory.createMBeanServer();
27          }
28          return server;
29      }
30  }
31  
32