Package org.osgi.jmx.framework

Examples of org.osgi.jmx.framework.BundleStateMBean


   @Override
   public boolean isBundleInstalled(String symbolicName)
   {
      try
      {
         BundleStateMBean bundleStateMBean = jmxSupport.getBundleStateMBean();
         TabularData listBundles = bundleStateMBean.listBundles();
         Iterator<?> iterator = listBundles.values().iterator();
         while (iterator.hasNext())
         {
            CompositeData bundleType = (CompositeData)iterator.next();
            String bsn = (String)bundleType.get(BundleStateMBean.SYMBOLIC_NAME);
View Full Code Here


    }

    private List<BundleHandle> getBundles() throws LifecycleException {
        List<BundleHandle> bundleList = new ArrayList<BundleHandle>();
        try {
            BundleStateMBean bundleStateMBean = jmxSupport.getBundleStateMBean();
            TabularData listBundles = bundleStateMBean.listBundles();
            Iterator<?> iterator = listBundles.values().iterator();
            while (iterator.hasNext()) {
                CompositeData bundleType = (CompositeData) iterator.next();
                Long bundleId = (Long) bundleType.get(BundleStateMBean.IDENTIFIER);
                String symbolicName = (String) bundleType.get(BundleStateMBean.SYMBOLIC_NAME);
View Full Code Here

    }

    @Test
    public void testMBeanInterface() throws Exception {
       
        BundleStateMBean mbean = getMBean(OBJECTNAME, BundleStateMBean.class);
        assertNotNull(mbean);
       
        //get bundles
       
        Bundle a = getBundle("org.apache.aries.jmx.test.bundlea");
        assertNotNull(a);
       
        Bundle b = getBundle("org.apache.aries.jmx.test.bundleb");
        assertNotNull(b);
       
        Bundle frag = getBundle("org.apache.aries.jmx.test.fragc");
        assertNotNull(frag);

        Bundle d = getBundle("org.apache.aries.jmx.test.bundled");
        assertNotNull(d);
       
        // exportedPackages
       
        String[] exports = mbean.getExportedPackages(a.getBundleId());
        assertEquals(2, exports.length);
       
        List<String> packages = Arrays.asList(exports);
        assertTrue(packages.contains("org.apache.aries.jmx.test.bundlea.api;2.0.0"));
        assertTrue(packages.contains("org.apache.aries.jmx.test.fragmentc;0.0.0"));
       
        //fragments
       
        long[] fragments = mbean.getFragments(a.getBundleId());
        assertEquals(1, fragments.length);
        assertEquals(frag.getBundleId() , fragments[0]);
      
        //headers

        TabularData headers = mbean.getHeaders(b.getBundleId());
        assertNotNull(headers);
        assertEquals(BundleStateMBean.HEADERS_TYPE, headers.getTabularType());
        assertTrue(headers.values().size() >= 4 );
        assertEquals("org.apache.aries.jmx.test.bundleb", Header.from(headers.get(new Object[] {Constants.BUNDLE_SYMBOLICNAME})).getValue());
       
        //hosts
       
        long[] hosts = mbean.getHosts(frag.getBundleId());
        assertEquals(1, hosts.length);
        assertEquals(a.getBundleId() , hosts[0]);
       
        //imported packages
          
        String[] imports = mbean.getImportedPackages(a.getBundleId());
        assertTrue(imports.length >= 3);
        List<String> importedPackages = Arrays.asList(imports);
        assertTrue(importedPackages.contains("org.osgi.framework;1.5.0"));
        assertTrue(importedPackages.contains("org.apache.aries.jmx.test.bundleb.api;1.1.0"));
       
        //last modified
       
        assertTrue(mbean.getLastModified(b.getBundleId()) > 0);
       
        //location
       
        assertEquals(b.getLocation(), mbean.getLocation(b.getBundleId()));
       
        //registered services
       
        long[] serviceIds = mbean.getRegisteredServices(a.getBundleId());
        assertEquals(1, serviceIds.length);
       
        //required bundles
       
        long[] required = mbean.getRequiredBundles(d.getBundleId());
        assertEquals(1, required.length);
        assertEquals(a.getBundleId(), required[0]);
       
        //requiring bundles
       
        long[] requiring = mbean.getRequiringBundles(a.getBundleId());
        assertEquals(1, requiring.length);
        assertEquals(d.getBundleId(), requiring[0]);
       
        //services in use
       
        long[] servicesInUse = mbean.getServicesInUse(a.getBundleId());
        assertEquals(1, servicesInUse.length);
       
        //start level
       
        long startLevel = mbean.getStartLevel(b.getBundleId());
        assertTrue(startLevel >= 0);
       
        //state
       
        assertEquals("ACTIVE", mbean.getState(b.getBundleId()));
       
        //isFragment
       
        assertFalse(mbean.isFragment(b.getBundleId()));
        assertTrue(mbean.isFragment(frag.getBundleId()));
       
        //isRemovalPending
        assertFalse(mbean.isRemovalPending(b.getBundleId()));
       
        // isRequired
      
        assertTrue(mbean.isRequired(a.getBundleId()));
        assertFalse(mbean.isRequired(b.getBundleId()));
       
        // listBundles
       
        TabularData bundlesTable = mbean.listBundles();
        assertNotNull(bundlesTable);
        assertEquals(BundleStateMBean.BUNDLES_TYPE, bundlesTable.getTabularType());
        assertEquals(bundleContext.getBundles().length, bundlesTable.values().size());
       
       
View Full Code Here

        }
        return frameworkState;
    }

    public BundleStateMBean getBundleStateMBean() throws IOException {
        BundleStateMBean bundleState = null;
        ObjectName objectName = createObjectName(BundleStateMBean.OBJECTNAME);
        if (isRegisteredWithTimeout(objectName)) {
            bundleState = getMBeanProxy(objectName, BundleStateMBean.class);
            return bundleState;
        }
View Full Code Here

    }

    private List<BundleHandle> getBundles() throws LifecycleException {
        List<BundleHandle> bundleList = new ArrayList<BundleHandle>();
        try {
            BundleStateMBean bundleStateMBean = jmxSupport.getBundleStateMBean();
            TabularData listBundles = bundleStateMBean.listBundles();
            Iterator<?> iterator = listBundles.values().iterator();
            while (iterator.hasNext()) {
                CompositeData bundleType = (CompositeData) iterator.next();
                Long bundleId = (Long) bundleType.get(BundleStateMBean.IDENTIFIER);
                String symbolicName = (String) bundleType.get(BundleStateMBean.SYMBOLIC_NAME);
View Full Code Here

TOP

Related Classes of org.osgi.jmx.framework.BundleStateMBean

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.