List of usage examples for javax.management ObjectName getInstance
public static ObjectName getInstance(ObjectName name)
Return an instance of ObjectName that can be used anywhere the given object can be used.
From source file:com.flipkart.poseidon.jmx.PoseidonJMXInvoker.java
public static void main(String[] args) { if (args.length < 3) { System.err.println(PoseidonJMXInvoker.class.getSimpleName() + " <host> <port> <operation>"); System.exit(-1);// w w w. ja v a2 s . com } final String CONNECT_STRING = args[0] + ":" + args[1]; final String OPERATION = args[2]; try { System.out.println("Running " + OPERATION + " over JMX on " + CONNECT_STRING); JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + CONNECT_STRING + "/jmxrmi"); MBeanServerConnection connection = JMXConnectorFactory.connect(url).getMBeanServerConnection(); connection.invoke(ObjectName.getInstance(MBEAN_NAME), OPERATION, null, null); } catch (Exception e) { if (!(ExceptionUtils.getRootCause(e) instanceof EOFException && "destroy".equals(OPERATION))) { e.printStackTrace(); System.exit(-1); } } System.out.println(OPERATION + " successful over JMX on " + CONNECT_STRING); }
From source file:fr.xebia.management.jms.SpringManagedConnectionFactory.java
public ObjectName getObjectName() throws MalformedObjectNameException { return ObjectName.getInstance("javax.jms:type=ConnectionFactory,name=" + beanName); }
From source file:org.cloudfoundry.identity.statsd.MBeanMapTests.java
@Test public void testListDomain() throws Exception { Set<ObjectName> names = server.queryNames(ObjectName.getInstance("java.lang:type=Runtime,*"), null); System.err.println(names);//from w w w . jav a2 s .c om assertTrue(names.size() == 1); MBeanMap result = new MBeanMap(server, names.iterator().next()); @SuppressWarnings("unchecked") Map<String, String> properties = (Map<String, String>) result.get("system_properties"); assertTrue(properties.containsKey("java.vm.version")); }
From source file:org.cloudfoundry.identity.uaa.varz.MBeanMapTests.java
@Test public void testListDomain() throws Exception { Set<ObjectName> names = server.queryNames(ObjectName.getInstance("java.lang:type=Runtime,*"), null); System.err.println(names);// w w w .j av a2 s . com assertTrue(names.size() == 1); MBeanMap result = new MBeanMap(server, names.iterator().next()); @SuppressWarnings("unchecked") Map<String, String> properties = (Map<String, String>) result.get("system_properties"); // System.err.println(properties); assertTrue(properties.containsKey("java.vm.version")); String json = mapper.writeValueAsString(result); // System.err.println(json); assertNotNull(json); }
From source file:fr.xebia.springframework.jms.ManagedCachingConnectionFactory.java
public ObjectName getObjectName() throws MalformedObjectNameException { if (objectName == null) { objectName = ObjectName .getInstance("javax.jms:type=CachingConnectionFactory,name=" + ObjectName.quote(this.beanName)); }//w w w. j a v a 2 s. c om return objectName; }
From source file:com.adaptris.core.services.jmx.JmxOperationInvoker.java
public Object invoke(String serviceUrl, String objectName, String username, String password, String methodName, Object[] params, String[] signatures) throws Exception { Map<String, String[]> env = new HashMap<>(); if ((!StringUtils.isEmpty(username)) && (!StringUtils.isEmpty(password))) { String[] credentials = { username, Password.decode(password) }; env.put(JMXConnector.CREDENTIALS, credentials); }// www.j a v a 2s. com JMXServiceURL jmxServiceUrl = new JMXServiceURL(serviceUrl); JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxServiceUrl, env); ObjectName objectNameInst = ObjectName.getInstance(objectName); MBeanServerConnection mbeanConn = jmxConnector.getMBeanServerConnection(); try { return mbeanConn.invoke(objectNameInst, methodName, params, signatures); } finally { jmxConnector.close(); } }
From source file:com.chiralBehaviors.groo.configuration.GrooConfiguration.java
public Groo construct() throws MalformedObjectNameException, NullPointerException, IOException { Groo groo = new Groo(description); for (NetworkBuilderConfiguration config : networkBuilders) { groo.addNetworkBuilder(ObjectName.getInstance(config.networkPattern), null, config.parentProperties); }/* w w w .java 2 s . c o m*/ return groo; }
From source file:fr.xebia.springframework.jdbc.ManagedBasicDataSource.java
public void setObjectName(String objectName) throws MalformedObjectNameException { this.objectName = ObjectName.getInstance(objectName); }
From source file:org.trpr.platform.core.impl.management.jmx.BeanInstanceMetadataNamingStrategy.java
/** * Overriden superclass method. If the specified managedBean is of type {@link InstanceAwareMBean}, * calls {@link InstanceAwareMBean#getMBeanNameSuffix()} to determine if a bean instance specific name suffix is to be included. * Appends the suffix if one is returned or else continues with the default behavior of {@link MetadataNamingStrategy#getObjectName(Object, String)} * @see org.springframework.jmx.export.naming.MetadataNamingStrategy#getObjectName(java.lang.Object, java.lang.String) *///from w w w.ja v a 2s . com public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException { if (managedBean instanceof InstanceAwareMBean) { String nameSuffix = ((InstanceAwareMBean) managedBean).getMBeanNameSuffix(managedBean, beanKey); if (nameSuffix != null) { return ObjectName.getInstance(super.getObjectName(managedBean, beanKey).toString() + nameSuffix); } } return super.getObjectName(managedBean, beanKey); }
From source file:fr.xebia.springframework.jmx.ServletContextAwareObjectNamingStrategy.java
/** * <p>/*from ww w.ja va2 s . c o m*/ * Compose <code>ObjectName</code> with underlying <code>objectNamingStrategy</code>'s * result and the following parameters: "<code>application=${servletcontextName},bean=${beanKey}</code>". * </p> */ public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException { ObjectName objectName = this.objectNamingStrategy.getObjectName(managedBean, beanKey); String canonicalName = objectName.getCanonicalName(); canonicalName += ",application=" + ObjectName.quote(this.servletContextName) + ",bean=" + ObjectName.quote(beanKey); ObjectName result = ObjectName.getInstance(canonicalName); return result; }