Package org.apache.felix.ipojo.metadata

Examples of org.apache.felix.ipojo.metadata.Element


    /**
     * Gets the handler info.
     * @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
     */
    public Element getHandlerInfo() {
        Element root = super.getHandlerInfo();
        if (m_subscribersDescriptions != null) {
            for (int i = 0; i < m_subscribersDescriptions.length; i++) {
                Element description = m_subscribersDescriptions[i];
                root.addElement(description);
            }
        }
        return root;
    }
View Full Code Here


            try {
                Class spec = getInstanceManager().getFactory().loadClass(specName);
                Field specField = spec.getField("specification");
                Object specif = specField.get(null);
                if (specif instanceof String) {
                    Element specification = ManifestMetadataParser.parse((String) specif);
                    Element[] deps = specification.getElements("requires");
                    for (int j = 0; deps != null && j < deps.length; j++) {
                        Dependency dep = getAttachedDependency(deps[j]);
                        if (dep != null) {
                            // Fix service-level dependency flag
                            dep.setServiceLevelDependency();
View Full Code Here

        /**
         * Initialize the standard publishing component (based on the
         * asynchronous donut provider).
         */
        m_provider = new Element("component", "");
        m_provider.addAttribute(new Attribute("className",
                "org.apache.felix.ipojo.handler.eventadmin.test.donut.DonutProviderImpl"));
        m_provider.addAttribute(new Attribute("name",
                "standard donut provider for bad tests"));

        // The provided service of the publisher
        Element providesDonutProvider = new Element("provides", "");
        providesDonutProvider.addAttribute(new Attribute("interface",
                "org.apache.felix.ipojo.handler.eventadmin.test.donut.DonutProvider"));
        Element providesDonutProviderProperty = new Element("property", "");
        providesDonutProviderProperty
                .addAttribute(new Attribute("name", "name"));
        providesDonutProviderProperty.addAttribute(new Attribute("field",
                "m_name"));
        providesDonutProviderProperty.addAttribute(new Attribute("value",
                "Unknown donut vendor"));
        providesDonutProvider.addElement(providesDonutProviderProperty);
        m_provider.addElement(providesDonutProvider);

        // The event publisher, corresponding to the following description :
        // <ev:publisher name="donut-publisher" field="m_publisher"
        // topics="food/donuts" data-key="food" synchronous="false"/>
        m_publisher = new Element("publisher", NAMESPACE);
        m_publisherName = new Attribute("name", "donut-publisher");
        m_publisherField = new Attribute("field", "m_publisher");
        m_publisherTopics = new Attribute("topics", "food/donuts");
        m_publisherDataKey = new Attribute("data-key", "food");
        m_publisherSynchronous = new Attribute("synchronous", "false");
        m_publisher.addAttribute(m_publisherName);
        m_publisher.addAttribute(m_publisherField);
        m_publisher.addAttribute(m_publisherTopics);
        m_publisher.addAttribute(m_publisherDataKey);
        m_publisher.addAttribute(m_publisherSynchronous);
        m_provider.addElement(m_publisher);

        m_provider.addElement(getManipulationForComponent("donut-provider"));

        /**
         * Initialize the standard subscribing component (based on the donut
         * consumer).
         */
        m_consumer = new Element("component", "");
        m_consumer.addAttribute(new Attribute("className",
                "org.apache.felix.ipojo.handler.eventadmin.test.donut.DonutConsumerImpl"));
        m_consumer.addAttribute(new Attribute("name",
                "standard donut consumer for bad tests"));

        // The provided service of the publisher
        Element providesDonutConsumer = new Element("provides", "");
        providesDonutConsumer.addAttribute(new Attribute("interface",
                "org.apache.felix.ipojo.handler.eventadmin.test.donut.DonutConsumer"));
        Element providesDonutConsumerNameProperty = new Element("property", "");
        providesDonutConsumerNameProperty.addAttribute(new Attribute("name",
                "name"));
        providesDonutConsumerNameProperty.addAttribute(new Attribute("field",
                "m_name"));
        providesDonutConsumerNameProperty.addAttribute(new Attribute("value",
                "Unknown donut consumer"));
        providesDonutConsumer.addElement(providesDonutConsumerNameProperty);
        Element providesDonutConsumerSlowProperty = new Element("property", "");
        providesDonutConsumerSlowProperty.addAttribute(new Attribute("name",
                "slow"));
        providesDonutConsumerSlowProperty.addAttribute(new Attribute("field",
                "m_isSlow"));
        providesDonutConsumerSlowProperty.addAttribute(new Attribute("value",
                "false"));
        providesDonutConsumer.addElement(providesDonutConsumerSlowProperty);
        m_consumer.addElement(providesDonutConsumer);

        // The event publisher, corresponding to the following description :
        // <ev:subscriber name="donut-subscriber" callback="receiveDonut"
        // topics="food/donuts" data-key="food"
        // data-type="org.apache.felix.ipojo.handler.eventadmin.test.donut.Donut"/>
        m_subscriber = new Element("subscriber", NAMESPACE);
        m_subscriberName = new Attribute("name", "donut-subscriber");
        m_subscriberCallback = new Attribute("callback", "receiveDonut");
        m_subscriberTopics = new Attribute("topics", "food/donuts");
        m_subscriberDataKey = new Attribute("data-key", "food");
        m_subscriberDataType = new Attribute("data-type",
View Full Code Here

    /**
     * Gets the handler description.
     * @see org.apache.felix.ipojo.architecture.HandlerDescription#getHandlerInfo()
     */
    public Element getHandlerInfo() {
        Element root = super.getHandlerInfo();
        for (int i = 0; i < m_publishersDescriptions.size(); i++) {
            PublisherDescription p = (PublisherDescription) m_publishersDescriptions.get(i);
            Element publisher = new Element("Publisher", "");
            publisher.addAttribute(new Attribute("name", p.getName()));
            publisher.addAttribute(new Attribute("synchronous", String.valueOf(p.isSynchronous())));
            publisher.addAttribute(new Attribute("data_key", p.getDataKey()));
            Element topics = new Element("Topics", "");
            if (p.getTopics() != null) {
                for (int j = 0; j < p.getTopics().length; j++) {
                    String topic = p.getTopics()[j];
                    Element e_topic = new Element("topic","");
                    topics.addElement(e_topic);
                    e_topic.addAttribute(new Attribute("name",topic));
                }
            }
            publisher.addElement(topics);
            root.addElement(publisher);
        }
View Full Code Here

public class TestManipulationMetadata extends BaseTest {

    @Test
    public void testGetMetadata() {
        String header = (String) getTestBundle().getHeaders().get("iPOJO-Components");
        Element elem = null;
        try {
            elem = ManifestMetadataParser.parseHeaderMetadata(header);
        } catch (ParseException e) {
            fail("Parse Exception when parsing iPOJO-Component");
        }

        assertNotNull("Check elem not null", elem);


        Element manip = getManipulationForComponent(elem, "ManipulationMetadata-FooProviderType-1");
        assertNotNull("Check manipulation metadata not null for " + "FooProviderType-1", manip);
    }
View Full Code Here

    }

    @Test
    public void testInterface() {
        String comp_name = "ManipulationMetadata-FooProviderType-1";
        Element manip = getManipulationForComponent(comp_name);
        Element[] itf = manip.getElements("Interface");
        assertEquals("Check interfaces number", itf.length, 1);
        assertEquals("Check itf name", itf[0].getAttribute("name"), FooService.class.getName());
    }
View Full Code Here

    }

    @Test
    public void testInterfaces() {
        String comp_name = "ManipulationMetadata-FooBarProviderType-1";
        Element manip = getManipulationForComponent(comp_name);
        Element[] itf = manip.getElements("Interface");
        assertEquals("Check interfaces number", itf.length, 2);
        assertEquals("Check itf name", itf[0].getAttribute("name"), FooService.class.getName());
        assertEquals("Check itf name", itf[1].getAttribute("name"), BarService.class.getName());
    }
View Full Code Here

    }

    @Test
    public void testFields() {
        String comp_name = "ManipulationMetadata-FooProviderType-Dyn";
        Element manip = getManipulationForComponent(comp_name);
        Element[] fields = manip.getElements("field");
        assertEquals("Check field count " + fields.length, fields.length, 5);
        /*
        private int intProp;
    private String strProp;
    private String[] strAProp;
    private int[] intAProp;
    private boolean boolProp;
     */

        Element field;

        field = getFieldFromName(manip, "intProp");
        assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "intProp");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int");

        field = getFieldFromName(manip, "strProp");
        assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "strProp");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "java.lang.String");

        field = getFieldFromName(manip, "strAProp");
        assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "strAProp");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "java.lang.String[]");

        field = getFieldFromName(manip, "intAProp");
        assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "intAProp");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int[]");

        field = getFieldFromName(manip, "boolProp");
        assertEquals("Check field name : " + field.getAttribute("name"), field.getAttribute("name"), "boolProp");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean");
    }
