Search in sources :

Example 1 with MutableRefMetadata

use of org.apache.aries.blueprint.mutable.MutableRefMetadata in project camel by apache.

the class CamelNamespaceHandler method createRef.

private RefMetadata createRef(ParserContext context, String value) {
    MutableRefMetadata r = context.createMetadata(MutableRefMetadata.class);
    r.setComponentId(value);
    return r;
}
Also used : MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata)

Example 2 with MutableRefMetadata

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

the class ExtNamespaceHandler method createRef.

private static RefMetadata createRef(ParserContext context, String value) {
    MutableRefMetadata m = context.createMetadata(MutableRefMetadata.class);
    m.setComponentId(value);
    return m;
}
Also used : MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata)

Example 3 with MutableRefMetadata

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

the class SpringOsgiNamespaceHandler method parseReference.

private Metadata parseReference(Element element, ParserContext context) {
    MutableReferenceMetadata metadata = context.createMetadata(MutableReferenceMetadata.class);
    // Parse attributes
    if (element.hasAttribute(ID_ATTRIBUTE)) {
        metadata.setId(element.getAttribute(ID_ATTRIBUTE));
    } else {
        metadata.setId(generateId(context));
    }
    metadata.setAvailability(CARDINALITY_0_1.equals(element.getAttribute(CARDINALITY_ATTRIBUTE)) ? ReferenceMetadata.AVAILABILITY_OPTIONAL : ReferenceMetadata.AVAILABILITY_MANDATORY);
    metadata.setTimeout(getLong(element.getAttribute(TIMEOUT_ATTRIBUTE), DEFAULT_TIMEOUT));
    metadata.setInterface(element.getAttribute(INTERFACE_ATTRIBUTE));
    metadata.setFilter(element.getAttribute(FILTER_ATTRIBUTE));
    String[] dependsOn = StringUtils.tokenizeToStringArray(element.getAttribute(DEPENDS_ON_ATTRIBUTE), ",; ");
    metadata.setDependsOn(dependsOn != null ? Arrays.asList(dependsOn) : null);
    metadata.setComponentName(element.getAttribute(BEAN_NAME_ELEMENT));
    // Parse child elements
    for (Element child : getChildren(element)) {
        if (element.getNamespaceURI().equals(child.getNamespaceURI())) {
            if (INTERFACES_ELEMENT.equals(child.getLocalName())) {
                List<String> itfs = parseInterfaces(child);
                metadata.setExtraInterfaces(itfs);
            } else if (LISTENER_ELEMENT.equals(child.getLocalName())) {
                String bindMethod = nonEmpty(child.getAttribute(BIND_METHOD_ATTRIBUTE));
                String unbindMethod = nonEmpty(child.getAttribute(UNBIND_METHOD_ATTRIBUTE));
                String refStr = nonEmpty(child.getAttribute(REF_ATTRIBUTE));
                Target listenerComponent = null;
                if (refStr != null) {
                    MutableRefMetadata ref = context.createMetadata(MutableRefMetadata.class);
                    ref.setComponentId(refStr);
                    listenerComponent = ref;
                }
                for (Element cchild : getChildren(child)) {
                    if (listenerComponent != null) {
                        throw new IllegalArgumentException("Only one of @ref attribute or inlined bean definition element is allowed");
                    }
                    listenerComponent = parseInlinedTarget(context, metadata, cchild);
                }
                if (listenerComponent == null) {
                    throw new IllegalArgumentException("Missing @ref attribute or inlined bean definition element");
                }
                metadata.addServiceListener(listenerComponent, bindMethod, unbindMethod);
            }
        } else {
            throw new UnsupportedOperationException("Custom namespaces not supported");
        }
    }
    return metadata;
}
Also used : Target(org.osgi.service.blueprint.reflect.Target) MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata) Element(org.w3c.dom.Element) MutableReferenceMetadata(org.apache.aries.blueprint.mutable.MutableReferenceMetadata)

Example 4 with MutableRefMetadata

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

the class CmNamespaceHandler method createRef.

private static RefMetadata createRef(ParserContext context, String value) {
    MutableRefMetadata m = context.createMetadata(MutableRefMetadata.class);
    m.setComponentId(value);
    return m;
}
Also used : MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata)

Example 5 with MutableRefMetadata

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

the class BlueprintNamespaceHandler method createRef.

private Metadata createRef(ParserContext parserContext, String id) {
    MutableRefMetadata ref = parserContext.createMetadata(MutableRefMetadata.class);
    ref.setComponentId(id);
    return ref;
}
Also used : MutableRefMetadata(org.apache.aries.blueprint.mutable.MutableRefMetadata)

Aggregations

MutableRefMetadata (org.apache.aries.blueprint.mutable.MutableRefMetadata)10 Element (org.w3c.dom.Element)3 MutableReferenceMetadata (org.apache.aries.blueprint.mutable.MutableReferenceMetadata)2 Target (org.osgi.service.blueprint.reflect.Target)2 NamespaceHandler (org.apache.aries.blueprint.NamespaceHandler)1 MutableBeanMetadata (org.apache.aries.blueprint.mutable.MutableBeanMetadata)1 MutableServiceMetadata (org.apache.aries.blueprint.mutable.MutableServiceMetadata)1 MutableValueMetadata (org.apache.aries.blueprint.mutable.MutableValueMetadata)1 BeanMetadata (org.osgi.service.blueprint.reflect.BeanMetadata)1 ComponentMetadata (org.osgi.service.blueprint.reflect.ComponentMetadata)1 Metadata (org.osgi.service.blueprint.reflect.Metadata)1 NonNullMetadata (org.osgi.service.blueprint.reflect.NonNullMetadata)1 RefMetadata (org.osgi.service.blueprint.reflect.RefMetadata)1 ReferenceMetadata (org.osgi.service.blueprint.reflect.ReferenceMetadata)1 ServiceMetadata (org.osgi.service.blueprint.reflect.ServiceMetadata)1 Attr (org.w3c.dom.Attr)1