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;
}
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;
}
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;
}
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);
}
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;
}
Aggregations