Search in sources :

Example 31 with ComponentMetadata

use of org.osgi.service.blueprint.reflect.ComponentMetadata in project cxf by apache.

the class ConfigurerImpl method initializeWildcardMap.

private void initializeWildcardMap() {
    for (String s : container.getComponentIds()) {
        if (isWildcardBeanName(s)) {
            ComponentMetadata cmd = container.getComponentMetadata(s);
            Class<?> cls = BlueprintBeanLocator.getClassForMetaData(container, cmd);
            if (cls != null) {
                String orig = s;
                if (s.charAt(0) == '*') {
                    // old wildcard
                    s = "." + s.replaceAll("\\.", "\\.");
                }
                Matcher matcher = Pattern.compile(s).matcher("");
                List<MatcherHolder> m = wildCardBeanDefinitions.get(cls.getName());
                if (m == null) {
                    m = new ArrayList<>();
                    wildCardBeanDefinitions.put(cls.getName(), m);
                }
                MatcherHolder holder = new MatcherHolder(orig, matcher);
                m.add(holder);
            }
        }
    }
}
Also used : Matcher(java.util.regex.Matcher) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata)

Example 32 with ComponentMetadata

use of org.osgi.service.blueprint.reflect.ComponentMetadata in project cxf by apache.

the class JettyServerEngineFactoryParser method parseEngineConnector.

protected Metadata parseEngineConnector(List<Element> engines, ComponentMetadata enclosingComponent, ParserContext context) {
    MutableMapMetadata map = context.createMetadata(MutableMapMetadata.class);
    map.setKeyType("java.lang.String");
    map.setValueType("org.eclipse.jetty.server.Connector");
    for (Element engine : engines) {
        String port = engine.getAttribute("port");
        ValueMetadata keyValue = createValue(context, port);
        Element connector = DOMUtils.getFirstChildWithName(engine, HTTPJettyTransportNamespaceHandler.JETTY_TRANSPORT, "connector");
        if (connector != null) {
            Element first = DOMUtils.getFirstElement(connector);
            Metadata valValue = context.parseElement(Metadata.class, enclosingComponent, first);
            map.addEntry(keyValue, valValue);
        }
    }
    return map;
}
Also used : Element(org.w3c.dom.Element) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) Metadata(org.osgi.service.blueprint.reflect.Metadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata)

Example 33 with ComponentMetadata

use of org.osgi.service.blueprint.reflect.ComponentMetadata in project cxf by apache.

the class JettyServerEngineFactoryParser method parseEngineHandlers.

protected Metadata parseEngineHandlers(List<Element> engines, ComponentMetadata enclosingComponent, ParserContext context) {
    MutableMapMetadata map = context.createMetadata(MutableMapMetadata.class);
    map.setKeyType("java.lang.String");
    map.setValueType("java.util.List");
    for (Element engine : engines) {
        String port = engine.getAttribute("port");
        ValueMetadata keyValue = createValue(context, port);
        Element handlers = DOMUtils.getFirstChildWithName(engine, HTTPJettyTransportNamespaceHandler.JETTY_TRANSPORT, "handlers");
        if (handlers != null) {
            Metadata valValue = parseListData(context, enclosingComponent, handlers);
            map.addEntry(keyValue, valValue);
        }
    }
    return map;
}
Also used : Element(org.w3c.dom.Element) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) Metadata(org.osgi.service.blueprint.reflect.Metadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata)

Example 34 with ComponentMetadata

use of org.osgi.service.blueprint.reflect.ComponentMetadata in project cxf by apache.

the class UndertowServerEngineFactoryParser method parseEngineHandlers.

protected Metadata parseEngineHandlers(List<Element> engines, ComponentMetadata enclosingComponent, ParserContext context) {
    MutableMapMetadata map = context.createMetadata(MutableMapMetadata.class);
    map.setKeyType("java.lang.String");
    map.setValueType("java.util.List");
    for (Element engine : engines) {
        String port = engine.getAttribute("port");
        ValueMetadata keyValue = createValue(context, port);
        Element handlers = DOMUtils.getFirstChildWithName(engine, HTTPUndertowTransportNamespaceHandler.UNDERTOW_TRANSPORT, "handlers");
        if (handlers != null) {
            Metadata valValue = parseListData(context, enclosingComponent, handlers);
            map.addEntry(keyValue, valValue);
        }
    }
    return map;
}
Also used : Element(org.w3c.dom.Element) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) Metadata(org.osgi.service.blueprint.reflect.Metadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata)

Example 35 with ComponentMetadata

use of org.osgi.service.blueprint.reflect.ComponentMetadata in project opennms by OpenNMS.

the class OnmsVaadinUIFactory method validate.

/**
 * Verify that the current UIFactory is set up correctly.
 */
private void validate() {
    // Verify that the uiBean is a subclass of UI
    final Object instance = m_blueprintContainer.getComponentInstance(m_uiBeanId);
    if (!(instance instanceof UI)) {
        throw new IllegalStateException("The bean with id " + m_uiBeanId + " must be of type " + com.vaadin.ui.UI.class);
    }
    // Verify that the scope is prototype and NOT singleton
    final ComponentMetadata componentMetadata = Objects.requireNonNull(m_blueprintContainer.getComponentMetadata(m_uiBeanId));
    if (!(componentMetadata instanceof BeanMetadata)) {
        throw new IllegalStateException("The referenced id is not a bean");
    }
    if (!BeanMetadata.SCOPE_PROTOTYPE.equals(((BeanMetadata) componentMetadata).getScope())) {
        throw new IllegalStateException("The scope of the defined bean with id " + m_uiBeanId + " must be " + BeanMetadata.SCOPE_PROTOTYPE + " but is " + BeanMetadata.SCOPE_SINGLETON);
    }
}
Also used : UI(com.vaadin.ui.UI) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata)

Aggregations

ComponentMetadata (org.osgi.service.blueprint.reflect.ComponentMetadata)54 BeanMetadata (org.osgi.service.blueprint.reflect.BeanMetadata)22 Metadata (org.osgi.service.blueprint.reflect.Metadata)19 ValueMetadata (org.osgi.service.blueprint.reflect.ValueMetadata)18 RefMetadata (org.osgi.service.blueprint.reflect.RefMetadata)17 ServiceMetadata (org.osgi.service.blueprint.reflect.ServiceMetadata)17 CollectionMetadata (org.osgi.service.blueprint.reflect.CollectionMetadata)15 ArrayList (java.util.ArrayList)14 ComponentDefinitionException (org.osgi.service.blueprint.container.ComponentDefinitionException)14 MapMetadata (org.osgi.service.blueprint.reflect.MapMetadata)14 Element (org.w3c.dom.Element)14 ServiceReferenceMetadata (org.osgi.service.blueprint.reflect.ServiceReferenceMetadata)13 NullMetadata (org.osgi.service.blueprint.reflect.NullMetadata)12 ReferenceListMetadata (org.osgi.service.blueprint.reflect.ReferenceListMetadata)12 ReferenceMetadata (org.osgi.service.blueprint.reflect.ReferenceMetadata)12 Node (org.w3c.dom.Node)12 IdRefMetadata (org.osgi.service.blueprint.reflect.IdRefMetadata)11 PropsMetadata (org.osgi.service.blueprint.reflect.PropsMetadata)10 NodeList (org.w3c.dom.NodeList)10 NonNullMetadata (org.osgi.service.blueprint.reflect.NonNullMetadata)9