Package javax.management.openmbean

Examples of javax.management.openmbean.TabularDataSupport


            }
            StartLevel startLevel = visitor.getStartLevel();
            if (startLevel == null) {
                throw new IOException("StartLevel is not available");
            }
            TabularDataSupport dataSupport = new TabularDataSupport(BUNDLES_TYPE);
            if (bundles != null) {
                for (Bundle bundle : bundles) {
                    Map<String, Object> values = new HashMap<String, Object>();
                    values.put(EXPORTED_PACKAGES, getExportedPackages(bundle, packageAdmin));
                    values.put(FRAGMENT, isFragment(bundle, packageAdmin));
                    values.put(FRAGMENTS, Utils.toLongArray(getFragments(bundle, packageAdmin)));
                    values.put(HEADERS, getHeaders(bundle));
                    values.put(HOSTS, Utils.toLongArray(getHosts(bundle, packageAdmin)));
                    values.put(IDENTIFIER, bundle.getBundleId());
                    values.put(IMPORTED_PACKAGES, getImportedPackages(bundle, packageAdmin));
                    values.put(LAST_MODIFIED, bundle.getLastModified());
                    values.put(LOCATION, bundle.getLocation());
                    values.put(PERSISTENTLY_STARTED, isPersistentlyStarted(bundle, startLevel));
                    values.put(REGISTERED_SERVICES, Utils.toLongArray(getRegisteredServices(bundle)));
                    values.put(REMOVAL_PENDING, isRemovalPending(bundle, packageAdmin));
                    values.put(REQUIRED, isRequired(bundle, packageAdmin));
                    values.put(REQUIRED_BUNDLES, Utils.toLongArray(getRequiredBundles(bundle, packageAdmin)));
                    values.put(REQUIRING_BUNDLES, Utils.toLongArray(getRequiringBundles(bundle, packageAdmin)));
                    values.put(START_LEVEL, getStartLevel(bundle, startLevel));
                    values.put(STATE, getState(bundle));
                    values.put(SERVICES_IN_USE, Utils.toLongArray(getServicesInUse(bundle)));
                    values.put(SYMBOLIC_NAME, getSymbolicName(bundle));
                    values.put(VERSION, getVersion(bundle));
                    dataSupport.put(new CompositeDataSupport(BUNDLE_TYPE, values));
                }
            }
            return dataSupport;
        } catch (IOException e) {
            logVisitor.warning("listBundles error", e);
View Full Code Here


        }
        return new long[0];
    }

    private TabularData getHeaders(Bundle bundle) throws OpenDataException {
        TabularDataSupport dataSupport = new TabularDataSupport(HEADERS_TYPE);
        Dictionary headers = bundle.getHeaders();
        Enumeration keys = headers.keys();
        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            Map<String, Object> values = new HashMap<String, Object>();
            values.put(KEY, key);
            values.put(VALUE, headers.get(key));
            dataSupport.put(new CompositeDataSupport(HEADER_TYPE, values));
        }
        return dataSupport;
    }
