use of org.osgi.service.blueprint.reflect.CollectionMetadata in project aries by apache.
the class BlueprintContainerImpl method getMetadata.
private <T extends ComponentMetadata> void getMetadata(Class<T> clazz, Metadata component, Collection<T> metadatas) {
if (component == null) {
return;
}
if (clazz.isInstance(component)) {
metadatas.add(clazz.cast(component));
}
if (component instanceof BeanMetadata) {
getMetadata(clazz, ((BeanMetadata) component).getFactoryComponent(), metadatas);
for (BeanArgument arg : ((BeanMetadata) component).getArguments()) {
getMetadata(clazz, arg.getValue(), metadatas);
}
for (BeanProperty prop : ((BeanMetadata) component).getProperties()) {
getMetadata(clazz, prop.getValue(), metadatas);
}
}
if (component instanceof CollectionMetadata) {
for (Metadata m : ((CollectionMetadata) component).getValues()) {
getMetadata(clazz, m, metadatas);
}
}
if (component instanceof MapMetadata) {
for (MapEntry m : ((MapMetadata) component).getEntries()) {
getMetadata(clazz, m.getKey(), metadatas);
getMetadata(clazz, m.getValue(), metadatas);
}
}
if (component instanceof PropsMetadata) {
for (MapEntry m : ((PropsMetadata) component).getEntries()) {
getMetadata(clazz, m.getKey(), metadatas);
getMetadata(clazz, m.getValue(), metadatas);
}
}
if (component instanceof ServiceReferenceMetadata) {
for (ReferenceListener l : ((ServiceReferenceMetadata) component).getReferenceListeners()) {
getMetadata(clazz, l.getListenerComponent(), metadatas);
}
}
if (component instanceof ServiceMetadata) {
getMetadata(clazz, ((ServiceMetadata) component).getServiceComponent(), metadatas);
for (MapEntry m : ((ServiceMetadata) component).getServiceProperties()) {
getMetadata(clazz, m.getKey(), metadatas);
getMetadata(clazz, m.getValue(), metadatas);
}
for (RegistrationListener l : ((ServiceMetadata) component).getRegistrationListeners()) {
getMetadata(clazz, l.getListenerComponent(), metadatas);
}
}
}
use of org.osgi.service.blueprint.reflect.CollectionMetadata in project aries by apache.
the class AbstractParserProxy method traverse.
/**
* Traverse to find all nested {@link ComponentMetadata} instances
* @param metadata
* @param output
*/
private void traverse(Metadata metadata, Set<ComponentMetadata> output) {
if (metadata instanceof ComponentMetadata) {
traverseComponent((ComponentMetadata) metadata, output);
} else if (metadata instanceof CollectionMetadata) {
CollectionMetadata collection = (CollectionMetadata) metadata;
for (Metadata v : collection.getValues()) traverse(v, output);
} else if (metadata instanceof MapMetadata) {
MapMetadata map = (MapMetadata) metadata;
for (MapEntry e : map.getEntries()) {
traverse(e.getKey(), output);
traverse(e.getValue(), output);
}
}
}
use of org.osgi.service.blueprint.reflect.CollectionMetadata in project aries by apache.
the class AbstractPropertyPlaceholder method processMetadata.
protected Metadata processMetadata(Metadata metadata) {
try {
if (metadata instanceof BeanMetadata) {
BeanMetadata bmd = (BeanMetadata) metadata;
processingStack.add("Bean named " + bmd.getId() + "->");
return processBeanMetadata(bmd);
} else if (metadata instanceof CollectionMetadata) {
CollectionMetadata cmd = (CollectionMetadata) metadata;
processingStack.add("Collection of type " + cmd.getCollectionClass() + "->");
return processCollectionMetadata(cmd);
} else if (metadata instanceof MapMetadata) {
processingStack.add("Map->");
return processMapMetadata((MapMetadata) metadata);
} else if (metadata instanceof PropsMetadata) {
processingStack.add("Properties->");
return processPropsMetadata((PropsMetadata) metadata);
} else if (metadata instanceof ValueMetadata) {
processingStack.add("Value->");
return processValueMetadata((ValueMetadata) metadata);
} else {
processingStack.add("Unknown Metadata " + metadata + "->");
return metadata;
}
} finally {
processingStack.removeLast();
}
}
use of org.osgi.service.blueprint.reflect.CollectionMetadata 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;
}
Aggregations