Examples of Architecture


Examples of org.apache.felix.ipojo.architecture.Architecture

        factory.start();


        //  The instance should be created, wait for the architecture service
        osgiHelper.waitForService(Architecture.class.getName(), "(architecture.instance=" + pid + ")", 1000);
        Architecture architecture = (Architecture) osgiHelper.getServiceObject(Architecture.class.getName(), "(architecture.instance=" + pid + ")");

        assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);

        // Wait for the processing of the first configuration.
        grace();

        props.put("message", "message2");
        try {
            configuration.update(props);
            // Update the configuration ...
            grace();
        } catch (Exception e) {
            fail(e.getMessage());
        }

        //architecture = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance="+pid+")");

        assertEquals("Check no object -2", 0, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);

        //Invoke
        FooService fs = (FooService) osgiHelper.getServiceObject(FooService.class.getName(), "(instance.name=" + pid + ")");
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = (Integer) p.get("count");
        // architecture = (Architecture) osgiHelper.getServiceObject( Architecture.class.getName(), "(architecture.instance="+pid+")");

        assertEquals("Assert Message", "message2", mes);
        assertEquals("Assert count", 1, count);
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) architecture.getInstanceDescription()).getCreatedObjects().length);

        try {
            configuration.delete();
            grace();
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.felix.ipojo.architecture.Architecture

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

        Architecture arch = (Architecture) osgiHelper.getServiceObject(org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), conf.getPid());
        assertEquals("Check no object", 0, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        // arch = (Architecture) osgiHelper.getServiceObject( org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        FooService fs = (FooService) bc.getService(ref);
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = (Integer) p.get("count");
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertEquals("Check message", "message", mes);
        assertEquals("Check count", 1, count);

        //Update
        Configuration configuration;
        try {
            configuration = admin.getConfiguration(msp, getTestBundle().getLocation());
            Dictionary prc = configuration.getProperties();
            if (prc == null) {
                prc = new Properties();
            }
            prc.put("message", "message2");
            configuration.update(prc);
            grace();
        } catch (Exception e) {
            fail(e.getMessage());
        }

        // arch = (Architecture) osgiHelper.getServiceObject( org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), conf.getPid());
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        // arch = (Architecture) osgiHelper.getServiceObject( org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        fs = (FooService) bc.getService(ref);
        p = fs.fooProps();
        mes = p.getProperty("message");
        count = (Integer) p.get("count");
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        if (mes.equals("message")) {
            System.out.println("Warning, configuration not yet applied");
            assertEquals("Check count - W", 1, count);
        } else {
            assertEquals("Check message", "message2", mes);
View Full Code Here

Examples of org.apache.felix.ipojo.architecture.Architecture

            sr = refs[0];
        }
        assertNotNull("Check the check service availability", sr);

        ServiceReference sr_arch = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "HandlerTest-1");
        Architecture arch = (Architecture) osgiHelper.getRawServiceObject(sr_arch);

        System.out.println("===");
        Dumps.dumpArchitectures(context);
        assertEquals("Check instance validity - 0", arch.getInstanceDescription().getState(), ComponentInstance.VALID);

        CheckService cs = (CheckService) osgiHelper.getRawServiceObject(sr);
        Dictionary<String, Object> p = cs.getProps();
        Integer changes = (Integer) p.get("changes");
        assertNotNull("Check changes no null", changes);
        assertEquals("Changes changes 1 (" + changes + ")", changes.intValue(), 1);
        assertEquals("Check instance validity - 1", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
        cs.check();
        p = cs.getProps();
        changes = (Integer) p.get("changes");
        assertEquals("Changes changes 2 (" + changes + ")", changes.intValue(), 2);
        assertEquals("Check instance validity - 2", arch.getInstanceDescription().getState(), ComponentInstance.INVALID);
        cs.check();
        p = cs.getProps();
        changes = (Integer) p.get("changes");
        assertEquals("Changes changes 3 (" + changes + ")", changes.intValue(), 3);
        assertEquals("Check instance validity - 3", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
        cs.check();
        p = cs.getProps();
        changes = (Integer) p.get("changes");
        assertEquals("Changes changes 4 (" + changes + ")", changes.intValue(), 4);
        assertEquals("Check instance validity - 4", arch.getInstanceDescription().getState(), ComponentInstance.INVALID);
    }
View Full Code Here

Examples of org.apache.felix.ipojo.architecture.Architecture

            sr = refs[0];
        }
        assertNotNull("Check the check service availability", sr);

        ServiceReference sr_arch = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "HandlerTest-1");
        Architecture arch = (Architecture) osgiHelper.getRawServiceObject(sr_arch);
        assertEquals("Check validity", arch.getInstanceDescription().getState(), ComponentInstance.VALID);

        // Kill the handler factory
        HandlerManagerFactory f = (HandlerManagerFactory) ipojoHelper.getHandlerFactory("check");
        f.stop();

        boolean av = ipojoHelper.isServiceAvailableByName(CheckService.class.getName(), "HandlerTest-1");
        assertFalse("Check the check service unavailability", av);

        boolean av2 = ipojoHelper.isServiceAvailableByName(Architecture.class.getName(), "HandlerTest-1");
        assertFalse("Check the architecture unavailability", av2);

        // The instance is disposed, restart the handler
        f.start();

        Properties props = new Properties();
        props.put("instance.name", "HandlerTest-1");
        props.put("csh.simple", "simple");
        Properties p = new Properties();
        p.put("a", "a");
        p.put("b", "b");
        p.put("c", "c");
        props.put("csh.map", p);
        instance = ipojoHelper.createComponentInstance("HANDLER-HandlerTester", props);

        sr = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), "HandlerTest-1");
        assertNotNull("Check the check service availability - 2", sr);

        sr_arch = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "HandlerTest-1");
        arch = (Architecture) osgiHelper.getRawServiceObject(sr_arch);
        assertEquals("Check validity - 2", arch.getInstanceDescription().getState(), ComponentInstance.VALID);
    }
