List of usage examples for javax.management MBeanServer unregisterMBean
public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException;
If this method successfully unregisters an MBean, a notification is sent as described above.
From source file:com.octo.captcha.j2ee.ImageCaptchaService.java
/** * Unregister self from the first MBean server available in the JVM, if any */// www . j a va 2 s . co m public void unregisterFromMBeanServer() { if (this.registeredName != null) { ArrayList mbeanServers = MBeanServerFactory.findMBeanServer(null); MBeanServer mbeanServer = (MBeanServer) mbeanServers.get(0); try { ObjectName name = new ObjectName(this.registeredName); mbeanServer.unregisterMBean(name); } catch (MalformedObjectNameException e) { // this should never happens log.error("Exception trying to create the object name under witch" + " the service is registered", e); } catch (InstanceNotFoundException e) { // this should never happens log.error("Exception trying to unregister the ImageCaptchaFilter from" + " the MBean server", e); } catch (MBeanRegistrationException e) { // this remains silent for the client log.error("Exception trying to unregister the ImageCaptchaFilter from" + "the MBean server", e); } } }
From source file:org.red5.server.winstone.WinstoneLoader.java
protected void unregisterJMX() { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); try {//from w ww. ja va 2 s . c o m ObjectName oName = new ObjectName("org.red5.server:type=WinstoneLoader"); mbs.unregisterMBean(oName); } catch (Exception e) { log.warn("Exception unregistering", e); } }
From source file:org.apache.ode.jbi.OdeLifeCycle.java
private void registerMBean() throws JBIException { ProcessAndInstanceManagementMBean pmapi = new ProcessAndInstanceManagementMBean(_ode._server, _ode._store); MBeanServer server = _ode.getContext().getMBeanServer(); try {//ww w . ja v a 2 s .c om if (server != null) { _mbeanName = _ode.getContext().getMBeanNames().createCustomComponentMBeanName("Management"); if (server.isRegistered(_mbeanName)) { server.unregisterMBean(_mbeanName); } server.registerMBean(pmapi, _mbeanName); } } catch (Exception e) { throw new JBIException(e); } }
From source file:org.rhq.core.pc.measurement.MeasurementManager.java
public void shutdown() { if (this.collectorThreadPool != null) { this.collectorThreadPool.shutdownNow(); }//from w w w . j a v a 2 s .c o m if (this.senderThreadPool != null) { this.senderThreadPool.shutdownNow(); } if (configuration.isStartManagementBean()) { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); try { server.unregisterMBean(new ObjectName(OBJECT_NAME)); } catch (JMException e) { LOG.warn("Unable to unregister MeasurementManagerMBean", e); } } }
From source file:org.apache.axis2.transport.base.AbstractTransportListener.java
/** * Utility method to allow transports to register MBeans * @param mbeanInstance bean instance//from w ww.j a v a 2 s .co m * @param objectName name */ private void registerMBean(Object mbeanInstance, String objectName) { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName name = new ObjectName(objectName); 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 objectname ' " + objectName + " ' for JMX management", e); } }
From source file:org.codice.ddf.spatial.admin.module.service.Geocoding.java
private void registerMbean() { ObjectName objectName = null; MBeanServer mBeanServer = null; try {/*from ww w . ja v a2s. c o m*/ objectName = new ObjectName(Geocoding.class.getName() + ":service=geocoding"); mBeanServer = ManagementFactory.getPlatformMBeanServer(); } catch (MalformedObjectNameException e) { LOGGER.error("Unable to create Geocoding Configuration MBean.", e); } if (mBeanServer != null) { try { try { mBeanServer.registerMBean(this, objectName); LOGGER.info("Registered Geocoding Configuration MBean under object name: {}", objectName.toString()); } catch (InstanceAlreadyExistsException e) { // Try to remove and re-register mBeanServer.unregisterMBean(objectName); mBeanServer.registerMBean(this, objectName); LOGGER.info("Re-registered Geocoding Configuration MBean"); } } catch (Exception e) { LOGGER.error("Could not register MBean [{}].", objectName.toString(), e); } } }
From source file:org.wso2.carbon.caching.jsr107.CacheImpl.java
@Override public void stop() { Util.checkAccess(ownerTenantDomain, ownerTenantId); checkStatusStarted();/*w w w .ja va 2s .c o m*/ lastAccessed = System.currentTimeMillis(); getMap().clear(); if (!isLocalCache) { distributedCache.flush(); } // Unregister the cacheMXBean MBean MBeanServer mserver = getMBeanServer(); try { mserver.unregisterMBean(cacheMXBeanObjName); } catch (InstanceNotFoundException ignored) { } catch (MBeanRegistrationException e) { log.error("Cannot unregister CacheMXBean", e); } status = Status.STOPPED; cacheManager.removeCache(cacheName); }
From source file:org.openehealth.coala.lifecycle.FacesAppListener.java
@Override public void processEvent(SystemEvent event) throws AbortProcessingException { /*/*from w w w .j ava 2s .c o m*/ * STARTUP PHASE - nothing yet */ if (event instanceof PostConstructApplicationEvent) { LOG.info("PostConstructApplicationEvent is called"); } /* * SHUTDOWN PHASE - cleaning up PDQ/XDS ipf routes (mwiesner) */ if (event instanceof PreDestroyApplicationEvent) { LOG.info("PreDestroyApplicationEvent is called"); MBeanServer mbserver = null; ArrayList<MBeanServer> mbservers = MBeanServerFactory.findMBeanServer(null); if (mbservers.size() > 0) { mbserver = (MBeanServer) mbservers.get(0); } if (mbserver != null) { LOG.info("Found our MBean server instance..."); } else { mbserver = MBeanServerFactory.createMBeanServer(); } try { Set<ObjectInstance> mbeans = mbserver.queryMBeans(null, null); for (ObjectInstance mb : mbeans) { if (mb.getObjectName().getCanonicalName().contains("camelContext-pdq")) { LOG.info("Successfully removed MBean: " + mb.getObjectName().getCanonicalName()); mbserver.unregisterMBean(mb.getObjectName()); } else if (mb.getObjectName().getCanonicalName().contains("camelContext-xds")) { LOG.info("Successfully removed MBean: " + mb.getObjectName().getCanonicalName()); mbserver.unregisterMBean(mb.getObjectName()); } } } catch (InstanceNotFoundException infe) { LOG.warn("Ignoring to unregister pdq/xds camelContext, as it was not found!?"); } catch (Throwable e) { LOG.error(e.getLocalizedMessage(), e); } } }
From source file:org.red5.server.undertow.UndertowLoader.java
protected void unregisterJMX() { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); try {/*from ww w . j av a 2 s.c om*/ ObjectName oName = new ObjectName("org.red5.server:type=UndertowLoader"); mbs.unregisterMBean(oName); } catch (Exception e) { log.warn("Exception unregistering", e); } }
From source file:com.mustardgrain.solr.SolrClient.java
private void unregisterMBean() { if (objectName == null) return;/*from w ww . j ava2 s . c o m*/ try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.unregisterMBean(objectName); if (LOG.isInfoEnabled()) LOG.info("Unregistered " + objectName); } catch (Exception e) { if (LOG.isWarnEnabled()) LOG.warn("Couldn't remove MBean " + objectName.toString()); } }