private int getHttpsPort() {
    try {
      MBeanServer mBeanServer = MBeanServerFactory.findMBeanServer(null).get(0);
      QueryExp query = Query.eq(Query.attr("Scheme"), Query.value("https"));
      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 {
              int portNum = Integer.parseInt(port);
              return portNum;
            } catch (NumberFormatException e) {
              logger.error("Error parsing https port:" + port);
              return -1;
            }
          }
        }
      }
    } catch (Throwable t) {
      logger.error("Error getting https port:", t);
    }

    return -1;
  }
Esempio n. 2
0
  public void reset(boolean includeProcessors) throws Exception {
    reset();

    // and now reset all processors for this route
    if (includeProcessors) {
      MBeanServer server =
          getContext().getManagementStrategy().getManagementAgent().getMBeanServer();
      if (server != null) {
        // get all the processor mbeans and sort them accordingly to their index
        String prefix =
            getContext().getManagementStrategy().getManagementAgent().getIncludeHostName()
                ? "*/"
                : "";
        ObjectName query =
            ObjectName.getInstance(
                "org.apache.camel:context="
                    + prefix
                    + getContext().getManagementName()
                    + ",type=processors,*");
        QueryExp queryExp =
            Query.match(new AttributeValueExp("RouteId"), new StringValueExp(getRouteId()));
        Set<ObjectName> names = server.queryNames(query, queryExp);
        for (ObjectName name : names) {
          server.invoke(name, "reset", null, null);
        }
      }
    }
  }