Search in sources :

Example 81 with Attribute

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

the class AbstractBindVisitor method createRequiresElement.

protected Element createRequiresElement() {
    Element requires;
    requires = new Element("requires", "");
    if (m_specification != null) {
        requires.addAttribute(new Attribute("specification", m_specification));
    }
    if (m_aggregate != null) {
        requires.addAttribute(new Attribute("aggregate", m_aggregate));
    }
    if (m_filter != null) {
        requires.addAttribute(new Attribute("filter", m_filter));
    }
    if (m_optional != null) {
        requires.addAttribute(new Attribute("optional", m_optional));
    }
    if (m_policy != null) {
        requires.addAttribute(new Attribute("policy", m_policy));
    }
    if (m_id != null) {
        requires.addAttribute(new Attribute("id", m_id));
    }
    if (m_comparator != null) {
        requires.addAttribute(new Attribute("comparator", m_comparator));
    }
    if (m_from != null) {
        requires.addAttribute(new Attribute("from", m_from));
    }
    if (m_proxy != null) {
        requires.addAttribute(new Attribute("proxy", m_proxy));
    }
    return requires;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 82 with Attribute

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

the class ParameterBindVisitor method visitEnd.

/**
 * End of the visit.
 * Create or append the requirement info to a created or already existing "requires" element.
 *
 * @see org.objectweb.asm.commons.EmptyVisitor#visitEnd()
 */
public void visitEnd() {
    if (m_id == null) {
        m_id = Integer.toString(m_index);
    }
    Element requires = getRequiresElement();
    // Specific for parameters
    requires.addAttribute(new Attribute("constructor-parameter", Integer.toString(m_index)));
    workbench.getIds().put(m_id, requires);
    workbench.getElements().put(requires, null);
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 83 with Attribute

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

the class ParameterGenericVisitor method visitEnd.

@Override
public void visitEnd() {
    super.visitEnd();
    String type = Type.getArgumentTypes(node.desc)[index].getClassName();
    // TODO Is the 'index' attribute required ?
    element.addAttribute(new Attribute("index", Integer.toString(index)));
    element.addAttribute(new Attribute("type", type));
    element.addAttribute(new Attribute("constructor-parameter", Integer.toString(index)));
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute)

Example 84 with Attribute

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

the class XMLMetadataParser method startElement.

/**
 * Start an element.
 * @param namespaceURI : element namespace.
 * @param localName : local element.
 * @param qName : qualified name.
 * @param atts : attribute
 * @throws SAXException : occurs if the element cannot be parsed correctly.
 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
 */
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
    String namespace = namespaceURI;
    if (namespaceURI != null && (namespaceURI.equalsIgnoreCase("org.apache.felix.ipojo") || namespaceURI.equalsIgnoreCase("org.apache.felix.ipojo.composite"))) {
        // Remove the 'org.apache.felix.ipojo' namespace
        namespace = null;
    }
    Element elem = new Element(localName, namespace);
    for (int i = 0; i < atts.getLength(); i++) {
        String name = (String) atts.getLocalName(i);
        String ns = (String) atts.getURI(i);
        String value = (String) atts.getValue(i);
        Attribute att = new Attribute(name, ns, value);
        elem.addAttribute(att);
    }
    addElement(elem);
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 85 with Attribute

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

the class MethodDescriptor method getElement.

/**
 * Compute method manipulation metadata.
 * @return the element containing metadata about this method.
 */
public Element getElement() {
    Element method = new Element("method", "");
    method.addAttribute(new Attribute("name", m_name));
    // Add return
    if (!m_returnType.equals("void")) {
        method.addAttribute(new Attribute("return", m_returnType));
    }
    // Add arguments
    if (m_arguments.length > 0) {
        StringBuilder args = new StringBuilder("{");
        StringBuilder names = new StringBuilder("{");
        args.append(m_arguments[0]);
        if (m_locals.containsKey(1)) {
            // index +1 as the 0 is this
            names.append(m_locals.get(1).name);
        }
        for (int i = 1; i < m_arguments.length; i++) {
            args.append(",").append(m_arguments[i]);
            if (m_locals.containsKey(i + 1)) {
                names.append(",").append(m_locals.get(i + 1).name);
            }
        }
        args.append("}");
        names.append("}");
        method.addAttribute(new Attribute("arguments", args.toString()));
        method.addAttribute(new Attribute("names", names.toString()));
    }
    return method;
}
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