Search in sources :

Example 16 with Metadata

use of org.osgi.service.blueprint.reflect.Metadata in project karaf by apache.

the class NamespaceHandler method parseCompleters.

private Metadata parseCompleters(ParserContext context, ComponentMetadata enclosingComponent, Element element) {
    MutableCollectionMetadata collection = context.createMetadata(MutableCollectionMetadata.class);
    collection.setCollectionClass(List.class);
    NodeList children = element.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        if (child instanceof Element) {
            Metadata metadata;
            if (nodeNameEquals(child, REF)) {
                metadata = context.parseElement(RefMetadata.class, context.getEnclosingComponent(), (Element) child);
            } else if (nodeNameEquals(child, NULL)) {
                metadata = context.parseElement(NullMetadata.class, context.getEnclosingComponent(), (Element) child);
            } else if (nodeNameEquals(child, BEAN)) {
                metadata = context.parseElement(BeanMetadata.class, enclosingComponent, (Element) child);
            } else {
                throw new IllegalStateException("Unexpected element " + child.getNodeName());
            }
            collection.addValue(metadata);
        }
    }
    return collection;
}
Also used : RefMetadata(org.osgi.service.blueprint.reflect.RefMetadata) MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata) IdRefMetadata(org.osgi.service.blueprint.reflect.IdRefMetadata) MutableIdRefMetadata(org.apache.aries.blueprint.mutable.MutableIdRefMetadata) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) Metadata(org.osgi.service.blueprint.reflect.Metadata) MutablePassThroughMetadata(org.apache.aries.blueprint.mutable.MutablePassThroughMetadata) ServiceMetadata(org.osgi.service.blueprint.reflect.ServiceMetadata) PassThroughMetadata(org.apache.aries.blueprint.PassThroughMetadata) RefMetadata(org.osgi.service.blueprint.reflect.RefMetadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata) IdRefMetadata(org.osgi.service.blueprint.reflect.IdRefMetadata) MutableIdRefMetadata(org.apache.aries.blueprint.mutable.MutableIdRefMetadata) MutableServiceMetadata(org.apache.aries.blueprint.mutable.MutableServiceMetadata) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) NullMetadata(org.osgi.service.blueprint.reflect.NullMetadata) MapMetadata(org.osgi.service.blueprint.reflect.MapMetadata) MutableCollectionMetadata(org.apache.aries.blueprint.mutable.MutableCollectionMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) MutableValueMetadata(org.apache.aries.blueprint.mutable.MutableValueMetadata) MutableCollectionMetadata(org.apache.aries.blueprint.mutable.MutableCollectionMetadata)

Example 17 with Metadata

use of org.osgi.service.blueprint.reflect.Metadata in project camel by apache.

the class CxfNamespaceHandler method parse.

public Metadata parse(Element element, ParserContext context) {
    Metadata answer = null;
    String s = element.getLocalName();
    if ("cxfEndpoint".equals(s)) {
        LOG.debug("parsing the cxfEndpoint element");
        answer = new EndpointDefinitionParser().parse(element, context);
    }
    if ("rsClient".equals(s)) {
        LOG.debug("parsing the rsClient element");
        answer = new RsClientDefinitionParser().parse(element, context);
    }
    if ("rsServer".equals(s)) {
        LOG.debug("parsing the rsServer element");
        answer = new RsServerDefinitionParser().parse(element, context);
    }
    return answer;
}
Also used : ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) Metadata(org.osgi.service.blueprint.reflect.Metadata)

Example 18 with Metadata

use of org.osgi.service.blueprint.reflect.Metadata in project camel by apache.

the class RsClientDefinitionParser method parse.

