use of org.osgi.service.blueprint.reflect.MapEntry in project aries by apache.
the class AbstractPropertyPlaceholder method processServiceMetadata.
protected Metadata processServiceMetadata(ServiceMetadata component) {
try {
if (component instanceof MutableServiceMetadata) {
processingStack.add("Service Component->");
((MutableServiceMetadata) component).setServiceComponent((Target) processMetadata(component.getServiceComponent()));
} else {
printWarning(component, "Service Component");
processingStack.add("Service Component->");
processMetadata(component.getServiceComponent());
}
} finally {
processingStack.removeLast();
}
List<MapEntry> entries = new ArrayList<MapEntry>(component.getServiceProperties());
if (!!!entries.isEmpty()) {
try {
if (component instanceof MutableServiceMetadata) {
processingStack.add("Service Properties->");
MutableServiceMetadata msm = (MutableServiceMetadata) component;
for (MapEntry entry : entries) {
msm.removeServiceProperty(entry);
}
for (MapEntry entry : processMapEntries(entries)) {
msm.addServiceProperty(entry);
}
} else {
printWarning(component, "Service Properties");
processingStack.add("Service Properties->");
processMapEntries(entries);
}
} finally {
processingStack.removeLast();
}
}
for (RegistrationListener listener : component.getRegistrationListeners()) {
Target listenerComponent = listener.getListenerComponent();
try {
processingStack.add("Registration Listener " + listenerComponent + "->");
if (listener instanceof MutableRegistrationListener) {
((MutableRegistrationListener) listener).setListenerComponent((Target) processMetadata(listenerComponent));
} else {
//Say that we can't change this listener, but continue processing
//If the value is mutable then we may be ok!
printWarning(listener, "Service Registration Listener");
processMetadata(listenerComponent);
}
} finally {
processingStack.removeLast();
}
}
return component;
}
use of org.osgi.service.blueprint.reflect.MapEntry in project aries by apache.
the class AbstractPropertyPlaceholder method processMapEntries.
protected List<MapEntry> processMapEntries(List<MapEntry> entries) {
for (MapEntry entry : entries) {
try {
processingStack.add("Map Entry Key: " + entry.getKey() + " Value: " + entry.getValue() + "->");
if (entry instanceof MutableMapEntry) {
((MutableMapEntry) entry).setKey((NonNullMetadata) processMetadata(entry.getKey()));
((MutableMapEntry) entry).setValue(processMetadata(entry.getValue()));
} else {
printWarning(entry, "Map Entry");
processMetadata(entry.getKey());
processMetadata(entry.getValue());
}
} finally {
processingStack.removeLast();
}
}
return entries;
}
use of org.osgi.service.blueprint.reflect.MapEntry in project aries by apache.
the class AbstractPropertyPlaceholder method processMapMetadata.
protected Metadata processMapMetadata(MapMetadata metadata) {
List<MapEntry> entries = new ArrayList<MapEntry>(metadata.getEntries());
if (!!!entries.isEmpty()) {
try {
if (metadata instanceof MutableMapMetadata) {
processingStack.add("Map->");
MutableMapMetadata mmm = (MutableMapMetadata) metadata;
for (MapEntry entry : entries) {
mmm.removeEntry(entry);
}
for (MapEntry entry : processMapEntries(entries)) {
mmm.addEntry(entry);
}
} else {
printWarning(metadata, "Map");
processingStack.add("Map->");
processMapEntries(entries);
}
} finally {
processingStack.removeLast();
}
}
return metadata;
}
use of org.osgi.service.blueprint.reflect.MapEntry in project aries by apache.
the class Parser method parseProps.
public PropsMetadata parseProps(Element element) {
// Parse elements
List<MapEntry> entries = new ArrayList<MapEntry>();
NodeList nl = element.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node node = nl.item(i);
if (node instanceof Element) {
Element e = (Element) node;
if (isBlueprintNamespace(e.getNamespaceURI()) && nodeNameEquals(e, PROP_ELEMENT)) {
entries.add(parseProperty(e));
}
}
}
return new PropsMetadataImpl(entries);
}
use of org.osgi.service.blueprint.reflect.MapEntry in project aries by apache.
the class Parser method parseMap.
public MapMetadata parseMap(Element element, ComponentMetadata enclosingComponent) {
// Parse attributes
String keyType = element.hasAttribute(KEY_TYPE_ATTRIBUTE) ? element.getAttribute(KEY_TYPE_ATTRIBUTE) : null;
String valueType = element.hasAttribute(VALUE_TYPE_ATTRIBUTE) ? element.getAttribute(VALUE_TYPE_ATTRIBUTE) : null;
// Parse elements
List<MapEntry> entries = new ArrayList<MapEntry>();
NodeList nl = element.getChildNodes();
for (int i = 0; i < nl.getLength(); i++) {
Node node = nl.item(i);
if (node instanceof Element) {
Element e = (Element) node;
if (nodeNameEquals(e, ENTRY_ELEMENT)) {
entries.add(parseMapEntry(e, enclosingComponent, null, null));
}
}
}
return new MapMetadataImpl(keyType, valueType, entries);
}
Aggregations