Package org.apache.felix.ipojo.metadata

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


     * 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());
        }
View Full Code Here


     */
    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;
    }
View Full Code Here

     * @return the component type description of
     * the current component type
     */
    private Element generateComponentMetadata() {
        Element element = new Element("component", "");
        element.addAttribute(new Attribute("classname", m_classname));
        if (m_name != null) {
            element.addAttribute(new Attribute("name", m_name));
        }
        if (m_version != null) {
            element.addAttribute(new Attribute("version", m_version));
        }
        if (m_factoryMethod != null) {
            element.addAttribute(new Attribute("factory-method", m_factoryMethod));
        }
        if (! m_public) {
            element.addAttribute(new Attribute("public", "false"));
        }
        if (m_immediate) {
            element.addAttribute(new Attribute("immediate", "true"));
        }
        for (Service svc : m_services) {
            element.addElement(svc.getElement());
        }
        for (Dependency dep : m_dependencies) {
            element.addElement(dep.getElement());
        }
        for (TemporalDependency dep : m_temporals) {
            element.addElement(dep.getElement());
        }
        if (m_validate != null) {
            Element callback = new Element("callback", "");
            callback.addAttribute(new Attribute("transition", "validate"));
            callback.addAttribute(new Attribute("method", m_validate));
            element.addElement(callback);
        }
        if (m_invalidate != null) {
            Element callback = new Element("callback", "");
            callback.addAttribute(new Attribute("transition", "invalidate"));
            callback.addAttribute(new Attribute("method", m_invalidate));
            element.addElement(callback);
        }

        // Properties
        // First determine if we need the properties element
        if (m_propagation || m_msPID != null || ! m_properties.isEmpty()) {
            Element properties = new Element("properties", "");
            if (m_propagation) {
                properties.addAttribute(new Attribute("propagation", "true"));
            }
            if (m_msPID != null) {
                properties.addAttribute(new Attribute("pid", m_msPID));
            }
            if (m_updated != null) {
                properties.addAttribute(new Attribute("updated", m_updated));
            }
            for (Property prop : m_properties) {
                properties.addElement(prop.getElement());
            }
            element.addElement(properties);
View Full Code Here

     * @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;
    }
View Full Code Here

     * @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");
            }
View Full Code Here

     * @param values the array
     * @return the current instance
     */
    public Instance 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;
    }
View Full Code Here

     * @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");
            }
View Full Code Here

     * @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");
            }
View Full Code Here

     * @param values the dictionary
     * @return the current instance
     */
    public Instance addProperty(String name, Dictionary values) {
        Element elem = new Element("property", "");
        elem.addAttribute(new Attribute("name", name));
        elem.addAttribute(new Attribute("type", "dictionary"));

        m_conf.add(elem);
        Enumeration e = values.keys();
        while (e.hasMoreElements()) {
            Element el = new Element("property", "");
            elem.addElement(el);

            String n = (String) e.nextElement();
            Object v = values.get(n);
            if (v instanceof String) {
                el.addAttribute(new Attribute("name", n));
                el.addAttribute(new Attribute("value", v.toString()));
            } else {
                // TODO
                throw new UnsupportedOperationException(
                        "Complex properties are not supported yet");
            }
View Full Code Here

     * @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;
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.