Package javax.management.openmbean

Examples of javax.management.openmbean.TabularDataSupport


    private TabularData createTabularData() throws Exception {
        TabularType tabularType = new TabularType(TabularData.class.getName(),
                tabularTypeDesc,
                compositeType,
                new String[]{itemNames[0]});
         return new TabularDataSupport(tabularType);
    }
View Full Code Here


            CompositeType bundleType = new CompositeType("Bundle", "OSGi Bundle",
                    new String[]{"ID", "Name", "Version", "Start Level", "State"},
                    new String[]{"ID of the Bundle", "Name of the Bundle", "Version of the Bundle", "Start Level of the Bundle", "Current State of the Bundle"},
                    new OpenType[]{SimpleType.LONG, SimpleType.STRING, SimpleType.STRING, SimpleType.INTEGER, SimpleType.STRING});
            TabularType tableType = new TabularType("BundlesMBeanImpl", "Tables of all BundlesMBeanImpl", bundleType, new String[]{"ID"});
            TabularData table = new TabularDataSupport(tableType);

            Bundle[] bundles = bundleContext.getBundles();

            for (int i = 0; i < bundles.length; i++) {
                try {
                    Bundle bundle = bundles[i];
                    BundleInfo info = bundleService.getInfo(bundle);
                    String bundleStateString = info.getState().toString();
                    CompositeData data = new CompositeDataSupport(bundleType,
                            new String[]{"ID", "Name", "Version", "Start Level", "State"},
                            new Object[]{info.getBundleId(), info.getSymbolicName(), info.getVersion(), info.getStartLevel(), bundleStateString});
                    table.put(data);
                } catch (Exception e) {
                    LOG.error(e.getMessage(), e);
                }
            }
            return table;
View Full Code Here

        try
        {
            //verify the DLE exchange exists, has the expected type, and a single binding for the DLQ
            ManagedExchange exchange = jmxUtils.getManagedExchange(QUEUE_WITH_DLQ_NAME + "_DLE");
            assertEquals("Wrong exchange type", "fanout", exchange.getExchangeType());
            TabularDataSupport bindings = (TabularDataSupport) exchange.bindings();
            assertEquals(1, bindings.size());
            for(Object o : bindings.values())
            {
                CompositeData binding = (CompositeData) o;

                String bindingKey = (String) binding.get(ManagedExchange.BINDING_KEY);
                String[] queueNames = (String[]) binding.get(ManagedExchange.QUEUE_NAMES);
View Full Code Here

        TabularType bindinglistDataType =
                new TabularType("Exchange Bindings", "List of exchange bindings for " + getName(),
                        HEADERS_BINDING_DATA_TYPE,
                        HEADERS_TABULAR_UNIQUE_INDEX_ARRAY);
       
        TabularDataSupport bindingList = new TabularDataSupport(bindinglistDataType);
        int count = 1;
        for (Binding binding : bindings)
        {

            String queueName = binding.getParent(Queue.class).getName();


            Map<String,Object> headerMappings = binding.getArguments();

            final List<String> mappingList = new ArrayList<String>();

            if(headerMappings != null)
            {
                for(Map.Entry<String,Object> entry : headerMappings.entrySet())
                {

                    mappingList.add(entry.getKey() + "=" + entry.getValue());
                }
            }


            Object[] bindingItemValues = {count++, queueName, mappingList.toArray(new String[0])};
            CompositeData bindingData = new CompositeDataSupport(HEADERS_BINDING_DATA_TYPE,
                                                                 HEADERS_COMPOSITE_ITEM_NAMES_ARRAY,
                                                                 bindingItemValues);
            bindingList.put(bindingData);
        }

        return bindingList;

    }
View Full Code Here

        TabularType bindinglistDataType =
                new TabularType("Exchange Bindings", "Exchange Bindings for " + getName(),
                                BINDING_DATA_TYPE,
                                TABULAR_UNIQUE_INDEX_ARRAY);
       
        TabularDataSupport bindingList = new TabularDataSupport(bindinglistDataType);

        Map<String, List<String>> bindingMap = new HashMap<String, List<String>>();

        for (Binding binding : bindings)
        {
            String key = FANOUT_EXCHANGE_TYPE.equals(_exchange.getExchangeType()) ? "*" : binding.getName();
            List<String> queueList = bindingMap.get(key);
            if(queueList == null)
            {
                queueList = new ArrayList<String>();
                bindingMap.put(key, queueList);
            }
            queueList.add(binding.getParent(Queue.class).getName());

        }

        for(Map.Entry<String, List<String>> entry : bindingMap.entrySet())
        {
            Object[] bindingItemValues = {entry.getKey(), entry.getValue().toArray(new String[0])};
            CompositeData bindingData = new CompositeDataSupport(BINDING_DATA_TYPE,
                                                                 COMPOSITE_ITEM_NAMES_ARRAY,
                                                                 bindingItemValues);
            bindingList.put(bindingData);
        }

        return bindingList;
    }