public Metadata parse(Element element, ParserContext context) {
    MutableBeanMetadata beanMetadata = createBeanMetadata(element, context, RsClientBlueprintBean.class);
    NamedNodeMap atts = element.getAttributes();
    String bus = null;
    for (int i = 0; i < atts.getLength(); i++) {
        Attr node = (Attr) atts.item(i);
        String val = node.getValue();
        String pre = node.getPrefix();
        String name = node.getLocalName();
        if ("bus".equals(name)) {
            bus = val;
        } else if (isAttribute(pre, name)) {
            if ("depends-on".equals(name)) {
                beanMetadata.addDependsOn(val);
            } else if (!"name".equals(name)) {
                beanMetadata.addProperty(name, AbstractBPBeanDefinitionParser.createValue(context, val));
            }
        }
    }
    for (Element elem = DOMUtils.getFirstElement(element); elem != null; elem = DOMUtils.getNextElement(elem)) {
        String name = elem.getLocalName();
        if ("properties".equals(name) || "headers".equals(name)) {
            Metadata map = parseMapData(context, beanMetadata, elem);
            beanMetadata.addProperty(name, map);
        } else if ("binding".equals(name)) {
            setFirstChildAsProperty(elem, context, beanMetadata, "bindingConfig");
        } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
            Metadata list = parseListData(context, beanMetadata, elem);
            beanMetadata.addProperty(name, list);
        } else if ("features".equals(name) || "providers".equals(name) || "schemaLocations".equals(name) || "modelBeans".equals(name)) {
            Metadata list = parseListData(context, beanMetadata, elem);
            beanMetadata.addProperty(name, list);
        } else if ("model".equals(name)) {
            List<UserResource> resources = ResourceUtils.getResourcesFromElement(elem);
            MutablePassThroughMetadata value = context.createMetadata(MutablePassThroughMetadata.class);
            value.setObject(resources);
            beanMetadata.addProperty(name, value);
        } else {
            setFirstChildAsProperty(elem, context, beanMetadata, name);
        }
    }
    if (StringUtils.isEmpty(bus)) {
        bus = "cxf";
    }
    //Will create a bus if needed...
    beanMetadata.addProperty("bus", getBusRef(context, bus));
    return beanMetadata;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) MutablePassThroughMetadata(org.apache.aries.blueprint.mutable.MutablePassThroughMetadata) NamedNodeMap(org.w3c.dom.NamedNodeMap) Element(org.w3c.dom.Element) Metadata(org.osgi.service.blueprint.reflect.Metadata) MutablePassThroughMetadata(org.apache.aries.blueprint.mutable.MutablePassThroughMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) UserResource(org.apache.cxf.jaxrs.model.UserResource) Attr(org.w3c.dom.Attr)

Example 19 with Metadata

use of org.osgi.service.blueprint.reflect.Metadata in project camel by apache.

the class RsServerDefinitionParser method parse.

