List of usage examples for javax.management ObjectName ObjectName
public ObjectName(String domain, Hashtable<String, String> table) throws MalformedObjectNameException
From source file:gov.nih.nci.cabig.caaers.tools.JMXBeansRegistrar.java
/** * @return/*from ww w .jav a2 s . c o m*/ * @throws MalformedObjectNameException * @throws NullPointerException */ private ObjectName prepareObjectName(SessionFactory sessionFactory) throws MalformedObjectNameException, NullPointerException { Hashtable tb = new Hashtable(); tb.put("type", "statistics"); tb.put("sessionFactory", "Session Factory #" + sessionFactories.indexOf(sessionFactory)); ObjectName on = new ObjectName("hibernate", tb); // MBean object // name return on; }
From source file:de.msg.terminfindung.common.jmx.TestJmxUeberwachung.java
@Test public void testJmxUeberwachung() throws Exception { // SpringContext initialisieren und Komponente holen //Meldung meldung = (Meldung) SpringContextHolder.getBean("meldung"); // Holen des MBeanServers ArrayList<MBeanServer> mBeanServerList = MBeanServerFactory.findMBeanServer(null); MBeanServer mBeanServer = mBeanServerList.get(0); // Lesen der gewnschten Information per JMX // de.bund.bva.isyfact.terminfindung:type=ServiceStatistik,name="Erstellung-Statistik" Hashtable<String, String> table = new Hashtable<>(); table.put("type", "ServiceStatistik"); table.put("name", "\"Erstellung-Statistik\""); ObjectName testObjectName = new ObjectName("de.bund.bva.isyfact.terminfindung", table); String testAttributeName = "DurchschnittsDauerLetzteAufrufe"; String result = mBeanServer.getAttribute(testObjectName, testAttributeName).toString(); // Auswerten des Ergebnisses assertEquals("0", result); // Einen Anwendungsfall ausfhren contr.initialisiereModel(new ErstellenModel()); result = mBeanServer.getAttribute(testObjectName, testAttributeName).toString(); assertNotEquals("0", result); }
From source file:br.com.uol.runas.classloader.ClassLoaderGC.java
private void deregisterOracleDiagnosabilityMBean(WeakReference<ClassLoader> classLoader) { try {//from w w w . j a v a 2 s. c om 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:com.stratuscom.harvester.deployer.FolderBasedAppRunner.java
private void registerApplication(ServiceLifeCycle deployedApp) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { Hashtable<String, String> props = new Hashtable<String, String>(); props.put(com.stratuscom.harvester.Strings.NAME, deployedApp.getName()); ObjectName oName = new ObjectName(com.stratuscom.harvester.Strings.CONTAINER_JMX_DOMAIN, props); mbeanRegistrar.getMbeanServer().registerMBean(deployedApp, oName); }
From source file:com.stratuscom.harvester.deployer.FolderBasedAppRunner.java
private void unregisterApplication(ServiceLifeCycle deployedApp) { try {/* w ww . j av a 2 s . c om*/ Hashtable<String, String> props = new Hashtable<String, String>(); props.put(com.stratuscom.harvester.Strings.NAME, deployedApp.getName()); ObjectName oName = new ObjectName(com.stratuscom.harvester.Strings.CONTAINER_JMX_DOMAIN, props); mbeanRegistrar.getMbeanServer().unregisterMBean(oName); } catch (Exception e) { log.log(Level.SEVERE, MessageNames.FAILED_TO_REMOVE_MBEAN, new Object[] { deployedApp.getName() }); } }
From source file:com.linkedin.databus.client.pub.mbean.UnifiedClientStats.java
@Override public ObjectName generateObjectName() throws MalformedObjectNameException { Hashtable<String, String> mbeanProps = generateBaseMBeanProps(); mbeanProps.put("ownerId", Integer.toString(_event.ownerId)); mbeanProps.put("dimension", _dimension); return new ObjectName(AbstractMonitoringMBean.JMX_DOMAIN, mbeanProps); }
From source file:dk.netarkivet.common.management.SingleMBeanObject.java
/** * Registers this object as a standard MBean, with a name generated from * domain given in constructor and the nameProperties hashTable. * * @throws IllegalState if bean is already registered. * @throws IOFailure on trouble registering. *//*from ww w . ja va 2 s .c o m*/ public void register() { try { name = new ObjectName(domain, nameProperties); mBeanServer.registerMBean(new StandardMBean(exposedObject, asInterface), name); log.trace("Registered mbean '" + name + "'"); } catch (InstanceAlreadyExistsException e) { String msg = "this MBean '" + name + "' is already registered on " + "the MBeanServer"; log.warn(msg, e); throw new IllegalState(msg, e); } catch (JMException e) { throw new IOFailure("Unable to register MBean '" + name + "'", e); } }
From source file:dk.netarkivet.common.management.SingleMBeanObject.java
/** * Unregister the object from the MBeanServer. Note: It is not checked that * it is actually this mbean that is registered under the name, this method * simply unregisters any object with this object name. * * @throws IOFailure on trouble unregistering. *///w w w . ja v a 2 s. c om public void unregister() { MBeanServer mbserver = mBeanServer; try { if (name != null) { name = new ObjectName(domain, nameProperties); } if (mbserver.isRegistered(name)) { mbserver.unregisterMBean(name); } } catch (JMException e) { throw new IOFailure("Unable to unregister MBean '" + name + "'", e); } }
From source file:com.linkedin.databus2.relay.GoldenGateEventProducer.java
private void registerParserMbean(GGParserStatisticsMBean parserBean) throws DatabusException { try {/* w w w . j a va 2s . c o m*/ Hashtable<String, String> props = new Hashtable<String, String>(); props.put("type", "GGParserStatistics"); props.put("name", _pConfig.getName()); ObjectName objectName = new ObjectName(ServerContainer.JMX_DOMAIN, props); if (_mbeanServer.isRegistered(objectName)) { _log.warn("Unregistering old ggparser statistics mbean: " + objectName); _mbeanServer.unregisterMBean(objectName); } _mbeanServer.registerMBean(parserBean, objectName); _log.info("Registered gg-parser statistics mbean: " + objectName); _registeredMbeans.add(objectName); } catch (Exception ex) { _log.error("Failed to register the GGparser statistics mbean for db = " + _pConfig.getName() + " due to an exception.", ex); throw new DatabusException("Failed to initialize GGparser statistics mbean.", ex); } }
From source file:com.qwazr.server.GenericServer.java
private void startHttpServer(final ServerConfiguration.WebConnector connector, final ServletContextBuilder context, final AccessLogger accessLogger) throws IOException, ServletException, OperationsException, MBeanException { if (context == null || context.getServlets().isEmpty()) return;/* ww w . j a v a2 s . c om*/ context.setIdentityManager(getIdentityManager(connector)); contextAttributes.forEach(context::addServletContextAttribute); if (context.getIdentityManager() != null && !StringUtils.isEmpty(connector.authentication)) { if (hostnamePrincipalResolver != null) HostnameAuthenticationMechanism.register(context, hostnamePrincipalResolver); final LoginConfig loginConfig = Servlets.loginConfig(connector.realm); for (String authmethod : StringUtils.split(connector.authentication, ',')) loginConfig.addLastAuthMethod(authmethod); context.setLoginConfig(loginConfig); } final DeploymentManager manager = servletContainer.addDeployment(context); manager.deploy(); LOGGER.info(() -> "Start the connector " + configuration.listenAddress + ":" + connector.port); HttpHandler httpHandler = manager.start(); final LogMetricsHandler logMetricsHandler = new LogMetricsHandler(httpHandler, configuration.listenAddress, connector.port, context.jmxName, accessLogger); deploymentManagers.add(manager); httpHandler = logMetricsHandler; final Undertow.Builder servletBuilder = Undertow.builder() .addHttpListener(connector.port, configuration.listenAddress) .setServerOption(UndertowOptions.NO_REQUEST_TIMEOUT, 10000) .setServerOption(UndertowOptions.RECORD_REQUEST_START_TIME, true) .setServerOption(UndertowOptions.ENABLE_STATISTICS, true) .setServerOption(UndertowOptions.ENABLE_HTTP2, true).setHandler(httpHandler); start(servletBuilder.build()); // Register MBeans final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); final Hashtable<String, String> props = new Hashtable<>(); props.put("type", "connector"); props.put("name", context.jmxName); final ObjectName name = new ObjectName( "com.qwazr.server." + serverCounter.incrementAndGet() + "." + context.jmxName, props); mbs.registerMBean(logMetricsHandler, name); registeredObjectNames.add(name); connectorsStatistics.add(logMetricsHandler); }