Search in sources :

Example 51 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project karaf by apache.

the class NamespaceHandler method parseKeystore.

public ComponentMetadata parseKeystore(Element element, ParserContext context) {
    MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);
    bean.setRuntimeClass(ResourceKeystoreInstance.class);
    // Parse name
    String name = element.getAttribute("name");
    bean.addProperty("name", createValue(context, name));
    // Parse rank
    String rank = element.getAttribute("rank");
    if (rank != null && rank.length() > 0) {
        bean.addProperty("rank", createValue(context, rank));
    }
    // Parse path
    String path = element.getAttribute("path");
    if (path != null && path.length() > 0) {
        bean.addProperty("path", createValue(context, path));
    }
    // Parse keystorePassword
    String keystorePassword = element.getAttribute("keystorePassword");
    if (keystorePassword != null && keystorePassword.length() > 0) {
        bean.addProperty("keystorePassword", createValue(context, keystorePassword));
    }
    // Parse keyPasswords
    String keyPasswords = element.getAttribute("keyPasswords");
    if (keyPasswords != null && keyPasswords.length() > 0) {
        bean.addProperty("keyPasswords", createValue(context, keyPasswords));
    }
    // Publish Config
    MutableServiceMetadata service = context.createMetadata(MutableServiceMetadata.class);
    service.setId(name);
    service.setServiceComponent(bean);
    service.addInterface(KeystoreInstance.class.getName());
    return service;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) MutableServiceMetadata(org.apache.aries.blueprint.mutable.MutableServiceMetadata) KeystoreInstance(org.apache.karaf.jaas.config.KeystoreInstance) ResourceKeystoreInstance(org.apache.karaf.jaas.config.impl.ResourceKeystoreInstance)

Example 52 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project karaf by apache.

the class NamespaceHandler method parseConfig.

public ComponentMetadata parseConfig(Element element, ParserContext context) {
    MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);
    bean.setRuntimeClass(Config.class);
    String name = element.getAttribute("name");
    bean.addProperty("bundleContext", createRef(context, "blueprintBundleContext"));
    bean.addProperty("name", createValue(context, name));
    String rank = element.getAttribute("rank");
    if (rank != null && rank.length() > 0) {
        bean.addProperty("rank", createValue(context, rank));
    }
    NodeList childElements = element.getElementsByTagNameNS(element.getNamespaceURI(), "module");
    if (childElements != null && childElements.getLength() > 0) {
        MutableCollectionMetadata children = context.createMetadata(MutableCollectionMetadata.class);
        for (int i = 0; i < childElements.getLength(); ++i) {
            Element childElement = (Element) childElements.item(i);
            MutableBeanMetadata md = context.createMetadata(MutableBeanMetadata.class);
            md.setRuntimeClass(Module.class);
            md.addProperty("className", createValue(context, childElement.getAttribute("className")));
            if (childElement.getAttribute("name") != null) {
                md.addProperty("name", createValue(context, childElement.getAttribute("name")));
            }
            if (childElement.getAttribute("flags") != null) {
                md.addProperty("flags", createValue(context, childElement.getAttribute("flags")));
            }
            String options = getTextValue(childElement);
            if (options != null && options.length() > 0) {
                md.addProperty("options", createValue(context, options));
            }
            children.addValue(md);
        }
        bean.addProperty("modules", children);
    }
    // Publish Config
    MutableServiceMetadata service = context.createMetadata(MutableServiceMetadata.class);
    service.setId(name);
    service.setServiceComponent(bean);
    service.addInterface(JaasRealm.class.getName());
    service.addServiceProperty(createValue(context, ProxyLoginModule.PROPERTY_MODULE), createValue(context, name));
    return service;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) JaasRealm(org.apache.karaf.jaas.config.JaasRealm) MutableServiceMetadata(org.apache.aries.blueprint.mutable.MutableServiceMetadata) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) MutableCollectionMetadata(org.apache.aries.blueprint.mutable.MutableCollectionMetadata)

Example 53 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project karaf by apache.

the class NamespaceHandler method parseAction.

private MutableBeanMetadata parseAction(ParserContext context, ComponentMetadata enclosingComponent, Element element) {
    MutableBeanMetadata action = context.createMetadata(MutableBeanMetadata.class);
    action.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);
    action.setScope(MutableBeanMetadata.SCOPE_PROTOTYPE);
    action.setClassName(element.getAttribute("class"));
    NodeList children = element.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        if (child instanceof Element) {
            Element childElement = (Element) child;
            if (nodeNameEquals(childElement, "argument")) {
                action.addArgument(context.parseElement(BeanArgument.class, enclosingComponent, childElement));
            } else if (nodeNameEquals(childElement, "property")) {
                action.addProperty(context.parseElement(BeanProperty.class, enclosingComponent, childElement));
            }
        }
    }
    return action;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) BeanArgument(org.osgi.service.blueprint.reflect.BeanArgument) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element)

