use of org.apache.aries.blueprint.mutable.MutableCollectionMetadata in project aries by apache.
the class AbstractPropertyPlaceholder method processCollectionMetadata.
protected Metadata processCollectionMetadata(CollectionMetadata metadata) {
List<Metadata> values = new ArrayList<Metadata>(metadata.getValues());
if (!!!values.isEmpty()) {
try {
if (metadata instanceof MutableCollectionMetadata) {
processingStack.add("Collection type: " + metadata.getValueType() + "->");
MutableCollectionMetadata mcm = (MutableCollectionMetadata) metadata;
for (Metadata value : values) {
mcm.removeValue(value);
}
for (Metadata value : values) {
mcm.addValue(processMetadata(value));
}
} else {
printWarning(metadata, "Collection type: " + metadata.getValueType());
processingStack.add("Collection type: " + metadata.getValueType() + "->");
for (Metadata value : values) {
processMetadata(value);
}
}
} finally {
processingStack.removeLast();
}
}
return metadata;
}
use of org.apache.aries.blueprint.mutable.MutableCollectionMetadata 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;
}
Aggregations