Search in sources :

Example 76 with Element

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

the class TemporalDependency method getElement.

/**
 * Gets the dependency metadata.
 * @return the 'requires' element describing
 * the current dependency.
 */
public Element getElement() {
    ensureValidity();
    Element dep = new Element("requires", "org.apache.felix.ipojo.handler.temporal");
    if (m_specification != null) {
        dep.addAttribute(new Attribute("specification", m_specification));
    }
    if (m_filter != null) {
        dep.addAttribute(new Attribute("filter", m_filter));
    }
    if (m_field != null) {
        dep.addAttribute(new Attribute("field", m_field));
    }
    if (m_onTimeout != null) {
        dep.addAttribute(new Attribute("omTimeout", m_onTimeout));
    }
    if (m_timeout != null) {
        dep.addAttribute(new Attribute("timeout", m_timeout));
    }
    if (m_proxy) {
        dep.addAttribute(new Attribute("proxy", "true"));
    }
    return dep;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 77 with Element

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

the class ImportedService method getElement.

/**
 * Gets the dependency metadata.
 * @return the 'requires' element describing
 * the current dependency.
 */
public Element getElement() {
    ensureValidity();
    Element dep = new Element("subservice", "");
    dep.addAttribute(new Attribute("action", "import"));
    dep.addAttribute(new Attribute("specification", m_specification));
    dep.addAttribute(new Attribute("scope", m_scope));
    if (m_filter != null) {
        dep.addAttribute(new Attribute("filter", m_filter));
    }
    if (m_comparator != null) {
        dep.addAttribute(new Attribute("comparator", m_comparator));
    }
    if (m_id != null) {
        dep.addAttribute(new Attribute("id", m_id));
    }
    if (m_optional) {
        dep.addAttribute(new Attribute("optional", "true"));
    }
    if (m_aggregate) {
        dep.addAttribute(new Attribute("aggregate", "true"));
    }
    if (m_policy == DependencyModel.DYNAMIC_BINDING_POLICY) {
        dep.addAttribute(new Attribute("policy", "dynamic"));
    } else if (m_policy == DependencyModel.STATIC_BINDING_POLICY) {
        dep.addAttribute(new Attribute("policy", "static"));
    } else if (m_policy == DependencyModel.DYNAMIC_PRIORITY_BINDING_POLICY) {
        dep.addAttribute(new Attribute("policy", "dynamic-priority"));
    }
    return dep;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 78 with Element

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

the class Instance method addProperty.

/**
 * Adds the string property.
 * @param name property name
 * @param value property value
 * @return the current instance
 */
public Instance 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 79 with Element

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

the class Instance method getElement.

/**
 * Gets the instance description in the Element-Attribute form.
 * @return the root Element of the instance description
 * @see org.apache.felix.ipojo.api.HandlerConfiguration#getElement()
 */
public Element getElement() {
    ensureValidity();
    Element instance = new Element("instance", "");
    instance.addAttribute(new Attribute("component", m_type));
    for (int i = 0; i < m_conf.size(); i++) {
        Element elem = (Element) m_conf.get(i);
        instance.addElement(elem);
    }
    return instance;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 80 with Element

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

the class Instance method addProperty.

/**
 * Adds a map property.
 * @param name the property name
 * @param values the map
 * @return the current instance
 */
public Instance addProperty(String name, Map values) {
    Element elem = new Element("property", "");
    elem.addAttribute(new Attribute("name", name));
    elem.addAttribute(new Attribute("type", "map"));
    m_conf.add(elem);
    Set entries = values.entrySet();
    Iterator it = entries.iterator();
    while (it.hasNext()) {
        Map.Entry entry = (Entry) it.next();
        Element e = new Element("property", "");
        elem.addElement(e);
        String n = (String) entry.getKey();
        Object v = entry.getValue();
        if (v instanceof String) {
            e.addAttribute(new Attribute("name", n));
            e.addAttribute(new Attribute("value", v.toString()));
        } else {
            // TODO
            throw new UnsupportedOperationException("Complex properties are not supported yet");
        }
    }
    return this;
}
Also used : Entry(java.util.Map.Entry) Entry(java.util.Map.Entry) Set(java.util.Set) Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element) Iterator(java.util.Iterator) Map(java.util.Map)

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