Examples of BundleEvent


Examples of org.osgi.framework.BundleEvent

        EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "*.xml", false))
            .andReturn(Collections.enumeration(
                Collections.singleton(getClass().getResource("/ed3.xml"))));
        EasyMock.replay(bundle);
               
        BundleEvent be0 = new BundleEvent(BundleEvent.INSTALLED, bundle);
        ld.bundleChanged(be0);
        assertEquals(0, ld.endpointDescriptions.size());
       
        // Create an EndpointListener
        final Hashtable<String, Object> props = new Hashtable<String, Object>();
        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=*)");
        ServiceReference sr = EasyMock.createMock(ServiceReference.class);
        EasyMock.expect(sr.getPropertyKeys()).andReturn(props.keySet().toArray(new String [] {})).anyTimes();
        EasyMock.expect(sr.getProperty((String) EasyMock.anyObject())).andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                return props.get(EasyMock.getCurrentArguments()[0]);
            }
        }).anyTimes();               
        EasyMock.replay(sr);

        EndpointListener el = EasyMock.createMock(EndpointListener.class);
        el.endpointAdded((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
        EasyMock.expectLastCall();
        EasyMock.replay(el);
        ld.registerTracker(sr, el);
       
        // Start the bundle
        BundleEvent be = new BundleEvent(BundleEvent.STARTED, bundle);
        ld.bundleChanged(be);
        assertEquals(1, ld.endpointDescriptions.size());
        EndpointDescription ed = ld.endpointDescriptions.keySet().iterator().next();
        assertEquals("http://somewhere:12345", ed.getId());
        assertSame(bundle, ld.endpointDescriptions.get(ed));
       
        EasyMock.verify(el);

        // Stop the bundle
        EasyMock.reset(el);
        el.endpointRemoved((EndpointDescription) EasyMock.anyObject(), EasyMock.eq("(objectClass=*)"));
        EasyMock.expectLastCall();
        EasyMock.replay(el);
       
        BundleEvent be1 = new BundleEvent(BundleEvent.STOPPED, bundle);
        ld.bundleChanged(be1);
        assertEquals(0, ld.endpointDescriptions.size());
       
        EasyMock.verify(el);
    }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

        EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "ed4.xml", false))
            .andReturn(Collections.enumeration(
                Collections.singleton(getClass().getResource("/ed4.xml"))));
        EasyMock.replay(bundle);
                       
        BundleEvent be = new BundleEvent(BundleEvent.STARTED, bundle);
        ld.bundleChanged(be);
        assertEquals(2, ld.endpointDescriptions.size());       

        final Hashtable<String, Object> props = new Hashtable<String, Object>();
        props.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, new String [] {"(objectClass=org.example.ClassA)"});
View Full Code Here

Examples of org.osgi.framework.BundleEvent

    public void init() throws Exception {
        bundleContext.addBundleListener(this);
        for (Bundle bundle : bundleContext.getBundles()) {
            if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING
                    || bundle.getState() == Bundle.ACTIVE)
            bundleChanged(new BundleEvent(BundleEvent.RESOLVED, bundle));
        }
    }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

       
        Bundle b = EasyMock.createMock(Bundle.class);
        EasyMock.replay(b);
       
        assertEquals("Precondition failed", 0, called.size());
        bundleListener[0].bundleChanged(new BundleEvent(BundleEvent.INSTALLED, b));
        assertEquals(0, called.size());
       
        bundleListener[0].bundleChanged(new BundleEvent(BundleEvent.STARTED, b));
        assertEquals(Arrays.asList("addDecorations"), called);
       
        bundleListener[0].bundleChanged(new BundleEvent(BundleEvent.STOPPING, b));
        assertEquals(Arrays.asList("addDecorations", "removeDecorations"), called);
    }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

        CompositeBundle  cb = composite("test.composite", "1.0.0");
        assertNoTrackers();
       
        // full lifecycle
       
        sut.addingBundle(cb, new BundleEvent(BundleEvent.INSTALLED, cb));
        assertTracker(cb);

        sut.modifiedBundle(cb, new BundleEvent(BundleEvent.RESOLVED, cb), cb);
        sut.modifiedBundle(cb, new BundleEvent(BundleEvent.STARTING, cb), cb);
        sut.modifiedBundle(cb, new BundleEvent(BundleEvent.STARTED, cb), cb);
        sut.modifiedBundle(cb, new BundleEvent(BundleEvent.STOPPING, cb), cb);
        sut.removedBundle(cb, new BundleEvent(BundleEvent.STOPPED, cb), cb);
        assertNoTrackers();
       
        // short lifecycle
       
        sut.addingBundle(cb, new BundleEvent(BundleEvent.INSTALLED, cb));
        assertTracker(cb);
       
        sut.modifiedBundle(cb, new BundleEvent(BundleEvent.RESOLVED, cb), cb);       
        sut.removedBundle(cb, new BundleEvent(BundleEvent.UNRESOLVED, cb), cb);
        assertNoTrackers();
       
        // shortest lifecycle
       
        sut.addingBundle(cb, new BundleEvent(BundleEvent.INSTALLED, cb));
        assertTracker(cb);
       
        sut.removedBundle(cb, new BundleEvent(BundleEvent.UNINSTALLED, cb), cb);
        assertNoTrackers();
    }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

    public void init() throws Exception {
        bundleContext.addBundleListener(this);
        for (Bundle bundle : bundleContext.getBundles()) {
            if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING
                    || bundle.getState() == Bundle.ACTIVE)
            bundleChanged(new BundleEvent(BundleEvent.RESOLVED, bundle));
        }
    }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

            public String getLocation() {
                return bundleLocation;
            }
        });

        BundleEvent bundleEvent = new BundleEvent(BundleEvent.INSTALLED, testBundleA);
        FrameworkEvent frameworkEvent = new FrameworkEvent(FrameworkEvent.INFO, testBundleA, new IllegalStateException());

        listeners.bundleChanged(bundleEvent);
        listeners.frameworkEvent(frameworkEvent);
        listeners.stopInternal();
View Full Code Here

Examples of org.osgi.framework.BundleEvent

    public void init() throws Exception {
        bundleContext.addBundleListener(this);
        for (Bundle bundle : bundleContext.getBundles()) {
            if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING
                    || bundle.getState() == Bundle.ACTIVE)
            bundleChanged(new BundleEvent(BundleEvent.RESOLVED, bundle));
        }
    }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

        loadProperties();
        // Scan bundles
        for (Bundle bundle : bundleContext.getBundles()) {
            if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING
                    || bundle.getState() == Bundle.ACTIVE)
            bundleChanged(new BundleEvent(BundleEvent.RESOLVED, bundle));
        }
    }
View Full Code Here

Examples of org.osgi.framework.BundleEvent

        loadProperties();
        // Scan bundles
        for (Bundle bundle : bundleContext.getBundles()) {
            if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING
                    || bundle.getState() == Bundle.ACTIVE)
            bundleChanged(new BundleEvent(BundleEvent.RESOLVED, bundle));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.