View Full Code Here

Examples of org.apache.felix.ipojo.architecture.Architecture

        Assert.assertNotNull(refs);
        Assert.assertEquals(2, refs.length);

        ServiceReference refv1 = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "mycons");
        Assert.assertNotNull(refv1);
        Architecture arch = (Architecture) osgiHelper.getRawServiceObject(refv1);

        HandlerDescription desc = arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:requires");
        Assert.assertNotNull(desc);

        DependencyHandlerDescription d = (DependencyHandlerDescription) desc;
        Assert.assertNotNull(d.getDependencies());
        Assert.assertEquals(1, d.getDependencies().length);
View Full Code Here

Examples of org.apache.felix.ipojo.architecture.Architecture

        Assert.assertNotNull(refs);
        Assert.assertEquals(2, refs.length);

        ServiceReference refv1 = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "mycons");
        Assert.assertNotNull(refv1);
        Architecture arch = (Architecture) osgiHelper.getRawServiceObject(refv1);

        HandlerDescription desc = arch.getInstanceDescription().getHandlerDescription("org.apache.felix.ipojo:requires");
        Assert.assertNotNull(desc);

        DependencyHandlerDescription d = (DependencyHandlerDescription) desc;
        Assert.assertNotNull(d.getDependencies());
        Assert.assertEquals(1, d.getDependencies().length);
View Full Code Here

