List of usage examples for javax.management ObjectName ObjectName
public ObjectName(String name) throws MalformedObjectNameException
From source file:hermes.ext.jbossmq.JBossMQAdmin.java
@Override protected Collection discoverDurableSubscriptions(String topicName, String jndiName) throws JMSException { final Collection<DestinationConfig> rval = new ArrayList<DestinationConfig>(); try {/* ww w . j a va 2s . co m*/ final ObjectName objectName = new ObjectName( "jboss.mq.destination:name=" + topicName + ",service=Topic"); final Collection<DurableSubscriptionID> durableSubs = (Collection<DurableSubscriptionID>) getRMIAdapter() .invoke(objectName, "listDurableSubscriptions", new String[0], new String[0]); for (final DurableSubscriptionID id : durableSubs) { if (getHermes().getConnection().getClientID() != null && getHermes().getConnection().getClientID().equals(id.getClientID())) { final DestinationConfig dConfig = HermesBrowser.getConfigDAO().createDestinationConfig(); dConfig.setClientID(id.getSubscriptionName()); dConfig.setName(jndiName == null ? topicName : jndiName); dConfig.setDomain(Domain.TOPIC.getId()); dConfig.setSelector(id.getSelector()); dConfig.setDurable(true); rval.add(dConfig); } else { log.debug("skipping subscription name=" + id.getSubscriptionName() + " as its not for this connection clientID"); } } } catch (Exception e) { log.error(e.getMessage(), e); } return rval; }
From source file:de.unioninvestment.eai.portal.portlet.crud.domain.model.JolokiaMBeanServerConnectionTest.java
@Test public void shouldGetAttribute() throws IOException, AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, J4pException, MalformedObjectNameException, ParseException { ObjectName objectName = new ObjectName(TEST_OBJECT_NAME_ATTR); JolokiaMBeanServerConnection jolokiaMBeanServerConnection = new JolokiaMBeanServerConnection(); jolokiaMBeanServerConnection.setJ4pClient(j4pClientMock); J4pReadRequest request = new J4pReadRequest(objectName, "currentState"); J4pResponse<J4pReadRequest> response = new J4pResponse<J4pReadRequest>(request, (JSONObject) new JSONParser().parse(TEST_RESPONSE_ATTR)) { };//w w w . j a va2s . c om when(j4pClientMock.execute(any(J4pReadRequest.class))).thenReturn(response); assertTrue("Shutdown".equals(jolokiaMBeanServerConnection.getAttribute(objectName, "currentState"))); }
From source file:be.fedict.trust.service.snmp.SNMPInterceptor.java
public static void setValue(String oid, String service, Long value) { LOG.debug("set value of counter oid=" + oid + " @ service=" + service + " to " + value); try {/*from w ww . j a v a2s. c o m*/ for (MBeanServer mBeanServer : MBeanServerFactory.findMBeanServer(null)) { mBeanServer.invoke(new ObjectName(service), "setValue", new Object[] { oid, value }, new String[] { "java.lang.String", "java.lang.Long" }); } } catch (Exception e) { LOG.error("Failed to contact SNMP Mbean: " + e.getMessage(), e); } }
From source file:io.github.albertopires.mjc.JConsoleM.java
public long getUpTime() throws Exception { ObjectName mbeanName;// w ww .j a v a 2 s .c o m mbeanName = new ObjectName("java.lang:type=Runtime"); Long ut; ut = (Long) mbsc.getAttribute(mbeanName, "Uptime"); return ut.longValue(); }
From source file:com.dsf.dbxtract.cdc.AppJournalWindowTest.java
@Test(dependsOnMethods = { "testAppWithJournalWindow" }) public void testInfoStatistics() throws Exception { JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:5000/jmxrmi"); JMXConnector jmxc = JMXConnectorFactory.connect(url, null); MBeanServerConnection mbsc = jmxc.getMBeanServerConnection(); ObjectName mbeanName = new ObjectName("com.dsf.dbxtract:type=InfoMBean"); TabularDataSupport info = (TabularDataSupport) mbsc.getAttribute(mbeanName, InfoMBean.ATTR_INFO); Collection<?> list = info.values(); boolean hasHandlerEntry = false; for (Iterator<?> it = list.iterator(); it.hasNext();) { CompositeDataSupport entry = (CompositeDataSupport) it.next(); if (entry.get("handler").equals(TestWindowHandler.class.getName())) { assert (((Long) entry.get("readCount")).longValue() == TEST_SIZE); hasHandlerEntry = true;//from w w w . j av a 2s . c o m } } assert (hasHandlerEntry); jmxc.close(); }
From source file:com.sun.grizzly.http.jk.core.JkHandler.java
public ObjectName preRegister(MBeanServer server, ObjectName oname) throws Exception { this.oname = oname; mserver = server;// www . ja v a 2 s . c om domain = oname.getDomain(); if (name == null) { name = oname.getKeyProperty("name"); } // we need to create a workerEnv or set one. ObjectName wEnvName = new ObjectName(domain + ":type=JkWorkerEnv"); if (wEnv == null) { wEnv = new WorkerEnv(); } if (!mserver.isRegistered(wEnvName)) { Registry.getRegistry(null, null).registerComponent(wEnv, wEnvName, null); } mserver.invoke(wEnvName, "addHandler", new Object[] { name, this }, new String[] { "java.lang.String", "com.sun.grizzly.http.jk.core.JkHandler" }); return oname; }
From source file:fr.openfarm.jmx.service.JMXQuery.java
@Override public List<KeyResponse> getJmxKeys(String name, String attributeName) throws MalformedObjectNameException, NullPointerException, AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException, IOException { List<KeyResponse> response = new ArrayList<KeyResponse>(); ObjectName objectName = new ObjectName(name); Set<ObjectName> objectNameList = connection.queryNames(objectName, null); if (objectNameList != null && objectNameList.size() > 0) { objectName = objectNameList.iterator().next(); Object attr = connection.getAttribute(objectName, attributeName); if (attr instanceof CompositeDataSupport) { CompositeDataSupport cds = (CompositeDataSupport) attr; CompositeType type = cds.getCompositeType(); Set<String> listKey = type.keySet(); for (Object key : listKey) { if (key instanceof String) { Object value = cds.get((String) key); KeyResponse keyResponse = new KeyResponse(); keyResponse.setKey(key.toString()); keyResponse.setValue(value.toString()); response.add(keyResponse); }/*from w ww .j a va 2s .c o m*/ } } else { KeyResponse keyResponse = new KeyResponse(); keyResponse.setValue(attr.toString()); response.add(keyResponse); } } return response; }
From source file:com.rosy.bill.utils.jmx.JmxClientTemplate.java
/** * ObjectName,?unchecked exception./*w w w . j a v a 2s .c o m*/ */ private ObjectName buildObjectName(final String mbeanName) { try { return new ObjectName(mbeanName); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException("mbeanName:" + mbeanName + "?,?ObjectName.", e); } }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.util.MMXConfigurationTest.java
@Before public void setup() throws Exception { MMXManagedConfiguration mmxConfigMBean = new MMXManagedConfiguration(MMXConfiguration.getConfiguration()); ObjectName name = new ObjectName(MMX_MBEAN_OBJECT_NAME); server.registerMBean(mmxConfigMBean, name); url = new JMXServiceURL(JMX_SERVICE_URI); JiveGlobalsMock.setup();/* w w w. j a va 2 s . c om*/ jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server); jmxConnectorServer.start(); new MockUp<JiveGlobals>() { @Mock public boolean isPropertyEncrypted(String name) { return false; } }; }
From source file:io.github.albertopires.mjc.JConsoleM.java
public long getOSProcessCpuTime() throws Exception { ObjectName mbeanName;/*from ww w . jav a 2 s. c om*/ mbeanName = new ObjectName("java.lang:type=OperatingSystem"); Long ut; ut = (Long) mbsc.getAttribute(mbeanName, "ProcessCpuTime"); return ut.longValue(); }