Search in sources :

Example 1 with MutableMapMetadata

use of org.apache.aries.blueprint.mutable.MutableMapMetadata in project aries by apache.

the class ExtNamespaceHandler method parseDefaultProperties.

private Metadata parseDefaultProperties(ParserContext context, MutableBeanMetadata enclosingComponent, Element element) {
    MutableMapMetadata props = context.createMetadata(MutableMapMetadata.class);
    NodeList nl = element.getChildNodes();
    for (int i = 0; i < nl.getLength(); i++) {
        Node node = nl.item(i);
        if (node instanceof Element) {
            Element e = (Element) node;
            if (isExtNamespace(e.getNamespaceURI())) {
                if (nodeNameEquals(e, PROPERTY_ELEMENT)) {
                    BeanProperty prop = context.parseElement(BeanProperty.class, enclosingComponent, e);
                    props.addEntry(createValue(context, prop.getName(), String.class.getName()), prop.getValue());
                }
            }
        }
    }
    return props;
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata) BeanProperty(org.osgi.service.blueprint.reflect.BeanProperty)

Example 2 with MutableMapMetadata

use of org.apache.aries.blueprint.mutable.MutableMapMetadata in project aries by apache.

the class CmNamespaceHandler method parseDefaultProperties.

private Metadata parseDefaultProperties(ParserContext context, MutableBeanMetadata enclosingComponent, Element element) {
    MutableMapMetadata props = context.createMetadata(MutableMapMetadata.class);
    NodeList nl = element.getChildNodes();
    for (int i = 0; i < nl.getLength(); i++) {
        Node node = nl.item(i);
        if (node instanceof Element) {
            Element e = (Element) node;
            if (isCmNamespace(e.getNamespaceURI())) {
                if (nodeNameEquals(e, PROPERTY_ELEMENT)) {
                    BeanProperty prop = context.parseElement(BeanProperty.class, enclosingComponent, e);
                    props.addEntry(createValue(context, prop.getName(), String.class.getName()), prop.getValue());
                }
            }
        }
    }
    return props;
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata) BeanProperty(org.osgi.service.blueprint.reflect.BeanProperty)

Example 3 with MutableMapMetadata

use of org.apache.aries.blueprint.mutable.MutableMapMetadata in project aries by apache.

the class AbstractPropertyPlaceholder method processMapMetadata.

protected Metadata processMapMetadata(MapMetadata metadata) {
    List<MapEntry> entries = new ArrayList<MapEntry>(metadata.getEntries());
    if (!!!entries.isEmpty()) {
        try {
            if (metadata instanceof MutableMapMetadata) {
                processingStack.add("Map->");
                MutableMapMetadata mmm = (MutableMapMetadata) metadata;
                for (MapEntry entry : entries) {
                    mmm.removeEntry(entry);
                }
                for (MapEntry entry : processMapEntries(entries)) {
                    mmm.addEntry(entry);
                }
            } else {
                printWarning(metadata, "Map");
                processingStack.add("Map->");
                processMapEntries(entries);
            }
        } finally {
            processingStack.removeLast();
        }
    }
    return metadata;
}
Also used : MutableMapEntry(org.apache.aries.blueprint.mutable.MutableMapEntry) MapEntry(org.osgi.service.blueprint.reflect.MapEntry) ArrayList(java.util.ArrayList) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata)

Aggregations

MutableMapMetadata (org.apache.aries.blueprint.mutable.MutableMapMetadata)3 BeanProperty (org.osgi.service.blueprint.reflect.BeanProperty)2 Element (org.w3c.dom.Element)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 ArrayList (java.util.ArrayList)1 MutableMapEntry (org.apache.aries.blueprint.mutable.MutableMapEntry)1 MapEntry (org.osgi.service.blueprint.reflect.MapEntry)1