View Full Code Here

    }

    @Test
    public void testPrimitivesFields() {
        String comp_name = "ManipulationMetadata-PrimitiveManipulationTester";
        Element manip = getManipulationForComponent(comp_name);
        Element[] fields = manip.getElements("Field");
        assertEquals("Check field count", fields.length, 16);
    /*
    byte b = 1;
    short s = 1;
    int i = 1;
    long l = 1;
    double d = 1.1;
    float f = 1.1f;
    char c = 'a';
    boolean bool = false;
    byte[] bs = new byte[] {0,1,2};
    short[] ss = new short[] {0,1,2};
    int[] is = new int[] {0,1,2};
    long[] ls = new long[] {0,1,2};
    double[] ds = new double[] {0.0, 1.1, 2.2};
    float[] fs = new float[] {0.0f, 1.1f, 2.2f};
    char[] cs = new char[] {'a', 'b', 'c'};
    boolean[] bools = new boolean[] {false, true, false};
     */
        Element field;

        field = getFieldFromName(manip, "b");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte");
        field = getFieldFromName(manip, "s");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short");
        field = getFieldFromName(manip, "i");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int");
        field = getFieldFromName(manip, "l");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long");
        field = getFieldFromName(manip, "d");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double");
        field = getFieldFromName(manip, "f");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float");
        field = getFieldFromName(manip, "c");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char");
        field = getFieldFromName(manip, "bool");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean");

        field = getFieldFromName(manip, "bs");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "byte[]");
        field = getFieldFromName(manip, "ss");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "short[]");
        field = getFieldFromName(manip, "is");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "int[]");
        field = getFieldFromName(manip, "ls");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "long[]");
        field = getFieldFromName(manip, "ds");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "double[]");
        field = getFieldFromName(manip, "fs");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "float[]");
        field = getFieldFromName(manip, "cs");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "char[]");
        field = getFieldFromName(manip, "bools");
        assertEquals("Check field type : " + field.getAttribute("name"), field.getAttribute("type"), "boolean[]");
    }
View Full Code Here

    }

    @Test
    public void testNoArgMethod() {
        String comp_name = "ManipulationMetadata-SimpleMultipleCheckServiceProvider";
        Element manip = getManipulationForComponent(comp_name);
        Element method = getMethodFromName(manip, "check");
        assertFalse("Check no args", method.containsAttribute("arguments"));
        assertEquals("Check return", method.getAttribute("return"), "boolean");
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.metadata.Element

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.