Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.ServiceContext


        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        ServiceContext sc = getServiceContext(empty);

        Factory fact2 = ipojoHelper.getFactory("composite.test.2");
        Properties props2 = new Properties();
        props2.put("instance.name", "2"); // 2
        Factory fact3 = ipojoHelper.getFactory("composite.test.3");
        Properties props3 = new Properties();
        props3.put("instance.name", "3");
        ComponentInstance comp2 = null;
        ComponentInstance comp3 = null;
        try {
            comp2 = fact2.createComponentInstance(props2, sc);
            comp3 = fact3.createComponentInstance(props3, sc);
        } catch (Throwable e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        assertTrue("Test comp3", comp3.getState() == ComponentInstance.VALID);
        assertTrue("Test comp2", comp2.getState() == ComponentInstance.VALID);

        ServiceReference ref = null;

        ref = ipojoHelper.getServiceReferenceByName(sc, CheckService.class.getName(), "2"); // 2

        assertNotNull("Check ref", ref);
        CheckService cs = (CheckService) sc.getService(ref);
        assertTrue("Check invoke", cs.check());

        comp3.dispose();
        comp2.dispose();
        empty.dispose();
View Full Code Here


            empty = fact1.createComponentInstance(p);
        } catch (Exception e) {
            e.printStackTrace();
        }

        ServiceContext sc = getServiceContext(empty);

        Factory fact2 = ipojoHelper.getFactory(sc, "composite.test.2");
        Properties props2 = new Properties();
        props2.put("instance.name", "4");
        Factory fact3 = ipojoHelper.getFactory(sc, "composite.test.3");
        Properties props3 = new Properties();
        props3.put("instance.name", "5");
        ComponentInstance comp2 = null;
        ComponentInstance comp3 = null;
        try {
            comp2 = fact2.createComponentInstance(props2, sc);
            comp3 = fact3.createComponentInstance(props3, sc);
        } catch (Exception e) {
            e.printStackTrace();
        }

        assertTrue("Test comp3", comp3.getState() == ComponentInstance.VALID);
        assertTrue("Test comp2", comp2.getState() == ComponentInstance.VALID);

        ServiceReference ref = null;

        ref = ipojoHelper.getServiceReferenceByName(sc, CheckService.class.getName(), "4");

        assertNotNull("Check ref", ref);
        CheckService cs = (CheckService) sc.getService(ref);
        assertTrue("Check invoke", cs.check());

        comp3.dispose();
        comp2.dispose();
        empty.dispose();
View Full Code Here

            under = bar1Factory.createComponentInstance(props);
        } catch (Exception e) {
            fail("Cannot instantiate under : " + e.getMessage());
        }
        assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
        ServiceContext sc = getServiceContext(under);
        assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));

        under.dispose();
    }
View Full Code Here

        under.dispose();
    }

    @Test
    public void testCreationLevel2() {
        ServiceContext sc = getServiceContext(empty);
        Properties props = new Properties();
        props.put("instance.name", "under");
        ComponentInstance under = null;
        try {
            under = bar1Factory.createComponentInstance(props, sc);
View Full Code Here

        under.dispose();
    }

    @Test
    public void testServiceAvailabilityLevel2() {
        ServiceContext sc = getServiceContext(empty);
        Properties props = new Properties();
        props.put("instance.name", "under-X");
        ComponentInstance under = null;
        try {
            under = bar1Factory.createComponentInstance(props, sc);
        } catch (Exception e) {
            fail("Cannot instantiate under : " + e.getMessage());
        }
        assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
        ServiceContext sc2 = getServiceContext(under);
        assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));

        under.dispose();
    }
View Full Code Here

        fact3.start();
    }

    @Test
    public void testFactoryManagementLevel2() {
        ServiceContext sc = getServiceContext(empty);
        Properties props = new Properties();
        props.put("instance.name", "under");
        ComponentInstance under = null;
        try {
            under = bar1Factory.createComponentInstance(props, sc);
View Full Code Here

            under = bar2Factory.createComponentInstance(props);
        } catch (Exception e) {
            fail("Cannot instantiate under : " + e.getMessage());
        }
        assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
        ServiceContext sc = getServiceContext(under);
        assertNotNull("Check service availability", sc.getServiceReference(BarService.class.getName()));
        int count = ipojoHelper.getServiceReferences(sc, BarService.class.getName(), null).length;
        assertEquals("Check service provider number : " + count, count, 3);

        under.dispose();
    }
View Full Code Here

        under.dispose();
    }

    @Test
    public void testCreationLevel2() {
        ServiceContext sc = getServiceContext(empty);
        Properties props = new Properties();
        props.put("instance.name", "under");
        ComponentInstance under = null;
        try {
            under = bar2Factory.createComponentInstance(props, sc);
View Full Code Here

        under.dispose();
    }

    @Test
    public void testServiceAvailabilityLevel2() {
        ServiceContext sc = getServiceContext(empty);
        Properties props = new Properties();
        props.put("instance.name", "under");
        ComponentInstance under = null;
        try {
            under = bar2Factory.createComponentInstance(props, sc);
        } catch (Exception e) {
            fail("Cannot instantiate under : " + e.getMessage());
        }
        assertTrue("Check instance validity", under.getState() == ComponentInstance.VALID);
        ServiceContext sc2 = getServiceContext(under);
        assertNotNull("Check service availability", sc2.getServiceReference(BarService.class.getName()));
        assertEquals("Check service provider number", ipojoHelper.getServiceReferences(sc2,
                BarService.class.getName(), null).length, 3);

        under.dispose();
    }
View Full Code Here

        try {
            under = bar2Factory.createComponentInstance(props);
        } catch (Exception e) {
            fail("Cannot instantiate under : " + e.getMessage());
        }
        ServiceContext sc = getServiceContext(under);
        assertTrue("Check instance validity - 1", under.getState() == ComponentInstance.VALID);

        ComponentFactory fact1 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-1");
        ComponentFactory fact2 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-2");
        ComponentFactory fact3 = (ComponentFactory) ipojoHelper.getFactory("COMPO-FooBarProviderType-3");
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.ServiceContext

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.