Java Code Examples for javax.management.Query#anySubString()

The following examples show how to use javax.management.Query#anySubString() . 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: ApiRestletApplication.java    From geowave with Apache License 2.0 5 votes vote down vote up
private static String getHTTPEndPoint() throws Exception {
  final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  final QueryExp subQuery1 = Query.match(Query.attr("protocol"), Query.value("HTTP/1.1"));
  final QueryExp subQuery2 = Query.anySubString(Query.attr("protocol"), Query.value("Http11"));
  final QueryExp query = Query.or(subQuery1, subQuery2);
  final Set<ObjectName> objs = mbs.queryNames(new ObjectName("*:type=Connector,*"), query);
  // HP Fortify "DNS Lookups" false positive
  // The DNS lookups referenced here are not used for Security purposes
  final String hostname = InetAddress.getLocalHost().getHostName();
  // HP Fortify "DNS Lookups" false positive
  // The DNS lookups referenced here are not used for Security purposes
  final InetAddress[] addresses = InetAddress.getAllByName(hostname);
  for (final Iterator<ObjectName> i = objs.iterator(); i.hasNext();) {
    final ObjectName obj = i.next();
    // final String scheme = mbs.getAttribute(
    // obj,
    // "scheme").toString();
    final String port = obj.getKeyProperty("port");
    // HP Fortify "DNS Lookups" false positive
    // The DNS lookups referenced here are not used for Security
    // purposes
    for (final InetAddress addr : addresses) {
      if (addr.isAnyLocalAddress() || addr.isLoopbackAddress() || addr.isMulticastAddress()) {
        continue;
      }
      final String host = addr.getHostAddress();
      // just return the first one
      return host + ":" + port;
    }
    return hostname + ":" + port;
  }
  return "localhost:8080";
}
 
Example 2
Source File: QuerySubstringTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 3
Source File: QuerySubstringTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 4
Source File: QuerySubstringTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 5
Source File: QuerySubstringTest.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 6
Source File: QuerySubstringTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 7
Source File: QuerySubstringTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 8
Source File: QuerySubstringTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 9
Source File: QuerySubstringTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 10
Source File: QuerySubstringTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 11
Source File: QuerySubstringTest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 12
Source File: QuerySubstringTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 13
Source File: QuerySubstringTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}
 
Example 14
Source File: QuerySubstringTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static int query(MBeanServer mbs,
                         int type,
                         String substring,
                         String[][] data) throws Exception {

    int error = 0;

    String querySubString = null;
    switch (type) {
        case 1:
            querySubString = "InitialSubString";
            break;
        case 2:
            querySubString = "AnySubString";
            break;
        case 3:
            querySubString = "FinalSubString";
            break;
    }

    System.out.println("\n" + querySubString + " = " + substring + "\n");

    for (int i = 0; i < data.length; i++) {
        ObjectName on = new ObjectName("test:type=Simple,query=" +
                                       querySubString + ",name=" + i);
        Simple s = new Simple(data[i][0]);
        mbs.registerMBean(s, on);
        QueryExp q = null;
        switch (type) {
            case 1:
                q = Query.initialSubString(Query.attr("String"),
                                           Query.value(substring));
                break;
            case 2:
                q = Query.anySubString(Query.attr("String"),
                                       Query.value(substring));
                break;
            case 3:
                q = Query.finalSubString(Query.attr("String"),
                                         Query.value(substring));
                break;
        }
        q.setMBeanServer(mbs);
        boolean r = q.apply(on);
        System.out.print("Attribute Value = " +
            mbs.getAttribute(on, "String"));
        if (r && "OK".equals(data[i][type])) {
            System.out.println(" OK");
        } else if (!r && "KO".equals(data[i][type])) {
            System.out.println(" KO");
        } else {
            System.out.println(" Error");
            error++;
        }
    }

    return error;
}