Search in sources :

Example 46 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project camel by apache.

the class ManagedCamelContext method listComponents.

@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 secret = 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("secret")) {
                    secret = row.get("secret");
                } 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", "secret", "status", "type", "groupId", "artifactId", "version" }, new Object[] { name, title, syntax, description, label, deprecated, secret, status, type, groupId, artifactId, version });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Properties(java.util.Properties) IOException(java.io.IOException) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) Map(java.util.Map) CompositeType(javax.management.openmbean.CompositeType)

Example 47 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project camel by apache.

the class ManagedChoice method choiceStatistics.

@Override
public TabularData choiceStatistics() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.choiceTabularType());
        List<WhenDefinition> whens = getDefinition().getWhenClauses();
        List<FilterProcessor> filters = processor.getFilters();
        for (int i = 0; i < filters.size(); i++) {
            WhenDefinition when = whens.get(i);
            FilterProcessor filter = filters.get(i);
            CompositeType ct = CamelOpenMBeanTypes.choiceCompositeType();
            String predicate = when.getExpression().getExpression();
            String language = when.getExpression().getLanguage();
            Long matches = filter.getFilteredCount();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "predicate", "language", "matches" }, new Object[] { predicate, language, matches });
            answer.put(data);
        }
        if (getDefinition().getOtherwise() != null) {
            CompositeType ct = CamelOpenMBeanTypes.choiceCompositeType();
            String predicate = "otherwise";
            String language = "";
            Long matches = processor.getNotFilteredCount();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "predicate", "language", "matches" }, new Object[] { predicate, language, matches });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : FilterProcessor(org.apache.camel.processor.FilterProcessor) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) TabularData(javax.management.openmbean.TabularData) TabularDataSupport(javax.management.openmbean.TabularDataSupport) WhenDefinition(org.apache.camel.model.WhenDefinition) CompositeType(javax.management.openmbean.CompositeType)

Example 48 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project camel by apache.

the class ManagedComponent method explain.

public TabularData explain(boolean allOptions) {
    try {
        // 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 = component.getCamelContext().resolveComponentDefaultName(component.getClass().getName());
        String target = defaultName != null ? defaultName : name;
        String json = component.getCamelContext().explainComponentJson(target, allOptions);
        List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema("componentProperties", json, true);
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.explainComponentTabularType());
        for (Map<String, String> row : rows) {
            String name = row.get("name");
            String kind = row.get("kind");
            String group = row.get("group") != null ? row.get("group") : "";
            String label = row.get("label") != null ? row.get("label") : "";
            String type = row.get("type");
            String javaType = row.get("javaType");
            String deprecated = row.get("deprecated") != null ? row.get("deprecated") : "";
            String secret = row.get("secret") != null ? row.get("secret") : "";
            String value = row.get("value") != null ? row.get("value") : "";
            String defaultValue = row.get("defaultValue") != null ? row.get("defaultValue") : "";
            String description = row.get("description") != null ? row.get("description") : "";
            CompositeType ct = CamelOpenMBeanTypes.explainComponentCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "option", "kind", "group", "label", "type", "java type", "deprecated", "secret", "value", "default value", "description" }, new Object[] { name, kind, group, label, type, javaType, deprecated, secret, value, defaultValue, description });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Map(java.util.Map) IOException(java.io.IOException) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 49 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project camel by apache.

the class ManagedDataFormat method explain.

@Override
public TabularData explain(boolean allOptions) {
    String dataFormatName = getName();
    if (dataFormatName != null) {
        try {
            TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.explainDataFormatTabularType());
            String json = camelContext.explainDataFormatJson(dataFormatName, dataFormat, allOptions);
            List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema("properties", json, true);
            for (Map<String, String> row : rows) {
                String name = row.get("name");
                String kind = row.get("kind");
                String label = row.get("label") != null ? row.get("label") : "";
                String type = row.get("type");
                String javaType = row.get("javaType");
                String deprecated = row.get("deprecated") != null ? row.get("deprecated") : "";
                String secret = row.get("secret") != null ? row.get("secret") : "";
                String value = row.get("value") != null ? row.get("value") : "";
                String defaultValue = row.get("defaultValue") != null ? row.get("defaultValue") : "";
                String description = row.get("description") != null ? row.get("description") : "";
                CompositeType ct = CamelOpenMBeanTypes.explainDataFormatsCompositeType();
                CompositeData data = new CompositeDataSupport(ct, new String[] { "option", "kind", "label", "type", "java type", "deprecated", "secret", "value", "default value", "description" }, new Object[] { name, kind, label, type, javaType, deprecated, secret, value, defaultValue, description });
                answer.put(data);
            }
            return answer;
        } catch (Exception e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
    } else {
        return null;
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Map(java.util.Map) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Example 50 with TabularDataSupport

use of javax.management.openmbean.TabularDataSupport in project camel by apache.

the class ManagedEndpoint method explain.

@Override
public TabularData explain(boolean allOptions) {
    try {
        String json = endpoint.getCamelContext().explainEndpointJson(getEndpointUri(), allOptions);
        List<Map<String, String>> rows = JsonSchemaHelper.parseJsonSchema("properties", json, true);
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.explainEndpointTabularType());
        for (Map<String, String> row : rows) {
            String name = row.get("name");
            String kind = row.get("kind");
            String group = row.get("group") != null ? row.get("group") : "";
            String label = row.get("label") != null ? row.get("label") : "";
            String type = row.get("type");
            String javaType = row.get("javaType");
            String deprecated = row.get("deprecated") != null ? row.get("deprecated") : "";
            String secret = row.get("secret") != null ? row.get("secret") : "";
            String value = row.get("value") != null ? row.get("value") : "";
            String defaultValue = row.get("defaultValue") != null ? row.get("defaultValue") : "";
            String description = row.get("description") != null ? row.get("description") : "";
            CompositeType ct = CamelOpenMBeanTypes.explainEndpointsCompositeType();
            CompositeData data = new CompositeDataSupport(ct, new String[] { "option", "kind", "group", "label", "type", "java type", "deprecated", "secret", "value", "default value", "description" }, new Object[] { name, kind, group, label, type, javaType, deprecated, secret, value, defaultValue, description });
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
Also used : TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) Map(java.util.Map) TabularData(javax.management.openmbean.TabularData) CompositeType(javax.management.openmbean.CompositeType)

Aggregations

TabularDataSupport (javax.management.openmbean.TabularDataSupport)103 TabularData (javax.management.openmbean.TabularData)67 CompositeDataSupport (javax.management.openmbean.CompositeDataSupport)60 CompositeData (javax.management.openmbean.CompositeData)51 CompositeType (javax.management.openmbean.CompositeType)50 TabularType (javax.management.openmbean.TabularType)36 Map (java.util.Map)27 OpenDataException (javax.management.openmbean.OpenDataException)24 HashMap (java.util.HashMap)11 Bundle (org.osgi.framework.Bundle)10 IOException (java.io.IOException)7 ObjectName (javax.management.ObjectName)7 OpenType (javax.management.openmbean.OpenType)7 EndpointUtilizationStatistics (org.apache.camel.spi.EndpointUtilizationStatistics)7 Test (org.junit.Test)6 ConcurrentMap (java.util.concurrent.ConcurrentMap)5 MBeanException (javax.management.MBeanException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4 Dictionary (java.util.Dictionary)4