List of usage examples for java.lang.management ManagementFactory getPlatformMBeanServer
public static synchronized MBeanServer getPlatformMBeanServer()
From source file:com.taobao.diamond.server.service.jmx.DataIdCountService.java
public void init() { try {// ww w .j a va 2s. c o m ObjectName oName = new ObjectName(DataIdCountService.class.getPackage().getName() + ":type=" + DataIdCountService.class.getSimpleName()); ManagementFactory.getPlatformMBeanServer().registerMBean(this, oName); } catch (Exception e) { log.error("DataIdCountServicembean", e); } }
From source file:ome.services.util.JvmSettingsCheck.java
public static long getPhysicalMemory() { try {/*from www . j a va 2s . c o m*/ MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); Object attribute = mBeanServer.getAttribute(new ObjectName("java.lang", "type", "OperatingSystem"), "TotalPhysicalMemorySize"); return Long.valueOf(attribute.toString()); } catch (Exception e) { log.debug("Failed to get physical memory", e); return -1; } }
From source file:hivemall.mix.metrics.MetricsRegistry.java
public static void unregisterMBeans(int port) { final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); final ObjectName name = makeMBeanName("hivemall", MixServerMetricsMBean.class.getSimpleName(), "port=" + port); try {/*from w w w .j a va2s .co m*/ server.unregisterMBean(name); logger.info("Unregistered MBean: " + name); } catch (Exception e) { logger.warn("Failed unregistering mbean: " + name); } }
From source file:org.jminix.server.DefaultLocalServerConnectionProvider.java
public List<MBeanServerConnection> getConnections() { List<MBeanServerConnection> result = new ArrayList<MBeanServerConnection>(); // Make sure the platform server is instanciated try {// www. j av a2 s .co m ManagementFactory.getPlatformMBeanServer(); } catch (SecurityException ex) { LogFactory.getLog(this.getClass()).warn("Not allowed to obtain the Java platform MBeanServer", ex); } try { List servers = MBeanServerFactory.findMBeanServer(null); LogFactory.getLog(this.getClass()).debug("Found " + servers.size() + " MBean servers"); result.addAll(servers); } catch (Exception e) { LogFactory.getLog(this.getClass()).warn("Could not register the Java platform MBeanServer", e); } return result; }
From source file:com.clustercontrol.plugin.impl.SummaryPlugin.java
@Override public void activate() { try {/*from ww w. jav a2 s . com*/ ManagementFactory.getPlatformMBeanServer().registerMBean(new Manager(), new ObjectName("com.clustercontrol.mbean:type=" + ManagerMXBean.class.getSimpleName())); } catch (Exception e) { log.error(e); } }
From source file:org.echocat.jemoni.jmx.JmxRegistry.java
public JmxRegistry() { this(ManagementFactory.getPlatformMBeanServer()); }
From source file:gov.nih.nci.cabig.caaers.tools.JMXBeansRegistrar.java
public void afterPropertiesSet() throws Exception { try {//from ww w. j a v a 2s . c om MBeanServer server = ManagementFactory.getPlatformMBeanServer(); for (SessionFactory sf : sessionFactories) { ObjectName on = prepareObjectName(sf); StatisticsService stats = new StatisticsService(); stats.setSessionFactory(sf); server.registerMBean(stats, on); } } catch (RuntimeException e) { log.error("Unable to register MBeans"); log.error(ExceptionUtils.getFullStackTrace(e)); } }
From source file:com.buschmais.maexo.test.server.platform.PlatformServerTest.java
/** * Looks up the platform MBean server and checks it's registration *///from w w w . ja v a 2 s . c om public void test_getPlatformMBeanServer() { MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); super.test_ServersAreRegistered(Arrays.asList(new MBeanServer[] { platformMBeanServer })); }
From source file:com.zavakid.mushroom.util.MBeans.java
static public void unregister(ObjectName mbeanName) { final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); if (mbeanName == null) return;/*from w w w . j a v a2s . c o m*/ try { mbs.unregisterMBean(mbeanName); } catch (InstanceNotFoundException e) { LOG.warn(mbeanName, e); } catch (Exception e) { LOG.warn("Error unregistering " + mbeanName, e); } }
From source file:com.taobao.common.store.util.MyMBeanServer.java
private MyMBeanServer() { try {//from ww w . j a v a 2s . c o m final boolean useJmx = Boolean.parseBoolean(System.getProperty("store4j.useJMX", "false")); if (useJmx) { mbs = ManagementFactory.getPlatformMBeanServer(); } } catch (final Exception e) { log.error("create MBServer error", e); } }