Search in sources :

Example 66 with Attribute

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

the class JMXHandlerDescription method getHandlerInfo.

/**
 * Gets handler information.
 *
 * @return the handler information.
 */
public Element getHandlerInfo() {
    Element elem = super.getHandlerInfo();
    elem.addAttribute(new Attribute("registered", Boolean.toString(m_handler.isRegistered())));
    elem.addAttribute(new Attribute("objectName", m_handler.getUsedObjectName()));
    if (m_handler.isUsesMOSGi()) {
        String foundStr = null;
        if (m_handler.isMOSGiExists()) {
            foundStr = "found";
        } else {
            foundStr = "not_found";
        }
        elem.addAttribute(new Attribute("mosgi", foundStr));
    }
    return elem;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 67 with Attribute

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

the class TestDeclarationBuilderService method manipulation.

private Element manipulation() {
    Element manipulation = new Element("manipulation", null);
    manipulation.addAttribute(new Attribute("classname", "org.apache.felix.ipojo.runtime.core.test.components.GermanHelloService"));
    manipulation.addAttribute(new Attribute("super", "java.lang.Object"));
    Element itf = new Element("interface", null);
    itf.addAttribute(new Attribute("name", "org.apache.felix.ipojo.runtime.core.test.services.HelloService"));
    manipulation.addElement(itf);
    Element method = new Element("method", null);
    method.addAttribute(new Attribute("name", "hello"));
    method.addAttribute(new Attribute("return", "java.lang.String"));
    method.addAttribute(new Attribute("arguments", "{java.lang.String}"));
    method.addAttribute(new Attribute("names", "{name}"));
    manipulation.addElement(method);
    return manipulation;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 68 with Attribute

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

the class CheckServiceHandlerDescription method getHandlerInfo.

public Element getHandlerInfo() {
    Element elem = super.getHandlerInfo();
    elem.addAttribute(new Attribute("isValid", isValid() + ""));
    return elem;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 69 with Attribute

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

the class ComponentFactory method getRequiredHandlerList.

/**
 * Computes required handlers.
 * This method does not manipulate any non-immutable fields,
 * so does not need to be synchronized.
 * This method checks the {@link ComponentFactory#HANDLER_AUTO_PRIMITIVE}
 * system property to add the listed handlers to the required handler set.
 *
 * @return the required handler list.
 */
public List<RequiredHandler> getRequiredHandlerList() {
    List<RequiredHandler> list = new ArrayList<RequiredHandler>();
    Element[] elems = m_componentMetadata.getElements();
    for (Element current : elems) {
        if (!"manipulation".equals(current.getName())) {
            // Remove the manipulation element
            RequiredHandler req = new RequiredHandler(current.getName(), current.getNameSpace());
            if (!list.contains(req)) {
                list.add(req);
            }
        }
    }
    // Add architecture if architecture != 'false'
    String arch = m_componentMetadata.getAttribute("architecture");
    if (arch == null || arch.equalsIgnoreCase("true")) {
        list.add(new RequiredHandler("architecture", null));
    }
    // and does not specified that the component is not immediate.
    if (m_componentMetadata.getElements("provides") == null) {
        String imm = m_componentMetadata.getAttribute("immediate");
        if (imm == null) {
            // immediate not specified, set the immediate attribute to true
            getLogger().log(Logger.INFO, "The component type " + getFactoryName() + " becomes immediate");
            m_componentMetadata.addAttribute(new Attribute("immediate", "true"));
        }
    }
    // Add lifecycle callback if immediate = true
    RequiredHandler reqCallback = new RequiredHandler("callback", null);
    String imm = m_componentMetadata.getAttribute("immediate");
    if (!list.contains(reqCallback) && imm != null && imm.equalsIgnoreCase("true")) {
        list.add(reqCallback);
    }
    // Manage auto attached handler.
    String v = System.getProperty(HANDLER_AUTO_PRIMITIVE);
    if (v != null && v.length() != 0) {
        String[] hs = ParseUtils.split(v, ",");
        for (String h1 : hs) {
            String h = h1.trim();
            String[] segments = ParseUtils.split(h, ":");
            RequiredHandler rq = null;
            if (segments.length == 2) {
                // External handler
                rq = new RequiredHandler(segments[1], segments[0]);
            } else if (segments.length == 1) {
                // Core handler
                rq = new RequiredHandler(segments[1], null);
            }
            if (rq != null) {
                // Check it's not already contained
                if (!list.contains(rq)) {
                    list.add(rq);
                }
            }
        }
    }
    return list;
}
Also used : Attribute(org.apache.felix.ipojo.metadata.Attribute) Element(org.apache.felix.ipojo.metadata.Element)

Example 70 with Attribute

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

the class PrimitiveTypeDescription method getDescription.

/**
 * Adds the "implementation-class" attribute to the type description.
 *
 * @return the component type description.
 * @see org.apache.felix.ipojo.architecture.ComponentTypeDescription#getDescription()
 */
public Element getDescription() {
    Element elem = super.getDescription();
    elem.addAttribute(new Attribute("Implementation-Class", m_factory.getClassName()));
    /* Adding interfaces and super-classes of component into description */
    Element inheritance = new Element("Inherited", "");
    inheritance.addAttribute(new Attribute("Interfaces", m_interfaces.toString()));
    inheritance.addAttribute(new Attribute("SuperClasses", m_superClasses.toString()));
    elem.addElement(inheritance);
    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