Package javax.management.openmbean

Examples of javax.management.openmbean.TabularData


                    new String[]{"Interfaces", "Properties"},
                    new String[]{"Interfaces class name of the service", "Properties of the service"},
                    new OpenType[]{new ArrayType(1, SimpleType.STRING), new ArrayType(1, SimpleType.STRING)});
            TabularType tableType = new TabularType("Services", "Table of OSGi Services", serviceType,
                    new String[]{"Interfaces", "Properties"});
            TabularData table = new TabularDataSupport(tableType);

            Bundle[] bundles;
            if (bundleId >= 0) {
                bundles = new Bundle[]{bundleContext.getBundle(bundleId)};
            } else {
                bundles = bundleContext.getBundles();
            }
            for (Bundle bundle : bundles) {
                try {
                    ServiceReference[] serviceReferences;
                    if (inUse) {
                        serviceReferences = bundle.getServicesInUse();
                    } else {
                        serviceReferences = bundle.getRegisteredServices();
                    }
                    if (serviceReferences != null) {
                        for (ServiceReference reference : serviceReferences) {
                            String[] interfaces = (String[]) reference.getProperty("objectClass");
                            List<String> properties = new ArrayList<String>();
                            for (String key : reference.getPropertyKeys()) {
                                properties.add(key + " = " + reference.getProperty(key));
                            }
                            CompositeData data = new CompositeDataSupport(serviceType,
                                    new String[]{"Interfaces", "Properties"},
                                    new Object[]{interfaces, properties.toArray(new String[0])});
                            table.put(data);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
View Full Code Here


        JMXConnector connector = null;
        try {
            connector = this.getJMXConnector();
            MBeanServerConnection connection = connector.getMBeanServerConnection();
            ObjectName name = new ObjectName("org.apache.karaf:type=service,name=root");
            TabularData services = (TabularData) connection.getAttribute(name, "Services");
            assertTrue(services.size() > 0);
        } finally {
            close(connector);
        }
    }
View Full Code Here

              close(connector);
        }
    }

    private int getInstancesNum(MBeanServerConnection connection, ObjectName name) throws Exception {
        TabularData instances = (TabularData) connection.getAttribute(name, "Instances");
        return instances.size();
    }
View Full Code Here

                                                                       "ID of the Bundle", "Bundle symbolic name"},
                                                         new OpenType[] {SimpleType.STRING, SimpleType.STRING,
                                                                         SimpleType.LONG, SimpleType.STRING});
            TabularType tableType = new TabularType("PackageExports", "Exported packages", bundleType,
                                                    new String[] {"Name", "Version", "ID"});
            TabularData table = new TabularDataSupport(tableType);

            SortedMap<String, PackageVersion> exports = packageService.getExports();

            for (String key : exports.keySet()) {
                PackageVersion export = exports.get(key);
                for (Bundle bundle : export.getBundles()) {
                    Object[] data = new Object[] {
                                         export.getPackageName(),
                                         export.getVersion().toString(),
                                         bundle.getBundleId(),
                                         bundle.getSymbolicName()};
                    CompositeData comp = new CompositeDataSupport(bundleType, names, data);
                    LOGGER.debug("Adding CompositeDataSupport {} for key: {}", comp, key);
                    table.put(comp);
                }
            }
            return table;
        } catch (RuntimeException e) {
            // To avoid the exception gets swallowed by jmx
View Full Code Here

                                                         names,
                                                         new OpenType[] {SimpleType.STRING, SimpleType.STRING, SimpleType.BOOLEAN,
                                                                         SimpleType.LONG, SimpleType.STRING, SimpleType.BOOLEAN});
            TabularType tableType = new TabularType("PackageImports", "Imported packages", bundleType,
                                                    new String[] {"Filter", "ID"});
            TabularData table = new TabularDataSupport(tableType);

            SortedMap<String, PackageRequirement> imports = packageService.getImports();

            for (String key : imports.keySet()) {
                PackageRequirement req = imports.get(key);
                Object[] data = new Object[] {
                                         req.getPackageName(),
                                         req.getFilter(),
                                         req.isOptional(),
                                         req.getBundle().getBundleId(),
                                         req.getBundle().getSymbolicName(),
                                         req.isResolveable()};
                CompositeData comp = new CompositeDataSupport(bundleType, names, data);
                table.put(comp);
             }
            return table;
        } catch (RuntimeException e) {
            // To avoid the exception gets swallowed by jmx
            LOGGER.error(e.getMessage(), e);
View Full Code Here

            MBeanServerConnection connection = connector.getMBeanServerConnection();
            ObjectName name = new ObjectName("org.apache.karaf:type=obr,name=root");
            @SuppressWarnings("unchecked")
            List<String> urls = (List<String>) connection.getAttribute(name, "Urls");
            assertEquals(0, urls.size());
            TabularData bundles = (TabularData) connection.getAttribute(name, "Bundles");
            assertEquals(0, bundles.size());
        } finally {
          close(connector);
        }
    }
View Full Code Here

        JMXConnector connector = null;
        try {
            connector = this.getJMXConnector();
            MBeanServerConnection connection = connector.getMBeanServerConnection();
            ObjectName name = new ObjectName("org.apache.karaf:type=package,name=root");
            TabularData exports = (TabularData) connection.getAttribute(name, "Exports");
            assertTrue(exports.size() > 0);
        } finally {
            close(connector);
        }
    }
View Full Code Here

        JMXConnector connector = null;
        try {
            connector = this.getJMXConnector();
            MBeanServerConnection connection = connector.getMBeanServerConnection();
            ObjectName name = new ObjectName("org.apache.karaf:type=package,name=root");
            TabularData imports = (TabularData) connection.getAttribute(name, "Imports");
            assertTrue(imports.size() > 0);
        } finally {
          close(connector);
        }
    }
View Full Code Here

        JMXConnector connector = null;
        try {
            connector = this.getJMXConnector();
            MBeanServerConnection connection = connector.getMBeanServerConnection();
            ObjectName name = new ObjectName("org.apache.karaf:type=http,name=root");
            TabularData servlets = (TabularData) connection.getAttribute(name, "Servlets");
            assertTrue(servlets.size() > 0);
        } finally {
            close(connector);
        }
    }
View Full Code Here

                    features.add(new JmxFeature(feature, insFeatures.contains(feature)));
                } catch (Throwable t) {
                    t.printStackTrace();
                }
            }
            TabularData table = JmxFeature.tableFrom(features);
            return table;
        } catch (Throwable t) {
            t.printStackTrace();
            return null;
        }
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.