View Full Code Here

        final Attribute attr = (Attribute) result.get(0);
        return attr.getValue();
    }

    private TabularData logData(final Result er) throws OpenDataException {
        final TabularDataSupport result = new TabularDataSupport(LOG_TABLE_TYPE);
        int i = 1;
        for(final ResultLog.Entry e : er) {
            final Map<String, Object> data = new HashMap<String, Object>();
            data.put(INDEX_COLUMN, i++);
            data.put(LEVEL_COLUMN, e.getStatus().toString());
            data.put(MESSAGE_COLUMN, e.getMessage());

            result.put(new CompositeDataSupport(LOG_ROW_TYPE, data));
        }
        return result;
    }
View Full Code Here

    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 description = null;
                // the status can be:
                // - in use = used by Camel
                // - classpath = on the classpath
                // - release = available from the Apache Camel release
                // TODO: gather list of components in the Camel release
                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("description")) {
                        description = row.get("description");
                    } 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", "description", "status", "type", "groupId", "artifactId", "version"},
                        new Object[]{name, description, status, type, groupId, artifactId, version});
                answer.put(data);
            }
            return answer;
        } catch (Exception e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
View Full Code Here

    }

    @Override
    public TabularData listEndpoints() {
        try {
            TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listEndpointsTabularType());
            Collection<Endpoint> endpoints = endpointRegistry.values();
            for (Endpoint endpoint : endpoints) {
                CompositeType ct = CamelOpenMBeanTypes.listEndpointsCompositeType();
                String url = endpoint.getEndpointUri();

                CompositeData data = new CompositeDataSupport(ct, new String[]{"url"}, new Object[]{url});
                answer.put(data);
            }
            return answer;
        } catch (Exception e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
View Full Code Here

    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 option = row.get("name");
                String type = row.get("type");
                String javaType = row.get("javaType");
                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", "type", "java type", "value", "default value", "description"},
                        new Object[]{option, type, javaType, value, defaultValue, description});
                answer.put(data);
            }

            return answer;
        } catch (Exception e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
View Full Code Here

  public List<Job> getJobDetails(QuartzInstance quartzInstance, Scheduler scheduler)
      throws Exception {
    List<Job> jobs = null;
    JMXInput jmxInput = new JMXInput(quartzInstance, null, "AllJobDetails", null,
        scheduler.getObjectName());
    TabularDataSupport tdata = (TabularDataSupport) JMXUtil.callJMXAttribute(jmxInput);
    if (tdata != null) {
      jobs = new ArrayList<Job>();
      for (Iterator<Object> it = tdata.values().iterator(); it.hasNext();) {
        Object object = (Object) it.next();
        if (!(object instanceof CompositeDataSupport)) {
          continue;
        }
        CompositeDataSupport compositeDataSupport = (CompositeDataSupport) object;
View Full Code Here

TOP

Related Classes of javax.management.openmbean.TabularDataSupport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.