Package javax.management.openmbean

Examples of javax.management.openmbean.TabularData


            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


        EasyMock.expect(i.getLocation()).andReturn("somewhere");
        EasyMock.expect(i.getJavaOpts()).andReturn("someopts");
        EasyMock.replay(i);
       
        JmxInstance ji = new JmxInstance(i);
        TabularData td = JmxInstance.tableFrom(Collections.singletonList(ji));       
        Collection<?> keys = (Collection<?>) td.keySet().iterator().next();
        Assert.assertEquals("MyInstance", keys.iterator().next());
       
        CompositeData cd = td.get(keys.toArray());
        Assert.assertEquals(1712, cd.get("Pid"));
        Assert.assertEquals("MyInstance", cd.get("Name"));
        Assert.assertEquals(false, cd.get("Is Root"));
        Assert.assertEquals(0, cd.get("SSH Port"));
        Assert.assertEquals(0, cd.get("RMI Port"));
View Full Code Here

        EasyMock.expect(i.getLocation()).andReturn(null);
        EasyMock.expect(i.getJavaOpts()).andReturn(null);
        EasyMock.replay(i);
       
        JmxInstance ji = new JmxInstance(i);
        TabularData td = JmxInstance.tableFrom(Collections.singletonList(ji));       
        Collection<?> keys = (Collection<?>) td.keySet().iterator().next();
        Assert.assertEquals("MyInstance", keys.iterator().next());
       
        CompositeData cd = td.get(keys.toArray());
        Assert.assertEquals(1712, cd.get("Pid"));
        Assert.assertEquals("MyInstance", cd.get("Name"));
        Assert.assertEquals(true, cd.get("Is Root"));
        Assert.assertEquals(0, cd.get("SSH Port"));
        Assert.assertEquals(0, cd.get("RMI Port"));
View Full Code Here

        EasyMock.replay(as);

        AdminServiceMBeanImpl ab = new AdminServiceMBeanImpl();
        ab.setAdminService(as);
       
        TabularData td = ab.getInstances();
        Assert.assertEquals(2, td.size());
        CompositeData cd1 = td.get(new Object [] {"i1"});
        Assert.assertTrue(cd1.containsValue("i1"));
        Assert.assertTrue(cd1.containsValue(true));
        Assert.assertTrue(cd1.containsValue(1234));
        Assert.assertTrue(cd1.containsValue(8818));
        Assert.assertTrue(cd1.containsValue(1122));
        Assert.assertTrue(cd1.containsValue("somewhere"));
        Assert.assertTrue(cd1.containsValue("someopts"));
        Assert.assertTrue(cd1.containsValue("Stopped"));

        CompositeData cd2 = td.get(new Object [] {"i2"});
        Assert.assertTrue(cd2.containsValue("i2"));
    }
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

        on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"log://foo\\?groupDelay=2000&groupSize=5&level=WARN\"");
        assertTrue(mbeanServer.isRegistered(on));

        // there should be 3 options
        TabularData data = (TabularData) mbeanServer.invoke(on, "explain", new Object[]{false}, new String[]{"boolean"});
        assertEquals(3, data.size());

        // there should be 6 options
        data = (TabularData) mbeanServer.invoke(on, "explain", new Object[]{true}, new String[]{"boolean"});
        assertEquals(6, data.size());
    }
View Full Code Here

        String source = (String) mbeanServer.getAttribute(on, "Source");
        assertTrue(source.startsWith("EndpointRegistry"));
        assertTrue(source.endsWith("capacity: 1000"));

        TabularData data = (TabularData) mbeanServer.invoke(on, "listEndpoints", null, null);
        assertEquals(2, data.size());

        // purge
        mbeanServer.invoke(on, "purge", null, null);

        current = (Integer) mbeanServer.getAttribute(on, "Size");
        assertEquals(0, current.intValue());

        data = (TabularData) mbeanServer.invoke(on, "listEndpoints", null, null);
        assertEquals(0, data.size());
    }
View Full Code Here

                    getManagedObject(ManagedQueue.class,
                                     jmxUtils.getQueueObjectName(getConnectionFactory().getVirtualPath().substring(1),
                                                                 getTestQueueName()));

            // Find the first message on the queue
            TabularData data = managedQueue.viewMessages(1L, 2L);

            Iterator values = data.values().iterator();
            assertTrue("No Messages found via JMX", values.hasNext());

            // Get its message ID
            Long msgID = (Long) ((CompositeDataSupport) values.next()).get("AMQ MessageId");
View Full Code Here

TOP

Related Classes of javax.management.openmbean.TabularData

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.