Package org.apache.felix.ipojo.metadata

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


                    specs.append(spec);
                }
            }

            specs.append('}');
            provide.addAttribute(new Attribute("specifications", specs.toString())); // Add interface attribute to avoid checking in the configure method

            Element[] props = provide.getElements("property");
            for (int j = 0; props != null && j < props.length; j++) {
                String name = props[j].getAttribute("name");
                String value = props[j].getAttribute("value");
                String type = props[j].getAttribute("type");
                String field = props[j].getAttribute("field");


                // Get property name :
                if (field != null && name == null) {
                    name = field;
                }

                // Check type if not already set
                if (type == null) {
                    if (field == null) {
                        throw new ConfigurationException("The property " + name + " has neither type nor field.");
                    }
                    FieldMetadata fieldMeta = manipulation.getField(field);
                    if (fieldMeta == null) {
                        throw new ConfigurationException("A declared property was not found in the implementation class : " + field);
                    }
                    type = fieldMeta.getFieldType();
                    props[j].addAttribute(new Attribute("type", type));
                }

                // Is the property set to immutable
                boolean immutable = false;
                String imm = props[j].getAttribute("immutable");
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",
                "org.apache.felix.ipojo.handler.eventadmin.test.donut.Donut");
        m_subscriber.addAttribute(m_subscriberName);
        m_subscriber.addAttribute(m_subscriberCallback);
        m_subscriber.addAttribute(m_subscriberTopics);
        m_subscriber.addAttribute(m_subscriberDataKey);
View Full Code Here

            UnacceptableConfiguration {

        // Remove the name attribute of the publisher and replace with an
        // unexisting field name
        m_publisher.removeAttribute(m_publisherField);
        Attribute unexistingField = new Attribute("field", "m_unexistingField");
        m_publisher.addAttribute(unexistingField);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(bc, m_provider);
        try {
View Full Code Here

            UnacceptableConfiguration {

        // Remove the name attribute of the publisher and replace with an
        // bad typed field name
        m_publisher.removeAttribute(m_publisherField);
        Attribute badTypedField = new Attribute("field", "m_name");
        m_publisher.addAttribute(badTypedField);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(bc, m_provider);
        try {
View Full Code Here

            UnacceptableConfiguration {

        // Remove the topics attribute of the publisher and replace with a
        // malformed one
        m_publisher.removeAttribute(m_publisherTopics);
        Attribute malformedTopics = new Attribute("topics",
                "| |\\| \\/ /-\\ |_ | |)");
        m_publisher.addAttribute(malformedTopics);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(bc, m_provider);
View Full Code Here

            UnacceptableConfiguration {

        // Remove the topics attribute of the publisher and replace with a
        // malformed one
        m_publisher.removeAttribute(m_publisherTopics);
        Attribute malformedTopics = new Attribute("topics",
                "a/pattern/topic/*");
        m_publisher.addAttribute(malformedTopics);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(bc, m_provider);
View Full Code Here

            UnacceptableConfiguration {

        // Remove the topics attribute of the subscriber and replace with a
        // malformed one
        m_subscriber.removeAttribute(m_subscriberTopics);
        Attribute malformedTopics = new Attribute("topics",
                "| |\\| \\/ /-\\ |_ | |)");
        m_subscriber.addAttribute(malformedTopics);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(bc, m_consumer);
View Full Code Here

            UnacceptableConfiguration {

        // Remove the data-type attribute of the subscriber and replace with a
        // malformed one
        m_subscriber.removeAttribute(m_subscriberDataType);
        Attribute unknownType = new Attribute("data-type", "org.unknown.Clazz");
        m_subscriber.addAttribute(unknownType);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(bc, m_consumer);
        try {
View Full Code Here

            UnacceptableConfiguration {

        // Remove the data-type attribute of the subscriber and replace with a
        // malformed one
        m_subscriber.removeAttribute(m_subscriberDataType);
        Attribute unknownType = new Attribute("data-type", "java.lang.String");
        m_subscriber.addAttribute(unknownType);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(bc, m_consumer);
        try {
View Full Code Here

        }
        sb.append('<');
        sb.append(element.getName());
        Attribute[] attributes = element.getAttributes();
        for (int i = 0; i < attributes.length; i++) {
            Attribute attribute = attributes[i];
            sb.append(' ');
            sb.append(attribute.getName());
            sb.append('=');
            sb.append(attribute.getValue());
        }
        sb.append(">\n");
        // Children
        Element[] elements = element.getElements();
        for (int i = 0; i < elements.length; i++) {
View Full Code Here

TOP

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

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.