Java Code Examples for javax.management.ObjectName#quote()
The following examples show how to use
javax.management.ObjectName#quote() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardWrapper.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override protected String getObjectNameKeyProperties() { StringBuilder keyProperties = new StringBuilder("j2eeType=Servlet"); keyProperties.append(getWebModuleKeyProperties()); keyProperties.append(",name="); String name = getName(); if (Util.objectNameValueNeedsQuote(name)) { name = ObjectName.quote(name); } keyProperties.append(name); keyProperties.append(getJ2EEKeyProperties()); return keyProperties.toString(); }
Example 2
Source File: ObjectNameHelper.java From ph-commons with Apache License 2.0 | 6 votes |
/** * Create a clean property value applicable for an {@link ObjectName} property * value by replacing the special chars ":" and "," with "." and "//" with * "__". If the input value contains a blank, the quotes value is returned. * * @param sPropertyValue * The original property value. May not be <code>null</code>. * @return The modified property value applicable for {@link ObjectName}. * @see ObjectName#quote(String) */ @Nonnull public static String getCleanPropertyValue (@Nonnull final String sPropertyValue) { // If a blank is contained, simply quote it if (sPropertyValue.indexOf (' ') != -1) return ObjectName.quote (sPropertyValue); // ":" is prohibited // "," is the property separator // "//" is according to the specs reserved for future use String ret = sPropertyValue; ret = StringHelper.replaceAll (ret, ':', '.'); ret = StringHelper.replaceAll (ret, ',', '.'); ret = StringHelper.replaceAll (ret, "//", "__"); return ret; }
Example 3
Source File: AbstractManagedObject.java From ns4_gear_watchdog with Apache License 2.0 | 6 votes |
@Override public ObjectName getObjectName() { if (this.objectName == null) { try { Map<String, String> props = new LinkedHashMap<String, String>(); props.put("type", this.getType()); String name = this.name; if (name != null) { if (name.indexOf(58) >= 0) { name = ObjectName.quote(name); } props.put("name", name); } this.objectName = Jmx.getObjectName(JmxUtil.DOMAIN, props); } catch (MalformedObjectNameException var3) { throw new RuntimeException(var3); } } return this.objectName; }
Example 4
Source File: AbstractProtocol.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * The name will be prefix-address-port if address is non-null and * prefix-port if the address is null. The name will be appropriately quoted * so it can be used directly in an ObjectName. */ public String getName() { StringBuilder name = new StringBuilder(getNamePrefix()); name.append('-'); if (getAddress() != null) { name.append(getAddress().getHostAddress()); name.append('-'); } int port = getPort(); if (port == 0) { // Auto binding is in use. Check if port is known name.append("auto-"); name.append(getNameIndex()); port = getLocalPort(); if (port != -1) { name.append('-'); name.append(port); } } else { name.append(port); } return ObjectName.quote(name.toString()); }
Example 5
Source File: QueryMatchTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static int query(MBeanServer mbs, String pattern, String[][] data) throws Exception { int error = 0; System.out.println("\nAttribute Value Pattern = " + pattern + "\n"); for (int i = 0; i < data.length; i++) { ObjectName on = new ObjectName("domain:type=Simple,pattern=" + ObjectName.quote(pattern) + ",name=" + i); Simple s = new Simple(data[i][0]); mbs.registerMBean(s, on); QueryExp q = Query.match(Query.attr("StringNumber"), Query.value(pattern)); q.setMBeanServer(mbs); boolean r = q.apply(on); System.out.print("Attribute Value = " + mbs.getAttribute(on, "StringNumber")); if (r && "OK".equals(data[i][1])) { System.out.println(" OK"); } else if (!r && "KO".equals(data[i][1])) { System.out.println(" KO"); } else { System.out.println(" Error"); error++; } } return error; }
Example 6
Source File: SimpleJMXStormMetricProcessor.java From storm-metrics-reporter with Apache License 2.0 | 5 votes |
String mBeanName(Metric metric, IMetricsConsumer.TaskInfo taskInfo) { return "storm" + ":topology=" + topologyName + ",component=" + metric.getComponent() + ",operation=" + ObjectName.quote(metric.getOperation()) + ",host-port-task=" + String.format("%s-%s-%s", taskInfo.srcWorkerHost ,taskInfo.srcWorkerPort ,taskInfo.srcTaskId); }
Example 7
Source File: TestRegistration.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private static String[] requestMBeanNames(String port, String type) { return new String[] { "Tomcat:type=RequestProcessor,worker=" + ObjectName.quote("http-" + type + "-" + ADDRESS + "-" + port) + ",name=HttpRequest1", }; }
Example 8
Source File: QueryMatchTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private static int query(MBeanServer mbs, String pattern, String[][] data) throws Exception { int error = 0; System.out.println("\nAttribute Value Pattern = " + pattern + "\n"); for (int i = 0; i < data.length; i++) { ObjectName on = new ObjectName("domain:type=Simple,pattern=" + ObjectName.quote(pattern) + ",name=" + i); Simple s = new Simple(data[i][0]); mbs.registerMBean(s, on); QueryExp q = Query.match(Query.attr("StringNumber"), Query.value(pattern)); q.setMBeanServer(mbs); boolean r = q.apply(on); System.out.print("Attribute Value = " + mbs.getAttribute(on, "StringNumber")); if (r && "OK".equals(data[i][1])) { System.out.println(" OK"); } else if (!r && "KO".equals(data[i][1])) { System.out.println(" KO"); } else { System.out.println(" Error"); error++; } } return error; }
Example 9
Source File: QueryMatchTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static int query(MBeanServer mbs, String pattern, String[][] data) throws Exception { int error = 0; System.out.println("\nAttribute Value Pattern = " + pattern + "\n"); for (int i = 0; i < data.length; i++) { ObjectName on = new ObjectName("domain:type=Simple,pattern=" + ObjectName.quote(pattern) + ",name=" + i); Simple s = new Simple(data[i][0]); mbs.registerMBean(s, on); QueryExp q = Query.match(Query.attr("StringNumber"), Query.value(pattern)); q.setMBeanServer(mbs); boolean r = q.apply(on); System.out.print("Attribute Value = " + mbs.getAttribute(on, "StringNumber")); if (r && "OK".equals(data[i][1])) { System.out.println(" OK"); } else if (!r && "KO".equals(data[i][1])) { System.out.println(" KO"); } else { System.out.println(" Error"); error++; } } return error; }
Example 10
Source File: ManagedEndpoint.java From cxf with Apache License 2.0 | 5 votes |
public ObjectName getObjectName() throws JMException { //Use default domain name of server StringBuilder buffer = new StringBuilder(ManagementConstants.DEFAULT_DOMAIN_NAME).append(':'); buffer.append(ManagementConstants.BUS_ID_PROP).append('=').append(bus.getId()).append(','); buffer.append(ManagementConstants.TYPE_PROP).append('=').append("Bus.Service.Endpoint,"); String serviceName = (String)endpoint.get(SERVICE_NAME); if (StringUtils.isEmpty(serviceName)) { serviceName = endpoint.getService().getName().toString(); } serviceName = ObjectName.quote(serviceName); buffer.append(ManagementConstants.SERVICE_NAME_PROP).append('=').append(serviceName).append(','); String endpointName = (String)endpoint.get(ENDPOINT_NAME); if (StringUtils.isEmpty(endpointName)) { endpointName = endpoint.getEndpointInfo().getName().getLocalPart(); } endpointName = ObjectName.quote(endpointName); buffer.append(ManagementConstants.PORT_NAME_PROP).append('=').append(endpointName).append(','); String instanceId = (String)endpoint.get(INSTANCE_ID); if (StringUtils.isEmpty(instanceId)) { instanceId = new StringBuilder().append(endpoint.hashCode()).toString(); } // Added the instance id to make the ObjectName unique buffer.append(ManagementConstants.INSTANCE_ID_PROP).append('=').append(instanceId); return new ObjectName(buffer.toString()); }
Example 11
Source File: QueryMatchTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static int query(MBeanServer mbs, String pattern, String[][] data) throws Exception { int error = 0; System.out.println("\nAttribute Value Pattern = " + pattern + "\n"); for (int i = 0; i < data.length; i++) { ObjectName on = new ObjectName("domain:type=Simple,pattern=" + ObjectName.quote(pattern) + ",name=" + i); Simple s = new Simple(data[i][0]); mbs.registerMBean(s, on); QueryExp q = Query.match(Query.attr("StringNumber"), Query.value(pattern)); q.setMBeanServer(mbs); boolean r = q.apply(on); System.out.print("Attribute Value = " + mbs.getAttribute(on, "StringNumber")); if (r && "OK".equals(data[i][1])) { System.out.println(" OK"); } else if (!r && "KO".equals(data[i][1])) { System.out.println(" KO"); } else { System.out.println(" Error"); error++; } } return error; }
Example 12
Source File: QueryMatchTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static int query(MBeanServer mbs, String pattern, String[][] data) throws Exception { int error = 0; System.out.println("\nAttribute Value Pattern = " + pattern + "\n"); for (int i = 0; i < data.length; i++) { ObjectName on = new ObjectName("domain:type=Simple,pattern=" + ObjectName.quote(pattern) + ",name=" + i); Simple s = new Simple(data[i][0]); mbs.registerMBean(s, on); QueryExp q = Query.match(Query.attr("StringNumber"), Query.value(pattern)); q.setMBeanServer(mbs); boolean r = q.apply(on); System.out.print("Attribute Value = " + mbs.getAttribute(on, "StringNumber")); if (r && "OK".equals(data[i][1])) { System.out.println(" OK"); } else if (!r && "KO".equals(data[i][1])) { System.out.println(" KO"); } else { System.out.println(" Error"); error++; } } return error; }
Example 13
Source File: TestRegistration.java From tomcatsrc with Apache License 2.0 | 5 votes |
private static String[] connectorMBeanNames(String port, String type) { return new String[] { "Tomcat:type=Connector,port=" + port + ",address=" + ObjectName.quote(ADDRESS), "Tomcat:type=GlobalRequestProcessor,name=" + ObjectName.quote("http-" + type + "-" + ADDRESS + "-" + port), "Tomcat:type=Mapper,port=" + port + ",address=" + ObjectName.quote(ADDRESS), "Tomcat:type=ProtocolHandler,port=" + port + ",address=" + ObjectName.quote(ADDRESS), "Tomcat:type=ThreadPool,name=" + ObjectName.quote("http-" + type + "-" + ADDRESS + "-" + port), }; }
Example 14
Source File: ApplicationFilterConfig.java From Tomcat8-Source-Read with MIT License | 5 votes |
private void registerJMX() { String parentName = context.getName(); if (!parentName.startsWith("/")) { parentName = "/" + parentName; } String hostName = context.getParent().getName(); hostName = (hostName == null) ? "DEFAULT" : hostName; // domain == engine name String domain = context.getParent().getParent().getName(); String webMod = "//" + hostName + parentName; String onameStr = null; String filterName = filterDef.getFilterName(); if (Util.objectNameValueNeedsQuote(filterName)) { filterName = ObjectName.quote(filterName); } if (context instanceof StandardContext) { StandardContext standardContext = (StandardContext) context; onameStr = domain + ":j2eeType=Filter,WebModule=" + webMod + ",name=" + filterName + ",J2EEApplication=" + standardContext.getJ2EEApplication() + ",J2EEServer=" + standardContext.getJ2EEServer(); } else { onameStr = domain + ":j2eeType=Filter,name=" + filterName + ",WebModule=" + webMod; } try { oname = new ObjectName(onameStr); Registry.getRegistry(null, null).registerComponent(this, oname, null); } catch (Exception ex) { log.warn(sm.getString("applicationFilterConfig.jmxRegisterFail", getFilterClass(), getFilterName()), ex); } }
Example 15
Source File: MBeanJMXAdapter.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public static String makeCompliantRegionPath(final String value) { if (containsSpecialChar(value)) { return ObjectName.quote(value); } return value; }
Example 16
Source File: MBeanJMXAdapter.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public static String makeCompliantRegionPath(final String value) { if (containsSpecialChar(value)) { return ObjectName.quote(value); } return value; }
Example 17
Source File: MBeanUtils.java From Tomcat8-Source-Read with MIT License | 3 votes |
/** * Create an <code>ObjectName</code> for this * <code>Role</code> object. * * @param domain Domain in which this name is to be created * @param role The Role to be named * @return a new object name * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, Role role) throws MalformedObjectNameException { ObjectName name = new ObjectName(domain + ":type=Role,rolename=" + ObjectName.quote(role.getRolename()) + ",database=" + role.getUserDatabase().getId()); return name; }
Example 18
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 3 votes |
/** * Create an <code>ObjectName</code> for this * <code>Role</code> object. * * @param domain Domain in which this name is to be created * @param role The Role to be named * * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, Role role) throws MalformedObjectNameException { ObjectName name = new ObjectName(domain + ":type=Role,rolename=" + ObjectName.quote(role.getRolename()) + ",database=" + role.getUserDatabase().getId()); return name; }
Example 19
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 3 votes |
/** * Create an <code>ObjectName</code> for this * <code>User</code> object. * * @param domain Domain in which this name is to be created * @param user The User to be named * * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, User user) throws MalformedObjectNameException { ObjectName name = new ObjectName(domain + ":type=User,username=" + ObjectName.quote(user.getUsername()) + ",database=" + user.getUserDatabase().getId()); return name; }
Example 20
Source File: MBeanUtils.java From tomcatsrc with Apache License 2.0 | 3 votes |
/** * Create an <code>ObjectName</code> for this * <code>Role</code> object. * * @param domain Domain in which this name is to be created * @param role The Role to be named * * @exception MalformedObjectNameException if a name cannot be created */ static ObjectName createObjectName(String domain, Role role) throws MalformedObjectNameException { ObjectName name = new ObjectName(domain + ":type=Role,rolename=" + ObjectName.quote(role.getRolename()) + ",database=" + role.getUserDatabase().getId()); return name; }