List of usage examples for java.lang.management ManagementFactory getPlatformMBeanServer
public static synchronized MBeanServer getPlatformMBeanServer()
From source file:org.apache.cassandra.auth.JMXResource.java
@Override public boolean exists() { if (!hasParent()) return true; MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); try {//from ww w .jav a 2 s .co m return !(mbs.queryNames(new ObjectName(name), null).isEmpty()); } catch (MalformedObjectNameException e) { return false; } catch (NullPointerException e) { return false; } }
From source file:de.micromata.mgc.application.jetty.JettyServer.java
protected void initJmx(final JettyConfigModel config, final ServletContextHandler contextHandler) { if (config.isServerEnableJmx() == false) { return;/*from w w w . ja va2 s . c om*/ } final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); final MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer); contextHandler.addEventListener(mBeanContainer); }
From source file:org.wso2.andes.kernel.registry.StorageQueueRegistry.java
/** * Remove registered storage queue from in-memory registry * * @param queueName name of the queue/*from w w w . j av a 2s . c om*/ * @return removed queue. Null if nothing is removed * @throws AndesException */ public StorageQueue removeStorageQueue(String queueName) throws AndesException { StorageQueue storageQueue = storageQueueMap.remove(queueName); storageQueue.unbindQueueFromMessageRouter(); //unregister subscription mbean of a durable subscription if (queueName.startsWith(AndesConstants.DURABLE_SUBSCRIPTION_QUEUE_PREFIX) && isMbeanRegistered(queueName)) { Hashtable<String, String> tab = getMbeanObjectnameProp(queueName); try { ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(ANDES_DOMAIN, tab)); } catch (Exception e) { log.error("Unable to unregister subscription mbean!", e); } } return storageQueue; }
From source file:org.apache.streams.util.ComponentUtils.java
/** * Attempts to register an object with local MBeanServer. Throws runtime exception on errors. * @param name name to register bean with * @param mbean mbean to register// ww w . j av a2s .co m */ public static <V> void registerLocalMBean(String name, V mbean) { try { ObjectName objectName = new ObjectName(name); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.registerMBean(mbean, objectName); } catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) { LOGGER.error("Failed to register MXBean : {}", e); throw new RuntimeException(e); } }
From source file:org.wso2.andes.server.management.JMXManagedObjectRegistry.java
public JMXManagedObjectRegistry() throws AMQException { _log.info("Initialising managed object registry using jplatform MBean server"); IApplicationRegistry appRegistry = ApplicationRegistry.getInstance(); // Retrieve the config parameters _useCustomSocketFactory = appRegistry.getConfiguration().getUseCustomRMISocketFactory(); boolean platformServer = appRegistry.getConfiguration().getPlatformMbeanserver(); _mbeanServer = platformServer ? ManagementFactory.getPlatformMBeanServer() : MBeanServerFactory.createMBeanServer(ManagedObject.DOMAIN); }
From source file:br.com.uol.runas.classloader.ClassLoaderGC.java
private void deregisterOracleDiagnosabilityMBean(WeakReference<ClassLoader> classLoader) { try {/*from w ww.j a v a 2s . c o m*/ final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final Hashtable<String, String> keys = new Hashtable<String, String>(); keys.put("type", "diagnosability"); keys.put("name", classLoader.get().getClass().getName() + "@" + Integer.toHexString(classLoader.get().hashCode()).toLowerCase()); mbs.unregisterMBean(new ObjectName("com.oracle.jdbc", keys)); } catch (Throwable e) { e.printStackTrace(); } }
From source file:nz.co.fortytwo.signalk.processor.FullExportProcessor.java
public FullExportProcessor(String wsSession, String routeId) { super();/*from w w w . ja v a 2 s . c o m*/ this.wsSession = wsSession; this.routeId = routeId; lastSend = new AtomicLong(System.currentTimeMillis()); signalkModel.getEventBus().register(this); //setup jmx //register the MBean try { ObjectName name = new ObjectName(getClass().getName(), "id", UUID.randomUUID().toString()); ManagementFactory.getPlatformMBeanServer().registerMBean(this, name); } catch (Exception e) { // TODO Auto-generated catch block logger.error(e.getMessage(), e); } }
From source file:co.paralleluniverse.common.monitoring.PeriodicMonitor.java
public void unregisterMBean() { try {/*from w w w . ja v a2 s. c o m*/ if (registered) { LOG.info("Unregistering MBean {}", name); ManagementFactory.getPlatformMBeanServer().unregisterMBean(new ObjectName(name)); timer.stop(); } this.registered = false; } catch (Exception e) { LOG.warn("Exception:", e); } }
From source file:com.neophob.sematrix.core.jmx.PixelControllerStatus.java
/** * Register the JMX Bean./*from www. java 2 s.co m*/ * * @param configuredFps the configured fps */ public PixelControllerStatus(Collector col, int configuredFps) { LOG.log(Level.INFO, "Initialize the PixelControllerStatus JMX Bean"); this.configuredFps = configuredFps; this.col = col; // initialize all buffers this.timeMeasureMapGlobal = new ConcurrentHashMap<TimeMeasureItemGlobal, CircularFifoBuffer>(); for (TimeMeasureItemGlobal timeMeasureItem : TimeMeasureItemGlobal.values()) { this.timeMeasureMapGlobal.put(timeMeasureItem, new CircularFifoBuffer(this.configuredFps * SECONDS)); } this.timeMeasureMapOutput = new ConcurrentHashMap<IOutput, Map<TimeMeasureItemOutput, CircularFifoBuffer>>(); this.outputList = new ArrayList<IOutput>(); startTime = System.currentTimeMillis(); // register MBean try { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName(JMX_BEAN_NAME); // check if the MBean is already registered if (!server.isRegistered(name)) { server.registerMBean(this, name); } } catch (JMException ex) { LOG.log(Level.WARNING, "Error while registering class as JMX Bean.", ex); } }
From source file:com.ricston.connectors.dataanalysis.DataAnalysisConnector.java
/** * Stop the module by closing the Map DB and unregister from the Mbean server * //from w ww. ja v a 2s. c o m * @throws MalformedObjectNameException * @throws MBeanRegistrationException * @throws InstanceNotFoundException */ @Stop public void stopModule() throws MalformedObjectNameException, MBeanRegistrationException, InstanceNotFoundException { logger.info("**********************************"); logger.info("*Stopping Data Analysis Connector*"); logger.info("**********************************"); MBeanServer server = ManagementFactory.getPlatformMBeanServer(); ObjectName id = new ObjectName(String.format(MBEAN_NAME, application)); server.unregisterMBean(id); logger.info("Unregistered mbean with name: " + String.format(MBEAN_NAME, application)); stopMapDb(); }