List of usage examples for javax.management Query and
public static QueryExp and(QueryExp q1, QueryExp q2)
From source file:org.alfresco.solr.SolrInformationServer.java
private String getHttpPort(String defaultPort) { try {/* w ww . j a v a 2 s .c om*/ MBeanServer mBeanServer = MBeanServerFactory.findMBeanServer(null).get(0); QueryExp query = Query.and(Query.eq(Query.attr("scheme"), Query.value("http")), Query.eq(Query.attr("protocol"), Query.value("HTTP/1.1"))); Set<ObjectName> objectNames = mBeanServer.queryNames(null, query); if (objectNames != null && objectNames.size() > 0) { for (ObjectName objectName : objectNames) { String name = objectName.toString(); if (name.indexOf("port=") > -1) { String[] parts = name.split("port="); String port = parts[1]; try { Integer.parseInt(port); return port; } catch (NumberFormatException e) { log.error("Error parsing http port:" + port); return defaultPort; } } } } } catch (Throwable t) { log.error("Error getting https port:", t); } return defaultPort; }
From source file:org.apache.geode.internal.process.MBeanProcessController.java
/** * Builds the QueryExp used to identify the target MBean. * //from ww w.java 2s .co m * @param pidAttribute the name of the MBean attribute with the process id to compare against * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return the main QueryExp for matching the target MBean */ private QueryExp buildQueryExp(final String pidAttribute, final String[] attributes, final Object[] values) { QueryExp optionalAttributes = buildOptionalQueryExp(attributes, values); QueryExp constraint; if (optionalAttributes != null) { constraint = Query.and(optionalAttributes, Query.eq(Query.attr(pidAttribute), Query.value(pid))); } else { constraint = Query.eq(Query.attr(pidAttribute), Query.value(pid)); } return constraint; }
From source file:org.apache.geode.internal.process.MBeanProcessController.java
/** * Builds an optional QueryExp to aid in matching the correct MBean using additional attributes * with the specified values. Returns null if no attributes and values were specified during * construction./* w w w . j a v a 2 s .c o m*/ * * @param attributes the names of additional MBean attributes to compare with expected values * @param values the expected values of the specified MBean attributes * * @return optional QueryExp to aid in matching the correct MBean */ private QueryExp buildOptionalQueryExp(final String[] attributes, final Object[] values) { QueryExp queryExp = null; for (int i = 0; i < attributes.length; i++) { if (values[i] instanceof Boolean) { if (queryExp == null) { queryExp = Query.eq(Query.attr(attributes[i]), Query.value((Boolean) values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((Boolean) values[i]))); } } else if (values[i] instanceof Number) { if (queryExp == null) { queryExp = Query.eq(Query.attr(attributes[i]), Query.value((Number) values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((Number) values[i]))); } } else if (values[i] instanceof String) { if (queryExp == null) { queryExp = Query.eq(Query.attr(attributes[i]), Query.value((String) values[i])); } else { queryExp = Query.and(queryExp, Query.eq(Query.attr(attributes[i]), Query.value((String) values[i]))); } } } return queryExp; }
From source file:org.apache.geode.management.internal.security.MBeanServerWrapper.java
@Override public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) { // We need to filter out the AccessControlMXBean so that the clients wouldn't see it if (query != null) return mbs.queryMBeans(name, Query.and(query, notAccessControlMBean)); else//w w w .j av a 2 s . c om return mbs.queryMBeans(name, notAccessControlMBean); }
From source file:org.apache.geode.management.internal.security.MBeanServerWrapper.java
@Override public Set<ObjectName> queryNames(ObjectName name, QueryExp query) { if (query != null) return mbs.queryNames(name, Query.and(query, notAccessControlMBean)); else/*from w ww . j av a 2 s . c o m*/ return mbs.queryNames(name, notAccessControlMBean); }