Search in sources :

Example 71 with Attribute

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

the class HandlerDescription method getHandlerInfo.

/**
 * Gets handler information.
 * This represent the actual state of the handler.
 * @return the handler information.
 */
public Element getHandlerInfo() {
    Element elem = new Element("Handler", "");
    elem.addAttribute(new Attribute("name", m_handlerName));
    if (isValid()) {
        elem.addAttribute(new Attribute("state", "valid"));
    } else {
        elem.addAttribute(new Attribute("state", "invalid"));
    }
    return elem;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 72 with Attribute

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

the class FieldPropertyVisitor method visitEnd.

/**
 * End of the annotation.
 * Create a "property" element
 * @see org.objectweb.asm.AnnotationVisitor#visitEnd()
 */
public void visitEnd() {
    if (m_field != null && m_name == null) {
        m_name = m_field;
    }
    Element[] props = m_parent.getElements("property");
    Element prop = null;
    for (int i = 0; prop == null && props != null && i < props.length; i++) {
        String name = props[i].getAttribute("name");
        if (name != null && name.equals(m_name)) {
            prop = props[i];
        }
    }
    if (prop == null) {
        prop = new Element("property", "");
        m_parent.addElement(prop);
        if (m_name != null) {
            prop.addAttribute(new Attribute("name", m_name));
        }
    }
    if (m_field != null) {
        prop.addAttribute(new Attribute("field", m_field));
    }
    if (m_type != null) {
        prop.addAttribute(new Attribute("type", m_type));
    }
    if (m_value != null) {
        prop.addAttribute(new Attribute("value", m_value));
    }
    if (m_mandatory != null) {
        prop.addAttribute(new Attribute("mandatory", m_mandatory));
    }
    if (m_immutable != null) {
        prop.addAttribute(new Attribute("immutable", m_immutable));
    }
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 73 with Attribute

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

the class HandlerVisitor method visitEnd.

/**
 * End of the visit.
 * Append to the "component" element computed attribute.
 *
 * @see org.objectweb.asm.AnnotationVisitor#visitEnd()
 */
public void visitEnd() {
    String classname = workbench.getType().getClassName();
    handler.addAttribute(new Attribute("classname", classname));
    if (workbench.getRoot() == null) {
        workbench.setRoot(handler);
    } else {
        // Error case: 2 component type's annotations (@Component and @Handler for example) on the same class
        reporter.error("Multiple 'component type' annotations on the class '{%s}'.", classname);
        reporter.warn("@Handler will be ignored.");
    }
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute)

Example 74 with Attribute

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

the class LifecycleVisitor method visitEnd.

@Override
public void visitEnd() {
    Element cb = new Element("callback", "");
    cb.addAttribute(new Attribute("transition", transition.name().toLowerCase()));
    cb.addAttribute(new Attribute("method", name));
    workbench.getElements().put(cb, null);
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 75 with Attribute

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

the class MethodPropertyVisitor method visitEndCommon.

protected Element visitEndCommon() {
    m_method = computeEffectiveMethodName(m_method);
    // If neither name nor id is provided, try to extract the name
    if (m_name == null && m_id == null && m_method.startsWith("set")) {
        m_name = m_method.substring("set".length());
        m_id = m_name;
    // Else align the two values
    } else if (m_name != null && m_id == null) {
        m_id = m_name;
    } else if (m_id != null && m_name == null) {
        m_name = m_id;
    }
    Element prop = getPropertyElement();
    if (m_value != null) {
        prop.addAttribute(new Attribute("value", m_value));
    }
    if (m_mandatory != null) {
        prop.addAttribute(new Attribute("mandatory", m_mandatory));
    }
    if (m_immutable != null) {
        prop.addAttribute(new Attribute("immutable", m_immutable));
    }
    return prop;
}
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