Example 54 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project karaf by apache.

the class NamespaceHandler method createSubShell.

private void createSubShell(ParserContext context, String scope, String subShellName) {
    if (context.getComponentDefinitionRegistry().containsComponentDefinition(subShellName)) {
        return;
    }
    MutableBeanMetadata subShellAction = context.createMetadata(MutableBeanMetadata.class);
    subShellAction.setRuntimeClass(SubShellAction.class);
    subShellAction.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);
    subShellAction.setScope(MutableBeanMetadata.SCOPE_PROTOTYPE);
    subShellAction.setId(getName());
    subShellAction.addProperty("subShell", createStringValue(context, scope));
    context.getComponentDefinitionRegistry().registerComponentDefinition(subShellAction);
    // generate the sub-shell command
    MutableBeanMetadata subShellCommand = context.createMetadata(MutableBeanMetadata.class);
    subShellCommand.setId(getName());
    subShellCommand.setRuntimeClass(BlueprintCommand.class);
    subShellCommand.addProperty(BLUEPRINT_CONTAINER, createRef(context, BLUEPRINT_CONTAINER));
    subShellCommand.addProperty(BLUEPRINT_CONVERTER, createRef(context, BLUEPRINT_CONVERTER));
    subShellCommand.addProperty(ACTION_ID, createIdRef(context, subShellAction.getId()));
    context.getComponentDefinitionRegistry().registerComponentDefinition(subShellCommand);
    // generate the sub-shell OSGi service
    MutableServiceMetadata subShellCommandService = context.createMetadata(MutableServiceMetadata.class);
    subShellCommandService.setActivation(MutableServiceMetadata.ACTIVATION_LAZY);
    subShellCommandService.setId(subShellName);
    subShellCommandService.setAutoExport(ServiceMetadata.AUTO_EXPORT_INTERFACES);
    subShellCommandService.setServiceComponent(subShellCommand);
    subShellCommandService.addServiceProperty(createStringValue(context, "osgi.command.scope"), createStringValue(context, "*"));
    subShellCommandService.addServiceProperty(createStringValue(context, "osgi.command.function"), createStringValue(context, scope));
    context.getComponentDefinitionRegistry().registerComponentDefinition(subShellCommandService);
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) MutableServiceMetadata(org.apache.aries.blueprint.mutable.MutableServiceMetadata)

Example 55 with MutableBeanMetadata

use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project controller by opendaylight.

the class OpendaylightNamespaceHandler method parseNotificationListener.

private static Metadata parseNotificationListener(final Element element, final ParserContext context) {
    registerNotificationServiceRefBean(context);
    MutableBeanMetadata metadata = createBeanMetadata(context, context.generateId(), NotificationListenerBean.class, true, true);
    addBlueprintBundleRefProperty(context, metadata);
    metadata.addProperty("notificationService", createRef(context, NOTIFICATION_SERVICE_NAME));
    metadata.addProperty("notificationListener", createRef(context, element.getAttribute(REF_ATTR)));
    LOG.debug("parseNotificationListener returning {}", metadata);
    return metadata;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata)

Aggregations

MutableBeanMetadata (org.apache.aries.blueprint.mutable.MutableBeanMetadata)96 Element (org.w3c.dom.Element)23 Node (org.w3c.dom.Node)20 MutablePassThroughMetadata (org.apache.aries.blueprint.mutable.MutablePassThroughMetadata)19 Metadata (org.osgi.service.blueprint.reflect.Metadata)19 MutableRefMetadata (org.apache.aries.blueprint.mutable.MutableRefMetadata)18 ComponentDefinitionException (org.osgi.service.blueprint.container.ComponentDefinitionException)18 MutableCollectionMetadata (org.apache.aries.blueprint.mutable.MutableCollectionMetadata)17 BeanMetadata (org.osgi.service.blueprint.reflect.BeanMetadata)16 ComponentMetadata (org.osgi.service.blueprint.reflect.ComponentMetadata)15 MutableValueMetadata (org.apache.aries.blueprint.mutable.MutableValueMetadata)13 RefMetadata (org.osgi.service.blueprint.reflect.RefMetadata)12 NodeList (org.w3c.dom.NodeList)11 MutableMapMetadata (org.apache.aries.blueprint.mutable.MutableMapMetadata)10 PassThroughMetadata (org.apache.aries.blueprint.PassThroughMetadata)9 JAXBException (javax.xml.bind.JAXBException)8 CollectionMetadata (org.osgi.service.blueprint.reflect.CollectionMetadata)8 ValueMetadata (org.osgi.service.blueprint.reflect.ValueMetadata)8 ExpressionNode (org.apache.camel.model.ExpressionNode)7 Attr (org.w3c.dom.Attr)7