public Metadata parse(Element element, ParserContext context) {
    MutableBeanMetadata beanMetadata = createBeanMetadata(element, context, RsServerBlueprintBean.class);
    NamedNodeMap atts = element.getAttributes();
    String bus = null;
    for (int i = 0; i < atts.getLength(); i++) {
        Attr node = (Attr) atts.item(i);
        String val = node.getValue();
        String pre = node.getPrefix();
        String name = node.getLocalName();
        if ("bus".equals(name)) {
            bus = val;
        } else if (isAttribute(pre, name)) {
            if ("depends-on".equals(name)) {
                beanMetadata.addDependsOn(val);
            } else if (!"name".equals(name)) {
                beanMetadata.addProperty(name, AbstractBPBeanDefinitionParser.createValue(context, val));
            }
        }
    }
    for (Element elem = DOMUtils.getFirstElement(element); elem != null; elem = DOMUtils.getNextElement(elem)) {
        String name = elem.getLocalName();
        if ("properties".equals(name) || "extensionMappings".equals(name) || "languageMappings".equals(name)) {
            Metadata map = parseMapData(context, beanMetadata, elem);
            beanMetadata.addProperty(name, map);
        } else if ("binding".equals(name)) {
            setFirstChildAsProperty(elem, context, beanMetadata, "bindingConfig");
        } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name) || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
            Metadata list = parseListData(context, beanMetadata, elem);
            beanMetadata.addProperty(name, list);
        } else if ("features".equals(name) || "providers".equals(name) || "schemaLocations".equals(name) || "modelBeans".equals(name) || "serviceBeans".equals(name)) {
            Metadata list = parseListData(context, beanMetadata, elem);
            beanMetadata.addProperty(name, list);
        } else if ("model".equals(name)) {
            List<UserResource> resources = ResourceUtils.getResourcesFromElement(elem);
            MutablePassThroughMetadata value = context.createMetadata(MutablePassThroughMetadata.class);
            value.setObject(resources);
            beanMetadata.addProperty(name, value);
        } else {
            setFirstChildAsProperty(elem, context, beanMetadata, name);
        }
    }
    if (StringUtils.isEmpty(bus)) {
        bus = "cxf";
    }
    //Will create a bus if needed...
    beanMetadata.addProperty("bus", getBusRef(context, bus));
    return beanMetadata;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) MutablePassThroughMetadata(org.apache.aries.blueprint.mutable.MutablePassThroughMetadata) NamedNodeMap(org.w3c.dom.NamedNodeMap) Element(org.w3c.dom.Element) Metadata(org.osgi.service.blueprint.reflect.Metadata) MutablePassThroughMetadata(org.apache.aries.blueprint.mutable.MutablePassThroughMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) UserResource(org.apache.cxf.jaxrs.model.UserResource) Attr(org.w3c.dom.Attr)

Example 20 with Metadata

use of org.osgi.service.blueprint.reflect.Metadata in project camel by apache.

the class CamelTransportNameSpaceHandler method parse.

@Override
public Metadata parse(Element element, ParserContext context) {
    Metadata answer = null;
    String s = element.getLocalName();
    if ("conduit".equals(s)) {
        LOG.debug("parsing the conduit element");
        answer = new CamelConduitDefinitionParser().parse(element, context);
    }
    if ("destination".equals(s)) {
        LOG.debug("parsing the detination element");
        answer = new CamelDestinationDefinitionParser().parse(element, context);
    }
    return answer;
}
Also used : ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) Metadata(org.osgi.service.blueprint.reflect.Metadata)

Aggregations

Metadata (org.osgi.service.blueprint.reflect.Metadata)30 ComponentMetadata (org.osgi.service.blueprint.reflect.ComponentMetadata)26 BeanMetadata (org.osgi.service.blueprint.reflect.BeanMetadata)23 RefMetadata (org.osgi.service.blueprint.reflect.RefMetadata)21 ServiceMetadata (org.osgi.service.blueprint.reflect.ServiceMetadata)17 CollectionMetadata (org.osgi.service.blueprint.reflect.CollectionMetadata)16 MapMetadata (org.osgi.service.blueprint.reflect.MapMetadata)16 ValueMetadata (org.osgi.service.blueprint.reflect.ValueMetadata)16 MutableBeanMetadata (org.apache.aries.blueprint.mutable.MutableBeanMetadata)12 ReferenceListMetadata (org.osgi.service.blueprint.reflect.ReferenceListMetadata)12 ReferenceMetadata (org.osgi.service.blueprint.reflect.ReferenceMetadata)12 ServiceReferenceMetadata (org.osgi.service.blueprint.reflect.ServiceReferenceMetadata)12 Element (org.w3c.dom.Element)12 IdRefMetadata (org.osgi.service.blueprint.reflect.IdRefMetadata)11 NonNullMetadata (org.osgi.service.blueprint.reflect.NonNullMetadata)11 NullMetadata (org.osgi.service.blueprint.reflect.NullMetadata)11 PropsMetadata (org.osgi.service.blueprint.reflect.PropsMetadata)11 MutableRefMetadata (org.apache.aries.blueprint.mutable.MutableRefMetadata)9 PassThroughMetadata (org.apache.aries.blueprint.PassThroughMetadata)8 Node (org.w3c.dom.Node)8