View Full Code Here

    }

    public TabularData listServices() throws IOException {
        try {
            ServiceReference[] serviceReferences = visitor.getAllServiceReferences();
            TabularDataSupport dataSupport = new TabularDataSupport(SERVICES_TYPE);
            if (serviceReferences != null) {
                for (ServiceReference serviceReference : serviceReferences) {
                    Map<String, Object> values = new HashMap<String, Object>();
                    values.put(BUNDLE_IDENTIFIER, serviceReference.getBundle().getBundleId());
                    values.put(IDENTIFIER, serviceReference.getProperty(Constants.SERVICE_ID));
                    values.put(OBJECT_CLASS, serviceReference.getProperty(Constants.OBJECTCLASS));
                    values.put(USING_BUNDLES, Utils.toLongArray(Utils.getIds(serviceReference.getUsingBundles())));
                    dataSupport.put(new CompositeDataSupport(SERVICE_TYPE, values));
                }
            }
            return dataSupport;
        } catch (Exception e) {
            logVisitor.warning("listServices error", e);
View Full Code Here

         itemNames, itemDescriptions, itemTypes);

      String[] indexNames = new String[] { "name1", "name2" };
      TabularType tabularType = new TabularType("typeName", "description", rowType, indexNames);

      TabularDataSupport data = new TabularDataSupport(tabularType);

      assertTrue("Didn't expect containsValue null", data.containsValue(null) == false);

      itemNames = new String[] { "name1", "name2" };
      itemDescriptions = new String[] { "desc1", "desc2" };
      itemTypes = new OpenType[] { SimpleType.STRING, SimpleType.INTEGER };
      CompositeType rowType2 = new CompositeType("rowTypeName2", "rowDescription",
         itemNames, itemDescriptions, itemTypes);

      HashMap map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(2));
      CompositeDataSupport compData2 = new CompositeDataSupport(rowType2, map);

      assertTrue("Didn't expect containsValue wrong composite type", data.containsValue(compData2) == false);

      map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(3));
      CompositeDataSupport compData = new CompositeDataSupport(rowType, map);
      assertTrue("Didn't expect containsValue on data not present", data.containsValue(compData) == false);

      map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(2));
      compData = new CompositeDataSupport(rowType, map);
      data.put(compData);
      assertTrue("Expected containsValue", data.containsValue(compData));

      map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(3));
      compData = new CompositeDataSupport(rowType, map);
      assertTrue("Didn't expect containsValue on value still not present", data.containsValue(compData) == false);

      assertTrue("Didn't expect containsValue still wrong composite type", data.containsValue(compData2) == false);

      data.remove(data.calculateIndex(compData));
      assertTrue("Didn't expect removed data in containsValue", data.containsValue(compData) == false);
   }
View Full Code Here

         itemNames, itemDescriptions, itemTypes);

      String[] indexNames = new String[] { "name1", "name2" };
      TabularType tabularType = new TabularType("typeName", "description", rowType, indexNames);

      TabularDataSupport data = new TabularDataSupport(tabularType);

      Object[] index = new Object[] { "value1", new Integer(3) };
      assertTrue("Expected null for get on data not present", data.get((Object) index) == null);

      HashMap map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(2));
      CompositeDataSupport compData = new CompositeDataSupport(rowType, map);
      index = new Object[] { "value1", new Integer(2) };
      data.put(compData);
      assertTrue("Expected get to return the same value", data.get((Object) index).equals(compData));

      index = new Object[] { "value1", new Integer(3) };
      assertTrue("Didn't expect get on value still not present", data.get((Object) index) == null);

      index = new Object[] { "value1", new Integer(2) };
      data.remove(index);
      assertTrue("Didn't expect removed data in get", data.get((Object) index) == null);
   }
View Full Code Here

         itemNames, itemDescriptions, itemTypes);

      String[] indexNames = new String[] { "name1", "name2" };
      TabularType tabularType = new TabularType("typeName", "description", rowType, indexNames);

      TabularDataSupport data = new TabularDataSupport(tabularType);

      Object[] index = new Object[] { "value1", new Integer(3) };
      assertTrue("Expected null for get on data not present", data.get(index) == null);

      HashMap map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(2));
      CompositeDataSupport compData = new CompositeDataSupport(rowType, map);
      index = new Object[] { "value1", new Integer(2) };
      data.put(compData);
      assertTrue("Expected get to return the same value", data.get(index).equals(compData));

      index = new Object[] { "value1", new Integer(3) };
      assertTrue("Didn't expect get on value still not present", data.get(index) == null);

      index = new Object[] { "value1", new Integer(2) };
      data.remove(index);
      assertTrue("Didn't expect removed data in get", data.get(index) == null);
   }
