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.enioka.jqm.tools.JndiContext.java
void resetSingletons() { jqmlogger.info("Resetting singleton JNDI resource cache"); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); for (ObjectName n : this.jmxNames) { try {/*w ww . j a va 2 s. co m*/ mbs.unregisterMBean(n); } catch (Exception e) { jqmlogger.error("could not unregister bean", e); } } this.jmxNames = new ArrayList<ObjectName>(); this.singletons = new HashMap<String, Object>(); }
From source file:org.sakaiproject.kernel.component.KernelLifecycle.java
/** * Stop the kernel./*from ww w . j av a2s. c o m*/ */ public void stop() { LOG.info("Component Lifecyle is stopping"); try { lifecycleEvent(CommonLifecycleEvent.BEFORE_STOP); lifecycleEvent(CommonLifecycleEvent.STOP); componentManager.stop(); serviceManager.stop(); kernel.stop(); lifecycleEvent(CommonLifecycleEvent.AFTER_STOP); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); ObjectName kernel = new ObjectName(Kernel.MBEAN_KERNEL); mbs.unregisterMBean(kernel); } catch (Throwable ex) { LOG.error("Failed to stop Component Lifecycle ", ex); } }
From source file:com.rackspacecloud.blueflood.cache.TtlCacheTest.java
@After public void deregister() throws Exception { final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final String name = String.format(TtlCache.class.getPackage().getName() + ":type=%s,scope=%s,name=Stats", TtlCache.class.getSimpleName(), "Test"); final ObjectName nameObj = new ObjectName(name); mbs.unregisterMBean(nameObj); // involves a little unsafe knowledge of TtlCache internals. Metrics.defaultRegistry().removeMetric(TtlCache.class, "Load Errors", "Test"); Metrics.defaultRegistry().removeMetric(TtlCache.class, "Http Errors", "Test"); }
From source file:org.geoserver.wfs.notification.GMLNotificationSerializer.java
private final void unregisterMBean() { if (name == null) return;//from ww w . j av a 2 s. com for (MBeanServer server : MBeanServerFactory.findMBeanServer(null)) { try { server.unregisterMBean(name); } catch (JMException e) { LOG.warn("Unable to unregister from JMX:", e); } } }
From source file:com.tesora.dve.server.bootstrap.BootstrapHost.java
@Override protected void unregisterMBeans() { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); try {/*from w ww .j a v a2 s. c o m*/ server.unregisterMBean(new ObjectName(MBEAN_BOOTSTRAP_HOST)); } catch (Exception e) { logger.error("Unable to unregister " + MBEAN_BOOTSTRAP_HOST + " mBean", e); } try { server.unregisterMBean(new ObjectName(MBEAN_LOG4J_HIERARCHY)); } catch (Exception e) { logger.error("Unable to unregister " + MBEAN_LOG4J_HIERARCHY + " mBean", e); } super.unregisterMBeans(); }
From source file:io.fabric8.insight.log.support.LogQuerySupport.java
public void unregisterMBeanServer(MBeanServer mbeanServer) { if (mbeanServer != null) { try {/*from www. j a v a 2 s . c om*/ ObjectName name = getMbeanName(); if (name != null && mbeanServer.isRegistered(name)) { mbeanServer.unregisterMBean(name); } } catch (Exception e) { LOG.warn("An error occurred during mbean server registration: " + e, e); } } }
From source file:org.apache.openejb.resource.jdbc.dbcp.JMXBasicDataSource.java
public JMXBasicDataSource(final String name, final BasicDataSource ds) { this.ds = ds; if (LocalMBeanServer.isJMXActive()) { objectName = ObjectNameBuilder.uniqueName("datasources", name, ds); final MBeanServer server = LocalMBeanServer.get(); try {//w w w. j av a 2 s. c om if (server.isRegistered(objectName)) { server.unregisterMBean(objectName); } server.registerMBean(new DynamicMBeanWrapper(this), objectName); } catch (final Exception e) { e.printStackTrace(); // TODO } } }
From source file:chronos.web.listener.ChronosServletListener.java
/** * {@inheritDoc}/*from w w w . j av a 2s.co m*/ * * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) */ public void contextDestroyed(final ServletContextEvent event) { logger.debug("Chronos is shutting down..."); final ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); logger.debug("Got " + servers.size() + " MBean servers"); if (servers.size() != 0) { final MBeanServer mbeanServer = servers.get(0); try { final ObjectName objectName = new ObjectName(CHRONOS, "type", QUARTZ_SCHEDULER_ADAPTER); logger.debug("Invoking shutdown() on QuartzSchedulerAdapter..."); mbeanServer.invoke(objectName, "shutdown", null, null); logger.debug("Unregistering QuartzSchedulerAdapter Mbean"); mbeanServer.unregisterMBean(objectName); } catch (final JMException e) { logger.error("Shutting down QuartzSchedulerAdapter failed: " + e.getMessage(), e); } catch (final NullPointerException e) { logger.error("Shutting down QuartzSchedulerAdapter failed: " + e.getMessage(), e); } } else { logger.warn("Unable to find MBeanServer!"); } logger.info("Chronos shutdown"); }
From source file:com.enioka.jqm.tools.Loader.java
private void endOfRun() { // Register end date as soon as possible to be as exact as possible (sending mails may take time for example) endDate = GregorianCalendar.getInstance(Locale.getDefault()); // This block is needed for external payloads, as the single runner may forcefully call endOfRun. synchronized (this) { if (!isDone) { isDone = true;/*from w w w . j av a2 s . co m*/ } else { return; } } // Release the slot so as to allow other job instances to run (first op!) if (p != null) { p.decreaseNbThread(this.job.getId()); } // Send e-mail before releasing the slot - it may be long if (job.getEmail() != null) { try { Helpers.sendEndMessage(job); } catch (Exception e) { jqmlogger.warn("An e-mail could not be sent. No impact on the engine.", e); } } // Clean class loader ClassLoaderLeakCleaner.clean(Thread.currentThread().getContextClassLoader()); // Clean JDBC connections ClassLoaderLeakCleaner.cleanJdbc(Thread.currentThread()); // Restore class loader if (this.classLoaderToRestoreAtEnd != null) { Thread.currentThread().setContextClassLoader(classLoaderToRestoreAtEnd); jqmlogger.trace("Class Loader was correctly restored"); } // Clean temp dir (if it exists) File tmpDir = new File(FilenameUtils.concat(node.getTmpDirectory(), "" + job.getId())); if (tmpDir.isDirectory()) { try { if (FileUtils.deleteQuietly(tmpDir)) { jqmlogger.trace("temp directory was removed"); } else { jqmlogger.warn("Could not remove temp directory " + tmpDir.getAbsolutePath() + "for this job instance. There may be open handlers remaining open."); } } catch (Exception e) { jqmlogger.warn("Could not remove temp directory for unusual reasons", e); } } // Unregister MBean if (p != null && this.p.getEngine().loadJmxBeans) { try { MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); mbs.unregisterMBean(name); } catch (Exception e) { jqmlogger.error("Could not unregister JobInstance JMX bean", e); } } // Unregister logger unregisterLogger(); // Part needing DB connection with specific failure handling code. endOfRunDb(); }