Examples of org.apache.felix.ipojo.architecture.Architecture

    @Test
    public void testInstanceArchitecture() {
        // Version 1.0
        ServiceReference refv1 = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "instance-v1");
        Assert.assertNotNull(refv1);
        Architecture archv1 = (Architecture) osgiHelper.getRawServiceObject(refv1);

        String version = archv1.getInstanceDescription().getComponentDescription().getVersion();
        Assert.assertEquals("1.0", version);

        // Version 1.1
        ServiceReference refv11 = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "instance-v1.1");
        Assert.assertNotNull(refv11);
        Architecture archv11 = (Architecture) osgiHelper.getRawServiceObject(refv11);

        String version11 = archv11.getInstanceDescription().getComponentDescription().getVersion();
        Assert.assertEquals("1.1", version11);

        // No Version
        ServiceReference refany = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "instance-any");
        Assert.assertNotNull(refany);
        Architecture archany = (Architecture) osgiHelper.getRawServiceObject(refany);

        String any = archany.getInstanceDescription().getComponentDescription().getVersion();
        Assert.assertNotNull(any);

        // No version set in the factory, so no version.
        ServiceReference refmci = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), "MyComponentInstance");
        Assert.assertNotNull(refmci);
        Architecture archmcy = (Architecture) osgiHelper.getRawServiceObject(refmci);

        String mci = archmcy.getInstanceDescription().getComponentDescription().getVersion();
        Assert.assertNull(mci);

    }
View Full Code Here

Examples of org.apache.felix.ipojo.architecture.Architecture

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


        Architecture arch = (Architecture) osgiHelper.getServiceObject(org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");

        ServiceReference ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), conf.getPid());
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        // arch = (Architecture) osgiHelper.getServiceObject( org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        FooService fs = (FooService) bc.getService(ref);
        Properties p = fs.fooProps();
        String mes = p.getProperty("message");
        int count = ((Integer) p.get("count")).intValue();
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertEquals("Check message", "message", mes);
        assertEquals("Check count", 1, count);

        //Update
        Configuration configuration;
        try {
            configuration = admin.getConfiguration(msp, getTestBundle().getLocation());
            Dictionary prc = configuration.getProperties();
            if (prc == null) {
                prc = new Properties();
            }
            prc.put("message", "message2");
            configuration.update(prc);
            grace();
        } catch (Exception e) {
            fail(e.getMessage());
        }

        //  arch = (Architecture) osgiHelper.getServiceObject( org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), conf.getPid());
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        assertNotNull("FS availability", ref);

        // arch = (Architecture) osgiHelper.getServiceObject( org.apache.felix.ipojo.architecture.Architecture.class.getName(), "(architecture.instance=" + conf.getPid() + ")");
        fs = (FooService) bc.getService(ref);
        p = fs.fooProps();
        mes = p.getProperty("message");
        count = ((Integer) p.get("count")).intValue();
        assertEquals("Check 1 object", 1, ((PrimitiveInstanceDescription) arch.getInstanceDescription()).getCreatedObjects().length);
        if (mes.equals("message")) {
            System.out.println("Warning, configuration not yet applied");
            assertEquals("Check count - W", 1, count);
        } else {
            assertEquals("Check message", "message2", mes);
View Full Code Here

Examples of org.apache.felix.ipojo.architecture.Architecture

        ipojoHelper.createComponentInstance(factName, compName);

        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), compName);
        assertNotNull("Architecture not available", arch_ref);

        Architecture arch = (Architecture) osgiHelper.getRawServiceObject(arch_ref);
        InstanceDescription id = arch.getInstanceDescription();

        assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
        assertEquals("Check component type implementation class", id.getComponentDescription().getClassName(), "org.apache.felix.ipojo.runtime.core.components.FooProviderType1");

        HandlerDescription[] handlers = id.getHandlers();
View Full Code Here

Examples of org.apache.felix.ipojo.architecture.Architecture

        ipojoHelper.createComponentInstance(factName, props);

        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), compName);
        assertNotNull("Architecture not available", arch_ref);

        Architecture arch = (Architecture) osgiHelper.getRawServiceObject(arch_ref);
        InstanceDescription id = arch.getInstanceDescription();

        assertEquals("Check component instance name (" + id.getName() + ")", id.getName(), compName);
        assertEquals("Check component type implementation class", id.getComponentDescription().getClassName(), "org.apache.felix.ipojo.runtime.core.components.FooProviderType1");

        HandlerDescription[] handlers = id.getHandlers();
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.