List of usage examples for java.lang.management ManagementFactory getPlatformMBeanServer
public static synchronized MBeanServer getPlatformMBeanServer()
From source file:cc.kune.core.server.mbean.MBeanRegistry.java
/** * Instantiates a new m bean registry. */ public MBeanRegistry() { mbeanServer = ManagementFactory.getPlatformMBeanServer(); }
From source file:org.sonatype.nexus.internal.httpclient.PoolingClientConnectionManagerMBeanInstaller.java
/** * Registers the connection manager to JMX. *///from w w w . j av a 2s .c o m synchronized void register(final PoolingHttpClientConnectionManager connectionManager) { if (jmxName == null) { try { jmxName = ObjectName.getInstance(JMX_DOMAIN, "name", PoolingHttpClientConnectionManager.class.getSimpleName()); final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); server.registerMBean(new PoolingClientConnectionManagerMBeanImpl(connectionManager), jmxName); } catch (final Exception e) { LOGGER.warn("Failed to register mbean {} due to {}:{}", jmxName, e.getClass(), e.getMessage()); jmxName = null; } } else { LOGGER.warn("Already registered mbean {}", jmxName); } }
From source file:dk.au.cs.karibu.backend.standard.StandardDaemon.java
/** Create a daemon with the given name to handle the * provided message receiver endpoint. The daemon is * NOT run, use 'startAndJoin' for that, or start it manually * using the accessor method for the underlying thread. * /*from w w w. j av a 2 s .co m*/ * @param nameOfDaemon name of daemon used in the log files. * @param the message receiver endpoint */ public StandardDaemon(String nameOfDaemon, MessageReceiverEndpoint mre) { log = LoggerFactory.getLogger(StandardDaemon.class); daemonName = nameOfDaemon; receiverThread = new Thread(mre, daemonName + "-ReceiverThread"); MBeanServer mbs = null; MonitoringMBean monitor; mbs = ManagementFactory.getPlatformMBeanServer(); monitor = new Monitoring(mre); try { String theName2 = "EcoSense:name=" + daemonName + "Monitor"; ObjectName monitorBeanName = new ObjectName(theName2); mbs.registerMBean(monitor, monitorBeanName); log.info("Registered JMX bean: " + nameOfDaemon); } catch (Exception e) { String theTrace = ExceptionUtils.getStackTrace(e); log.error("JMX bean exception: " + theTrace); } }
From source file:io.gravitee.management.standalone.jetty.JettyServerFactory.java
@Override public Server getObject() throws Exception { // Setup ThreadPool QueuedThreadPool threadPool = new QueuedThreadPool(jettyConfiguration.getPoolMaxThreads(), jettyConfiguration.getPoolMinThreads(), jettyConfiguration.getPoolIdleTimeout(), new ArrayBlockingQueue<Runnable>(jettyConfiguration.getPoolQueueSize())); threadPool.setName("gravitee-listener"); Server server = new Server(threadPool); // Extra options server.setDumpAfterStart(false);/*from w w w .j a v a2s . c o m*/ server.setDumpBeforeStop(false); server.setStopAtShutdown(true); // Setup JMX if (jettyConfiguration.isJmxEnabled()) { MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer()); server.addBean(mbContainer); } // HTTP Configuration HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setSecureScheme("https"); httpConfig.setSecurePort(8443); httpConfig.setOutputBufferSize(32768); httpConfig.setRequestHeaderSize(8192); httpConfig.setResponseHeaderSize(8192); httpConfig.setSendServerVersion(false); httpConfig.setSendDateHeader(false); // Setup Jetty HTTP Connector ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig)); http.setPort(jettyConfiguration.getHttpPort()); http.setIdleTimeout(jettyConfiguration.getIdleTimeout()); server.addConnector(http); // Setup Jetty statistics if (jettyConfiguration.isStatisticsEnabled()) { StatisticsHandler stats = new StatisticsHandler(); stats.setHandler(server.getHandler()); server.setHandler(stats); } if (jettyConfiguration.isAccessLogEnabled()) { AsyncNCSARequestLog requestLog = new AsyncNCSARequestLog(jettyConfiguration.getAccessLogPath()); requestLog.setRetainDays(90); requestLog.setExtended(true); requestLog.setLogLatency(true); requestLog.setLogTimeZone("GMT"); server.setRequestLog(requestLog); } return server; }
From source file:com.alibaba.dragoon.client.DragoonClientStandardMBeanProviderFilter.java
@Override public void stop(DaemonServiceLifeCycleFilterChain chain) { try {//w w w . j a v a 2 s . c o m standardMBeanProvider.unregister(ManagementFactory.getPlatformMBeanServer()); } catch (JMException e) { LOG.error("stop error", e); } chain.stop(); }
From source file:org.sonatype.nexus.apachehttpclient.PoolingClientConnectionManagerMBeanInstaller.java
/** * Registers the connection manager to JMX. *//*from w w w . j a v a 2 s .com*/ public synchronized void register(final PoolingHttpClientConnectionManager connectionManager) { if (jmxName == null) { try { jmxName = ObjectName.getInstance(JMX_DOMAIN, "name", PoolingHttpClientConnectionManager.class.getSimpleName()); final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); server.registerMBean(new PoolingClientConnectionManagerMBeanImpl(connectionManager), jmxName); } catch (final Exception e) { LOGGER.warn("Failed to register mbean {} due to {}:{}", jmxName, e.getClass(), e.getMessage()); jmxName = null; } } else { LOGGER.warn("Already registered mbean {}", jmxName); } }
From source file:io.fabric8.insight.metrics.MetricsTest.java
@Test public void testDefault() throws Exception { Query query = new Query("test", new HashSet<Request>(Arrays.asList( new MBeanAttrs("memory", "java.lang:type=Memory", Arrays.asList("HeapMemoryUsage", "NonHeapMemoryUsage")), new MBeanOpers("deadlocks", "java.lang:type=Threading", "dumpAllThreads", Arrays.<Object>asList(true, true), Arrays.<String>asList(boolean.class.getName(), boolean.class.getName())))), null, null, null, 0, 0);/* w ww . ja va 2 s . c o m*/ System.gc(); QueryResult qrs = JmxUtils.execute(new Server("local"), query, ManagementFactory.getPlatformMBeanServer()); String output = new Renderer().render(qrs); Map map = new ObjectMapper().readValue(output, Map.class); assertEquals("local", map.get("host")); assertNotNull(map.get("@timestamp")); }
From source file:org.nuxeo.ecm.webapp.seam.NuxeoSeamWebGate.java
protected Set<WebConnector> fetchConnectors() { Set<WebConnector> connectors = new HashSet<WebConnector>(); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName names;// w w w.java2 s. com try { names = new ObjectName("Catalina:type=Connector,port=*,address=*"); } catch (MalformedObjectNameException e) { log.error("Cannot query for tomcat connectors", e); return connectors; } Set<ObjectInstance> ois = mbs.queryMBeans(names, null); for (ObjectInstance oi : ois) { WebConnector connector = JMX.newMBeanProxy(mbs, oi.getObjectName(), WebConnector.class); connectors.add(connector); } return connectors; }
From source file:org.rhq.enterprise.server.util.HibernatePerformanceMonitor.java
public void zeroStats() { if (isLoggingEnabled()) { EntityManager entityManager = LookupUtil.getEntityManager(); MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); Statistics stats = PersistenceUtility.getStatisticsService(entityManager, platformMBeanServer); stats.clear();//from w ww . j av a 2 s . co m } }
From source file:org.apache.axis2.transport.base.TransportMBeanSupport.java
private TransportMBeanSupport(String connectorName, TransportView mbeanInstance) { try {// ww w .j a va 2 s . c om mbs = ManagementFactory.getPlatformMBeanServer(); } catch (SecurityException ex) { log.warn("Unable to get the platform MBean server; JMX support disabled", ex); enabled = false; return; } String jmxAgentName = System.getProperty("jmx.agent.name"); if (jmxAgentName == null || "".equals(jmxAgentName)) { jmxAgentName = "org.apache.axis2"; } String mbeanNameString = jmxAgentName + ":Type=Transport,ConnectorName=" + connectorName; try { mbeanName = ObjectName.getInstance(mbeanNameString); } catch (MalformedObjectNameException ex) { log.warn("Unable to create object name '" + mbeanNameString + "'; JMX support disabled", ex); enabled = false; } this.mbeanInstance = mbeanInstance; }