Search in sources :

Example 81 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class InstantiatedService method addProperty.

/**
 * Adds an array property.
 * @param name the property name
 * @param values the property value
 * @return the current instantiated sub-service
 */
public InstantiatedService addProperty(String name, String[] values) {
    Element elem = new Element("property", "");
    elem.addAttribute(new Attribute("name", name));
    elem.addAttribute(new Attribute("type", "array"));
    m_conf.add(elem);
    for (int i = 0; i < values.length; i++) {
        Object obj = values[i];
        Element e = new Element("property", "");
        elem.addElement(e);
        e.addAttribute(new Attribute("value", obj.toString()));
    }
    return this;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 82 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class InstantiatedService method addProperty.

/**
 * Adds a string property.
 * @param name the property name
 * @param value the property value
 * @return the current instantiated sub-service
 */
public InstantiatedService addProperty(String name, String value) {
    Element elem = new Element("property", "");
    m_conf.add(elem);
    elem.addAttribute(new Attribute("name", name));
    elem.addAttribute(new Attribute("value", value));
    return this;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 83 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class InstantiatedService method addProperty.

/**
 * Adds a vector property.
 * @param name the property name
 * @param values the property value
 * @return the current instantiated sub-service
 */
public InstantiatedService addProperty(String name, Vector values) {
    Element elem = new Element("property", "");
    elem.addAttribute(new Attribute("name", name));
    elem.addAttribute(new Attribute("type", "vector"));
    m_conf.add(elem);
    for (int i = 0; i < values.size(); i++) {
        Object obj = values.get(i);
        Element e = new Element("property", "");
        elem.addElement(e);
        if (obj instanceof String) {
            e.addAttribute(new Attribute("value", obj.toString()));
        } else {
            // TODO
            throw new UnsupportedOperationException("Complex properties are not supported yet");
        }
    }
    return this;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 84 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class ProvidedService method getElement.

/**
 * Gets the provided element.
 * @return the 'provides' element describing
 * the current provided service.
 */
public Element getElement() {
    ensureValidity();
    Element dep = new Element("provides", "");
    dep.addAttribute(new Attribute("action", "implement"));
    dep.addAttribute(new Attribute("specification", m_specification));
    for (int i = 0; i < m_delegation.size(); i++) {
        dep.addElement((Element) m_delegation.get(i));
    }
    return dep;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 85 with Element

use of org.apache.felix.ipojo.metadata.Element in project felix by apache.

the class ProvidedService method setDelegation.

/**
 * Sets the delegation policy of the given method.
 * @param method  the method name
 * @param policy the delegation policy
 * @return the current exported service.
 */
public ProvidedService setDelegation(String method, String policy) {
    Element element = new Element("delegation", "");
    element.addAttribute(new Attribute("method", method));
    element.addAttribute(new Attribute("policy", policy));
    m_delegation.add(element);
    return this;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Aggregations

Element (org.apache.felix.ipojo.metadata.Element)400 Test (org.junit.Test)126 Attribute (org.apache.felix.ipojo.metadata.Attribute)109 ConfigurationException (org.apache.felix.ipojo.ConfigurationException)22 ParseException (org.apache.felix.ipojo.parser.ParseException)14 PojoMetadata (org.apache.felix.ipojo.parser.PojoMetadata)14 ArrayList (java.util.ArrayList)13 Reporter (org.apache.felix.ipojo.manipulator.Reporter)12 FieldMetadata (org.apache.felix.ipojo.parser.FieldMetadata)12 Dictionary (java.util.Dictionary)10 Properties (java.util.Properties)10 MethodMetadata (org.apache.felix.ipojo.parser.MethodMetadata)10 BaseTest (org.ow2.chameleon.testing.helpers.BaseTest)10 PropertyDescription (org.apache.felix.ipojo.architecture.PropertyDescription)9 IOException (java.io.IOException)8 List (java.util.List)8 Before (org.junit.Before)7 Enumeration (java.util.Enumeration)6 ComponentWorkbench (org.apache.felix.ipojo.manipulator.metadata.annotation.ComponentWorkbench)6 FooService (org.apache.felix.ipojo.runtime.core.services.FooService)6