View Full Code Here

         itemNames, itemDescriptions, itemTypes);

      String[] indexNames = new String[] { "name1", "name2" };
      TabularType tabularType = new TabularType("typeName", "description", rowType, indexNames);

      TabularDataSupport data = new TabularDataSupport(tabularType);

      HashMap map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(2));
      CompositeDataSupport compData = new CompositeDataSupport(rowType, map);
      Object[] index = new Object[] { "value1", new Integer(2) };
      data.put(index, (Object) compData);
      assertTrue("The data should be present after put", data.get(index).equals(compData));

      HashMap map2 = new HashMap();
      map2.put("name1", "value1");
      map2.put("name2", new Integer(3));
      CompositeDataSupport compData2 = new CompositeDataSupport(rowType, map2);
      index = new Object[] { "value1", new Integer(3) };
      data.put(index, (Object) compData2);
      assertTrue("Another data should be present after put", data.get(index).equals(compData2));

      index = new Object[] { "value1", new Integer(2) };
      assertTrue("The previous data should be present after put", data.get(index).equals(compData));

      data.remove(index);
      data.put(index, compData);
      assertTrue("Data should be present after remove/put", data.get(index).equals(compData));

      HashMap map3 = new HashMap();
      map3.put("name1", "value1");
      map3.put("name2", new Integer(4));
      CompositeDataSupport compData3 = new CompositeDataSupport(rowType, map3);
      index = new Object[] { "value1", new Integer(4) };
      data.put(new Object(), compData3);
      assertTrue("The key should be ignored in put", data.get(index).equals(compData3));
   }
View Full Code Here

         itemNames, itemDescriptions, itemTypes);

      String[] indexNames = new String[] { "name1", "name2" };
      TabularType tabularType = new TabularType("typeName", "description", rowType, indexNames);

      TabularDataSupport data = new TabularDataSupport(tabularType);

      HashMap map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(2));
      CompositeDataSupport compData = new CompositeDataSupport(rowType, map);
      Object[] index = new Object[] { "value1", new Integer(2) };
      data.put(compData);
      assertTrue("The data should be present after put", data.get(index).equals(compData));

      HashMap map2 = new HashMap();
      map2.put("name1", "value1");
      map2.put("name2", new Integer(3));
      CompositeDataSupport compData2 = new CompositeDataSupport(rowType, map2);
      index = new Object[] { "value1", new Integer(3) };
      data.put(compData2);
      assertTrue("Another data should be present after put", data.get(index).equals(compData2));

      index = new Object[] { "value1", new Integer(2) };
      assertTrue("The previous data should be present after put", data.get(index).equals(compData));

      data.remove(index);
      data.put(compData);
      assertTrue("Data should be present after remove/put", data.get(index).equals(compData));
   }
View Full Code Here

         itemNames, itemDescriptions, itemTypes);

      String[] indexNames = new String[] { "name1", "name2" };
      TabularType tabularType = new TabularType("typeName", "description", rowType, indexNames);

      TabularDataSupport data = new TabularDataSupport(tabularType);

      HashMap map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(2));
      CompositeDataSupport compData = new CompositeDataSupport(rowType, map);
      Object[] index = new Object[] { "value1", new Integer(2) };

      assertTrue("Remove on data not present returns null", data.remove((Object) index) == null);

      data.put(compData);
      assertTrue("Remove on data present returns the data", data.remove((Object) index).equals(compData));
   }
View Full Code Here

         itemNames, itemDescriptions, itemTypes);

      String[] indexNames = new String[] { "name1", "name2" };
      TabularType tabularType = new TabularType("typeName", "description", rowType, indexNames);

      TabularDataSupport data = new TabularDataSupport(tabularType);

      HashMap map = new HashMap();
      map.put("name1", "value1");
      map.put("name2", new Integer(2));
      CompositeDataSupport compData = new CompositeDataSupport(rowType, map);
      Object[] index = new Object[] { "value1", new Integer(2) };

      assertTrue("Remove on data not present returns null", data.remove(index) == null);

      data.put(compData);
      assertTrue("Remove on data present returns the data", data.remove(index).equals(compData));
   }
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.