List of usage examples for javax.management ObjectName quote
public static String quote(String s)
Returns a quoted form of the given String, suitable for inclusion in an ObjectName.
From source file:com.mtgi.jmx.export.naming.AppendNamingStrategy.java
/** reluctantly quote the given input string (quoting only applied if the string contains control characters) */ public static final String quote(String input) { if (QUOTE_NEEDED.matcher(input).find()) return ObjectName.quote(input); return input; }
From source file:org.wso2.andes.kernel.registry.StorageQueueRegistry.java
private Hashtable<String, String> getMbeanObjectnameProp(String storageQueue) { int index = storageQueue.indexOf(':'); Hashtable<String, String> tab = new Hashtable<>(); tab.put("type", TOPIC_INFO_MBEAN_TYPE); tab.put("name", ObjectName.quote(storageQueue.substring(index + 1))); return tab;//from www. java 2 s . c om }
From source file:org.apache.qpid.server.jmx.mbeans.QueueMBean.java
public String getObjectInstanceName() { return ObjectName.quote(getName()); }
From source file:com.redhat.poc.jdg.bankofchina.function.TestCase411RemoteMultiThreadsCustomMarshal.java
public static void registerProtofile(String jmxHost, int jmxPort, String cacheContainerName) throws Exception { JMXConnector jmxConnector = JMXConnectorFactory .connect(new JMXServiceURL("service:jmx:remoting-jmx://" + jmxHost + ":" + jmxPort)); MBeanServerConnection jmxConnection = jmxConnector.getMBeanServerConnection(); ObjectName protobufMetadataManagerObjName = new ObjectName("jboss.infinispan:type=RemoteQuery,name=" + ObjectName.quote(cacheContainerName) + ",component=ProtobufMetadataManager"); // initialize client-side serialization context via JMX byte[] descriptor = readClasspathResource("/model/userbaseinfo.protobin"); jmxConnection.invoke(protobufMetadataManagerObjName, "registerProtofile", new Object[] { descriptor }, new String[] { byte[].class.getName() }); jmxConnector.close();//ww w. java 2 s . c om }
From source file:org.rhq.plugins.jslee.ServiceSbbUsageParameterSetComponent.java
@Override public Configuration loadResourceConfiguration() throws Exception { try {// w ww . j a v a 2 s. c om Configuration config = new Configuration(); MBeanServerConnection connection = this.mbeanUtils.getConnection(); this.mbeanUtils.login(); // As an example, if a particular service has the name FooService, vendor FooCompany, and version 1.0, // then the Object Name of a ServiceUsageMBean for that service would be: // javax.slee.management.usage:type=ServiceUsage,serviceName="FooService", serviceVendor="FooCompany",serviceVersion="1.0" ObjectName serviceUsageON = new ObjectName(ServiceUsageMBean.BASE_OBJECT_NAME + ',' + ServiceUsageMBean.SERVICE_NAME_KEY + '=' + ObjectName.quote(serviceId.getName()) + ',' + ServiceUsageMBean.SERVICE_VENDOR_KEY + '=' + ObjectName.quote(serviceId.getVendor()) + ',' + ServiceUsageMBean.SERVICE_VERSION_KEY + '=' + ObjectName.quote(serviceId.getVersion())); ServiceUsageMBean serviceUsageMBean = (ServiceUsageMBean) MBeanServerInvocationHandler.newProxyInstance( connection, serviceUsageON, javax.slee.management.ServiceUsageMBean.class, false); PropertyList columnList = new PropertyList("usageParameter"); ObjectName sbbUsageON = null; if (usageParameterSetName != null && !usageParameterSetName.equals("<default>")) { sbbUsageON = serviceUsageMBean.getSbbUsageMBean(sbbId, usageParameterSetName); } else { sbbUsageON = serviceUsageMBean.getSbbUsageMBean(sbbId); } MBeanInfo usageInfo = connection.getMBeanInfo(sbbUsageON); for (MBeanOperationInfo operation : usageInfo.getOperations()) { String opName = operation.getName(); if (opName.startsWith("get")) { PropertyMap col = new PropertyMap("usageParameterDefinition"); col.put(new PropertySimple("usageParameterName", opName.replaceFirst("get", ""))); boolean isSampleType = operation.getReturnType().equals("javax.slee.usage.SampleStatistics"); col.put(new PropertySimple("usageParameterType", isSampleType ? "Sample" : "Counter")); Object value = connection.invoke(sbbUsageON, opName, new Object[] { false }, new String[] { "boolean" }); col.put(new PropertySimple("usageParameterValue", value)); columnList.add(col); } } config.put(columnList); return config; } finally { try { this.mbeanUtils.logout(); } catch (LoginException e) { if (log.isDebugEnabled()) { log.debug("Failed to logout from secured JMX", e); } } } }
From source file:fr.xebia.management.statistics.ProfileAspect.java
public ObjectName getObjectName() throws MalformedObjectNameException { if (objectName == null) { String objectNameAsString = jmxDomain + ":type=ProfileAspect"; if (StringUtils.hasLength(name)) { objectNameAsString += ",name=" + ObjectName.quote(name); }/*from ww w . j a va 2 s . com*/ objectName = new ObjectName(objectNameAsString); } return objectName; }
From source file:org.wso2.andes.test.utils.JMXTestUtils.java
/** * Retrive the ObjectName for a Virtualhost. * * This is then used to create a proxy to the ManagedBroker MBean. * * @param virtualHostName the VirtualHost to retrieve * @return the ObjectName for the VirtualHost *///from ww w. j a va 2 s . c om @SuppressWarnings("static-access") public ObjectName getVirtualHostManagerObjectName(String vhostName) { // Get the name of the test manager String query = "org.wso2.andes:type=VirtualHost.VirtualHostManager,VirtualHost=" + ObjectName.quote(vhostName) + ",*"; Set<ObjectName> objectNames = queryObjects(query); _test.assertNotNull("Null ObjectName Set returned", objectNames); _test.assertEquals("Incorrect number test vhosts returned", 1, objectNames.size()); // We have verified we have only one value in objectNames so return it ObjectName objectName = objectNames.iterator().next(); _test.getLogger().info("Loading: " + objectName); return objectName; }
From source file:org.wso2.andes.test.utils.JMXTestUtils.java
/** * Retrive the ObjectName for the given Queue on a Virtualhost. * * This is then used to create a proxy to the ManagedQueue MBean. * * @param virtualHostName the VirtualHost the Queue is on * @param queue The Queue to retireve//from ww w .j a v a 2 s . co m * @return the ObjectName for the given queue on the VirtualHost */ @SuppressWarnings("static-access") public ObjectName getQueueObjectName(String virtualHostName, String queue) { // Get the name of the test manager String query = "org.wso2.andes:type=VirtualHost.Queue,VirtualHost=" + ObjectName.quote(virtualHostName) + ",name=" + ObjectName.quote(queue) + ",*"; Set<ObjectName> objectNames = queryObjects(query); _test.assertNotNull("Null ObjectName Set returned", objectNames); _test.assertEquals("Incorrect number of queues with name '" + queue + "' returned", 1, objectNames.size()); // We have verified we have only one value in objectNames so return it ObjectName objectName = objectNames.iterator().next(); _test.getLogger().info("Loading: " + objectName); return objectName; }
From source file:org.apache.qpid.test.utils.JMXTestUtils.java
/** * Retrieve the ObjectName for a Virtualhost. * * This is then used to create a proxy to the ManagedBroker MBean. * * @param virtualHostName the VirtualHost to retrieve * @return the ObjectName for the VirtualHost *///from w w w . jav a 2s. c o m @SuppressWarnings("static-access") public ObjectName getVirtualHostManagerObjectName(String vhostName) { // Get the name of the test manager String query = "org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=" + ObjectName.quote(vhostName) + ",*"; Set<ObjectName> objectNames = queryObjects(query); _test.assertNotNull("Null ObjectName Set returned", objectNames); _test.assertEquals("Incorrect number test vhosts returned", 1, objectNames.size()); // We have verified we have only one value in objectNames so return it ObjectName objectName = objectNames.iterator().next(); _test.getLogger().info("Loading: " + objectName); return objectName; }
From source file:org.rhq.plugins.jslee.ServiceSbbUsageParameterSetComponent.java
@Override public void updateResourceConfiguration(ConfigurationUpdateReport configurationUpdateReport) { try {/*from w w w . j av a 2 s. c o m*/ MBeanServerConnection connection = this.mbeanUtils.getConnection(); this.mbeanUtils.login(); // As an example, if a particular service has the name FooService, vendor FooCompany, and version 1.0, // then the Object Name of a ServiceUsageMBean for that service would be: // javax.slee.management.usage:type=ServiceUsage,serviceName="FooService", serviceVendor="FooCompany",serviceVersion="1.0" ObjectName serviceUsageON = new ObjectName(ServiceUsageMBean.BASE_OBJECT_NAME + ',' + ServiceUsageMBean.SERVICE_NAME_KEY + '=' + ObjectName.quote(serviceId.getName()) + ',' + ServiceUsageMBean.SERVICE_VENDOR_KEY + '=' + ObjectName.quote(serviceId.getVendor()) + ',' + ServiceUsageMBean.SERVICE_VERSION_KEY + '=' + ObjectName.quote(serviceId.getVersion())); ServiceUsageMBean serviceUsageMBean = (ServiceUsageMBean) MBeanServerInvocationHandler.newProxyInstance( connection, serviceUsageON, javax.slee.management.ServiceUsageMBean.class, false); PropertyList columnList = configurationUpdateReport.getConfiguration().getList("usageParameter"); ObjectName sbbUsageON = serviceUsageMBean.getSbbUsageMBean(sbbId); for (Property p : columnList.getList()) { PropertyMap pMap = (PropertyMap) p; String usageParamName = ((PropertySimple) pMap.get("usageParameterName")).getStringValue(); Object curValue = pMap.get("usageParameterValue"); Object newValue = connection.invoke(sbbUsageON, "get" + usageParamName, new Object[] { false }, new String[] { "boolean" }); if (newValue != null && !newValue.equals(curValue)) { if (log.isDebugEnabled()) { log.debug("Changing Usage Parameter '" + usageParamName + "' from value [" + curValue + "] to [" + newValue + "]."); } } } configurationUpdateReport.setStatus(ConfigurationUpdateStatus.SUCCESS); } catch (Exception e) { log.error("Failed to update Resource Configuration.", e); configurationUpdateReport.setErrorMessageFromThrowable(e); configurationUpdateReport.setStatus(ConfigurationUpdateStatus.FAILURE); } finally { try { this.mbeanUtils.logout(); } catch (LoginException e) { if (log.isDebugEnabled()) { log.debug("Failed to logout from secured JMX", e); } } } }