List of usage examples for java.lang.management ManagementFactory getPlatformMBeanServer
public static synchronized MBeanServer getPlatformMBeanServer()
From source file:Main.java
/** * //from w ww. j a v a 2 s. com * @param mBean * @param type * @param name * @param otherParams * comma-separated string containing additional parameters for * the MBean server */ public static ObjectName registerMBean(Object mBean, String type, String name, String otherParams) { try { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName objName = new ObjectName( "enkive:type=" + type + ",name=" + name + (otherParams == null ? "" : "," + otherParams)); server.registerMBean(mBean, objName); return objName; } catch (InstanceAlreadyExistsException e) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("tried to re-register mbean", e); } } catch (MBeanRegistrationException e) { LOGGER.error("could not register mbean", e); } catch (NotCompliantMBeanException e) { LOGGER.error("noncompliant mbean", e); } catch (MalformedObjectNameException e) { LOGGER.error("noncompliant mbean name", e); } return null; }
From source file:com.netflix.config.jmx.ConfigJMXManager.java
public static void unRegisterConfigMBean(AbstractConfiguration config, ConfigMBean mbean) { if (mbean == null) { throw new RuntimeException("Cannot unregister JMX Mbean. The object is null"); }/* w w w .j av a 2s . c om*/ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); try { mbs.unregisterMBean(getJMXObjectName(config, mbean)); } catch (InstanceNotFoundException e) { throw new RuntimeException("InstanceNotFoundException", e); } catch (MBeanRegistrationException e) { throw new RuntimeException("MBeanRegistrationException", e); } catch (Exception e) { throw new RuntimeException("unRegisterConfigMBeanException", e); } }
From source file:com.sm.utils.JmxService.java
public JmxService(List serviceList, List<String> names) { if (serviceList == null || serviceList.size() == 0) throw new RuntimeException("serviceList is null or empty"); this.serviceList = serviceList; this.mbeanServer = ManagementFactory.getPlatformMBeanServer(); this.registeredBeans = new HashSet<ObjectName>(); if (names == null) start();/*from w w w .j a v a 2 s. co m*/ else start(names); }
From source file:org.jolokia.jmx.JsonDymamicMBeanImplTest.java
@BeforeClass public void setup() { server = new JolokiaMBeanServer(); platformServer = ManagementFactory.getPlatformMBeanServer(); }
From source file:org.opendaylight.netvirt.statemanager.ConfigStateManager.java
private void getServices() { ConfigRegistry configRegistryClient = new ConfigRegistryJMXClient( ManagementFactory.getPlatformMBeanServer()); for (Map.Entry<String, Pair<String, Boolean>> ready : readyMap.entrySet()) { if (ready.getValue().getRight()) { continue; }/*ww w . jav a 2s . co m*/ String moduleName = ready.getKey(); String instanceName = ready.getValue().getLeft(); LOG.trace("ConfigStateManager attempting to configure: {}, {}", moduleName, instanceName); ObjectName objectName = null; try { objectName = configRegistryClient.lookupConfigBean(moduleName, instanceName); readyMap.put(moduleName, Pair.of(instanceName, true)); LOG.info("ConfigStateManager found: {}, {}, {}", moduleName, instanceName, objectName); } catch (InstanceNotFoundException e) { continue; } } }
From source file:org.cloudfoundry.identity.statsd.Application.java
@Bean public UaaMetricsEmitter statsDClientWrapper() { return new UaaMetricsEmitter(statsDClient(), ManagementFactory.getPlatformMBeanServer()); }
From source file:my.school.spring.beans.ProfilingBeanPostProcessor.java
public ProfilingBeanPostProcessor() { try {//from ww w. j a va 2s . c om ManagementFactory.getPlatformMBeanServer().registerMBean(profilingController, ObjectName.getInstance("my.school", "profiling", "profiling")); } catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException ex) { LOG.error(ex.getMessage()); } }
From source file:org.apache.synapse.securevault.commons.MBeanRegistrar.java
public void registerMBean(Object mbeanInstance, String category, String id) { assertNull(mbeanInstance, "Mbean instance is null"); assertNull(category, "Mbean instance category is null"); assertNull(id, "Mbean instance name is null"); try {/*from w w w . j a v a 2 s.c o m*/ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName(getObjectName(category, id)); Set set = mbs.queryNames(name, null); if (set != null && set.isEmpty()) { mbs.registerMBean(mbeanInstance, name); } else { mbs.unregisterMBean(name); mbs.registerMBean(mbeanInstance, name); } } catch (Exception e) { log.warn("Error registering a MBean with name ' " + id + " ' and category name ' " + category + "' for JMX management", e); } }
From source file:org.wso2.carbon.as.monitoring.collector.jmx.clients.MBeanClient.java
/** * Constructs MBean Client */ public MBeanClient() { server = ManagementFactory.getPlatformMBeanServer(); }
From source file:io.mapzone.arena.jmx.ArenaConfig.java
/** * The ArenaPlugin must be started automatically at level 5 in order to make this * available right after startup./* w w w. j a v a 2 s .c o m*/ */ public ArenaConfig() { assert instance == null; instance = this; try { MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); mbeanServer.registerMBean(this, ArenaConfigMBean.NAME.get()); log.info("MBean registered."); } catch (Exception e) { throw new RuntimeException(e); } }