Esempio n. 1
0
 public Map<String, Properties> findComponents() throws Exception {
   Map<String, Properties> answer = context.findComponents();
   for (Map.Entry<String, Properties> entry : answer.entrySet()) {
     if (entry.getValue() != null) {
       // remove component as its not serializable over JMX
       entry.getValue().remove("component");
       // .. and components which just list all the components in the JAR/bundle and that is
       // verbose and not needed
       entry.getValue().remove("components");
     }
   }
   return answer;
 }
Esempio n. 2
0
  @Override
  public TabularData listComponents() throws Exception {
    try {
      // find all components
      Map<String, Properties> components = context.findComponents();

      TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listComponentsTabularType());

      // gather component detail for each component
      for (Map.Entry<String, Properties> entry : components.entrySet()) {
        String name = entry.getKey();
        String title = null;
        String syntax = null;
        String description = null;
        String label = null;
        String deprecated = null;
        String status = context.hasComponent(name) != null ? "in use" : "on classpath";
        String type = (String) entry.getValue().get("class");
        String groupId = null;
        String artifactId = null;
        String version = null;

        // a component may have been given a different name, so resolve its default name by its java
        // type
        // as we can find the component json information from the default component name
        String defaultName = context.resolveComponentDefaultName(type);
        String target = defaultName != null ? defaultName : name;

        // load component json data, and parse it to gather the component meta-data
        String json = context.getComponentParameterJsonSchema(target);
        List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema("component", json, false);
        for (Map<String, String> row : rows) {
          if (row.containsKey("title")) {
            title = row.get("title");
          } else if (row.containsKey("syntax")) {
            syntax = row.get("syntax");
          } else if (row.containsKey("description")) {
            description = row.get("description");
          } else if (row.containsKey("label")) {
            label = row.get("label");
          } else if (row.containsKey("deprecated")) {
            deprecated = row.get("deprecated");
          } else if (row.containsKey("javaType")) {
            type = row.get("javaType");
          } else if (row.containsKey("groupId")) {
            groupId = row.get("groupId");
          } else if (row.containsKey("artifactId")) {
            artifactId = row.get("artifactId");
          } else if (row.containsKey("version")) {
            version = row.get("version");
          }
        }

        CompositeType ct = CamelOpenMBeanTypes.listComponentsCompositeType();
        CompositeData data =
            new CompositeDataSupport(
                ct,
                new String[] {
                  "name",
                  "title",
                  "syntax",
                  "description",
                  "label",
                  "deprecated",
                  "status",
                  "type",
                  "groupId",
                  "artifactId",
                  "version"
                },
                new Object[] {
                  name,
                  title,
                  syntax,
                  description,
                  label,
                  deprecated,
                  status,
                  type,
                  groupId,
                  artifactId,
                  version
                });
        answer.put(data);
      }
      return answer;
    } catch (Exception e) {
      throw ObjectHelper.wrapRuntimeCamelException(e);
    }
  }