Search in sources :

Example 56 with Attribute

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

the class Manipulator method getManipulationMetadata.

/**
 * Compute component type manipulation metadata.
 * @return the manipulation metadata of the class.
 */
public Element getManipulationMetadata() {
    Element elem = new Element("Manipulation", "");
    elem.addAttribute(new Attribute("className", toQualifiedName(m_className)));
    if (m_superClass != null) {
        elem.addAttribute(new Attribute("super", m_superClass));
    }
    for (String m_interface : m_interfaces) {
        Element itf = new Element("Interface", "");
        Attribute att = new Attribute("name", m_interface);
        itf.addAttribute(att);
        elem.addElement(itf);
    }
    for (Map.Entry<String, String> f : m_fields.entrySet()) {
        Element field = new Element("Field", "");
        Attribute attName = new Attribute("name", f.getKey());
        Attribute attType = new Attribute("type", f.getValue());
        field.addAttribute(attName);
        field.addAttribute(attType);
        elem.addElement(field);
    }
    for (MethodDescriptor method : m_methods) {
        elem.addElement(method.getElement());
    }
    for (Map.Entry<String, List<MethodDescriptor>> inner : m_inners.entrySet()) {
        Element element = new Element("Inner", "");
        Attribute name = new Attribute("name", extractInnerClassName(toQualifiedName(inner.getKey())));
        element.addAttribute(name);
        for (MethodDescriptor method : inner.getValue()) {
            element.addElement(method.getElement());
        }
        elem.addElement(element);
    }
    return elem;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 57 with Attribute

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

the class ClassMetadataCollector method visitEnd.

/**
 * End of the visit : compute final elements.
 *
 * @see org.objectweb.asm.ClassVisitor#visitEnd()
 */
@Override
public void visitEnd() {
    // Only process real class (no annotations, no interfaces)
    if (!(is(Opcodes.ACC_ANNOTATION) || is(Opcodes.ACC_INTERFACE) || is(Opcodes.ACC_ABSTRACT))) {
        if (workbench.getRoot() == null) {
            if (workbench.ignore()) {
                // Ignore this class.
                return;
            }
            if (!workbench.getElements().isEmpty()) {
                // There are other annotation's contribution on this type (additional handler declaration/configuration)
                // That means that there is a missing 'component type' annotation
                reporter.warn("Class %s has not been marked as a component type (no @Component, @Handler, " + "...). It will be ignored by the iPOJO manipulator.", workbench.getType().getClassName());
                return;
            }
            // else: no root and no elements
            return;
        }
        componentMetadata = workbench.build();
        instanceMetadata = workbench.getInstance();
        // of the instance (https://issues.apache.org/jira/browse/FELIX-4052).
        if (componentMetadata != null && componentMetadata.containsAttribute("name") && instanceMetadata != null) {
            // Update the component attribute
            instanceMetadata.addAttribute(new Attribute("component", componentMetadata.getAttribute("name")));
        }
    }
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute)

Example 58 with Attribute

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

the class TestBadFactories method getElementHandlerFactoryWithNoClassName.

private Element getElementHandlerFactoryWithNoClassName() {
    Element elem = new Element("handler", "");
    elem.addAttribute(new Attribute("name", "noclassname"));
    return elem;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 59 with Attribute

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

the class TestBadLFCCallback method getBadTransition.

private Element getBadTransition() {
    Element elem = new Element("component", "");
    elem.addAttribute(new Attribute("classname", clazz));
    Element callback = new Element("callback", "");
    callback.addAttribute(new Attribute("method", "start"));
    callback.addAttribute(new Attribute("transition", "validate_"));
    elem.addElement(callback);
    elem.addElement(manipulation);
    return elem;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 60 with Attribute

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

the class TestBadLFCCallback method getNoTransition.

private Element getNoTransition() {
    Element elem = new Element("component", "");
    elem.addAttribute(new Attribute("classname", clazz));
    Element callback = new Element("callback", "");
    callback.addAttribute(new Attribute("method", "start"));
    elem.addElement(callback);
    elem.addElement(manipulation);
    return elem;
}
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