Package org.apache.felix.dm.tracker

Examples of org.apache.felix.dm.tracker.ServiceTracker.open()


@RunWith(PaxExam.class)
public class ServiceTrackerTest extends TestBase {
    @Test
    public void testPlainServiceTracker() {
        ServiceTracker st = new ServiceTracker(context, ServiceInterface.class.getName(), null);
        st.open();
        ServiceRegistration sr = context.registerService(ServiceInterface.class.getName(), new ServiceProvider(), null);
        Assert.assertEquals("There should be one service that matches the tracker", 1, st.getServices().length);
        sr.unregister();
        Assert.assertNull("There should be no service that matches the tracker", st.getServices());
        st.close();
View Full Code Here


    }
   
    @Test
    public void testAspectServiceTracker() {
        ServiceTracker st = new ServiceTracker(context, ServiceInterface.class.getName(), null);
        st.open();

        ServiceRegistration sr = context.registerService(ServiceInterface.class.getName(), new ServiceProvider(), null);
        Assert.assertEquals("There should be one service that matches the tracker", 1, st.getServices().length);
       
        final long sid = ServiceUtil.getServiceId(sr.getReference());
View Full Code Here

        ServiceRegistration asr = context.registerService(ServiceInterface.class.getName(), new ServiceProvider(),
            new Hashtable() {{ put(DependencyManager.ASPECT, sid); put(Constants.SERVICE_RANKING, 10); }});
        ServiceRegistration asr2 = context.registerService(ServiceInterface.class.getName(), new ServiceProvider(),
            new Hashtable() {{ put(DependencyManager.ASPECT, sid); put(Constants.SERVICE_RANKING, 20); }});

        st.open();
        Assert.assertEquals("There should be one service that matches the tracker", 1, st.getServices().length);
        Assert.assertEquals("Service ranking should be 20", Integer.valueOf(20), (Integer) st.getServiceReference().getProperty(Constants.SERVICE_RANKING));
       
        asr2.unregister();
        Assert.assertEquals("There should be one service that matches the tracker", 1, st.getServices().length);
View Full Code Here

        m_latch = null;
    }

    private void configureService(final String pid, Properties props) throws Exception {
        ServiceTracker tracker = new ServiceTracker(m_context, ConfigurationAdmin.class.getName(), null);
        tracker.open();

        ServiceRegistration reg = null;

        try {
            ConfigurationAdmin configAdmin = (ConfigurationAdmin) tracker.waitForService(TimeUnit.SECONDS.toMillis(5));
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.