Search in sources :

Example 91 with Attribute

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

the class ServiceProperty method getElement.

/**
 * Gets the 'property' element.
 * @return the element describing the current property.
 */
public Element getElement() {
    ensureValidity();
    Element element = new Element("property", "");
    if (m_name != null) {
        element.addAttribute(new Attribute("name", m_name));
    }
    if (m_type != null) {
        element.addAttribute(new Attribute("type", m_type));
    }
    if (m_value != null) {
        element.addAttribute(new Attribute("value", m_value));
    }
    if (m_field != null) {
        element.addAttribute(new Attribute("field", m_field));
    }
    if (m_mandatory) {
        element.addAttribute(new Attribute("mandatory", new Boolean(m_mandatory).toString()));
    }
    if (m_immutable) {
        element.addAttribute(new Attribute("immutable", new Boolean(m_immutable).toString()));
    }
    return element;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 92 with Attribute

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

the class CompositeComponentType method generateComponentMetadata.

/**
 * Generates the component description.
 * @return the component type description of
 * the current component type
 */
private Element generateComponentMetadata() {
    Element element = new Element("composite", "");
    if (m_name != null) {
        element.addAttribute(new Attribute("name", m_name));
    }
    if (m_version != null) {
        element.addAttribute(new Attribute("version", m_version));
    }
    if (!m_public) {
        element.addAttribute(new Attribute("public", "false"));
    }
    for (int i = 0; i < m_contained.size(); i++) {
        Instance inst = (Instance) m_contained.get(i);
        element.addElement(inst.getElement());
    }
    for (int i = 0; i < m_imported.size(); i++) {
        ImportedService inst = (ImportedService) m_imported.get(i);
        element.addElement(inst.getElement());
    }
    for (int i = 0; i < m_instantiated.size(); i++) {
        InstantiatedService inst = (InstantiatedService) m_instantiated.get(i);
        element.addElement(inst.getElement());
    }
    for (int i = 0; i < m_exported.size(); i++) {
        ExportedService inst = (ExportedService) m_exported.get(i);
        element.addElement(inst.getElement());
    }
    for (int i = 0; i < m_provided.size(); i++) {
        ProvidedService inst = (ProvidedService) m_provided.get(i);
        element.addElement(inst.getElement());
    }
    // External handlers
    for (int i = 0; i < m_handlers.size(); i++) {
        HandlerConfiguration hc = (HandlerConfiguration) m_handlers.get(i);
        element.addElement(hc.getElement());
    }
    return element;
}
Also used : HandlerConfiguration(org.apache.felix.ipojo.api.HandlerConfiguration) Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 93 with Attribute

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

the class ExportedService method getElement.

/**
 * Gets the exported service metadata.
 * @return the 'provides' element describing
 * the current dependency.
 */
public Element getElement() {
    ensureValidity();
    Element dep = new Element("provides", "");
    dep.addAttribute(new Attribute("action", "export"));
    dep.addAttribute(new Attribute("specification", m_specification));
    if (m_filter != null) {
        dep.addAttribute(new Attribute("filter", m_filter));
    }
    if (m_comparator != null) {
        dep.addAttribute(new Attribute("comparator", m_comparator));
    }
    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 94 with Attribute

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

the class Instance method addProperty.

/**
 * Adds a list property.
 * @param name property name
 * @param values the list
 * @return the current instance
 */
public Instance addProperty(String name, List values) {
    Element elem = new Element("property", "");
    elem.addAttribute(new Attribute("name", name));
    elem.addAttribute(new Attribute("type", "list"));
    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 95 with Attribute

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

the class Instance method addProperty.

/**
 * Adds a vector property.
 * @param name the property name
 * @param values the vector
 * @return the current instance
 */
public Instance 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)

Aggregations

Attribute (org.apache.felix.ipojo.metadata.Attribute)125 Element (org.apache.felix.ipojo.metadata.Element)109 Test (org.junit.Test)9 PojoMetadata (org.apache.felix.ipojo.parser.PojoMetadata)6 Iterator (java.util.Iterator)4 Enumeration (java.util.Enumeration)3 Map (java.util.Map)3 Set (java.util.Set)3 ServiceReference (org.osgi.framework.ServiceReference)3 List (java.util.List)2 Entry (java.util.Map.Entry)2 PropertyDescription (org.apache.felix.ipojo.architecture.PropertyDescription)2 FieldMetadata (org.apache.felix.ipojo.parser.FieldMetadata)2 MethodMetadata (org.apache.felix.ipojo.parser.MethodMetadata)2 Type (org.objectweb.asm.Type)2 Member (java.lang.reflect.Member)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1