Search in sources :

Example 6 with MapEntry

use of org.osgi.service.blueprint.reflect.MapEntry in project aries by apache.

the class MapMetadataImpl method addEntry.

public MapEntry addEntry(NonNullMetadata key, Metadata value) {
    MapEntry entry = new MapEntryImpl(key, value);
    addEntry(entry);
    return entry;
}
Also used : MapEntry(org.osgi.service.blueprint.reflect.MapEntry)

Example 7 with MapEntry

use of org.osgi.service.blueprint.reflect.MapEntry 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);
        }
    }
}
Also used : BeanArgument(org.osgi.service.blueprint.reflect.BeanArgument) PropsMetadata(org.osgi.service.blueprint.reflect.PropsMetadata) RegistrationListener(org.osgi.service.blueprint.reflect.RegistrationListener) CollectionMetadata(org.osgi.service.blueprint.reflect.CollectionMetadata) MapEntry(org.osgi.service.blueprint.reflect.MapEntry) ExtendedBeanMetadata(org.apache.aries.blueprint.ExtendedBeanMetadata) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) CollectionMetadata(org.osgi.service.blueprint.reflect.CollectionMetadata) Metadata(org.osgi.service.blueprint.reflect.Metadata) PropsMetadata(org.osgi.service.blueprint.reflect.PropsMetadata) ServiceMetadata(org.osgi.service.blueprint.reflect.ServiceMetadata) RefMetadata(org.osgi.service.blueprint.reflect.RefMetadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) ServiceReferenceMetadata(org.osgi.service.blueprint.reflect.ServiceReferenceMetadata) ExtendedBeanMetadata(org.apache.aries.blueprint.ExtendedBeanMetadata) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) MapMetadata(org.osgi.service.blueprint.reflect.MapMetadata) ReferenceListener(org.osgi.service.blueprint.reflect.ReferenceListener) MapMetadata(org.osgi.service.blueprint.reflect.MapMetadata) ServiceReferenceMetadata(org.osgi.service.blueprint.reflect.ServiceReferenceMetadata) ServiceMetadata(org.osgi.service.blueprint.reflect.ServiceMetadata) BeanProperty(org.osgi.service.blueprint.reflect.BeanProperty)

Example 8 with MapEntry

use of org.osgi.service.blueprint.reflect.MapEntry in project aries by apache.

the class AbstractPropertyPlaceholder method processPropsMetadata.

protected Metadata processPropsMetadata(PropsMetadata metadata) {
    List<MapEntry> entries = new ArrayList<MapEntry>(metadata.getEntries());
    if (!!!entries.isEmpty()) {
        try {
            if (metadata instanceof MutablePropsMetadata) {
                processingStack.add("Properties->");
                MutablePropsMetadata mpm = (MutablePropsMetadata) metadata;
                for (MapEntry entry : entries) {
                    mpm.removeEntry(entry);
                }
                for (MapEntry entry : processMapEntries(entries)) {
                    mpm.addEntry(entry);
                }
            } else {
                printWarning(metadata, "Properties");
                processingStack.add("Properties->");
                processMapEntries(entries);
            }
        } finally {
            processingStack.removeLast();
        }
    }
    return metadata;
}
Also used : MutableMapEntry(org.apache.aries.blueprint.mutable.MutableMapEntry) MapEntry(org.osgi.service.blueprint.reflect.MapEntry) MutablePropsMetadata(org.apache.aries.blueprint.mutable.MutablePropsMetadata) ArrayList(java.util.ArrayList)

Example 9 with MapEntry

use of org.osgi.service.blueprint.reflect.MapEntry in project aries by apache.

the class AbstractParserProxy method traverseComponent.

/**
	   * Traverse {@link ComponentMetadata} instances to find all nested {@link ComponentMetadata} instances
	   * @param component
	   * @param output
	   */
private void traverseComponent(ComponentMetadata component, Set<ComponentMetadata> output) {
    if (!!!output.add(component))
        return;
    if (component instanceof BeanMetadata) {
        BeanMetadata bean = (BeanMetadata) component;
        traverse(bean.getFactoryComponent(), output);
        for (BeanArgument argument : bean.getArguments()) {
            traverse(argument.getValue(), output);
        }
        for (BeanProperty property : bean.getProperties()) {
            traverse(property.getValue(), output);
        }
    } else if (component instanceof ServiceMetadata) {
        ServiceMetadata service = (ServiceMetadata) component;
        traverse(service.getServiceComponent(), output);
        for (RegistrationListener listener : service.getRegistrationListeners()) {
            traverse(listener.getListenerComponent(), output);
        }
        for (MapEntry e : service.getServiceProperties()) {
            traverse(e.getKey(), output);
            traverse(e.getValue(), output);
        }
    } else if (component instanceof ServiceReferenceMetadata) {
        ServiceReferenceMetadata reference = (ServiceReferenceMetadata) component;
        for (ReferenceListener listener : reference.getReferenceListeners()) {
            traverse(listener.getListenerComponent(), output);
        }
    }
}
Also used : BeanArgument(org.osgi.service.blueprint.reflect.BeanArgument) RegistrationListener(org.osgi.service.blueprint.reflect.RegistrationListener) MapEntry(org.osgi.service.blueprint.reflect.MapEntry) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) ReferenceListener(org.osgi.service.blueprint.reflect.ReferenceListener) ServiceReferenceMetadata(org.osgi.service.blueprint.reflect.ServiceReferenceMetadata) WrappedServiceMetadata(org.apache.aries.application.modelling.WrappedServiceMetadata) ServiceMetadata(org.osgi.service.blueprint.reflect.ServiceMetadata) BeanProperty(org.osgi.service.blueprint.reflect.BeanProperty)

Example 10 with MapEntry

use of org.osgi.service.blueprint.reflect.MapEntry 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);
        }
    }
}
Also used : CollectionMetadata(org.osgi.service.blueprint.reflect.CollectionMetadata) MapEntry(org.osgi.service.blueprint.reflect.MapEntry) CollectionMetadata(org.osgi.service.blueprint.reflect.CollectionMetadata) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) Metadata(org.osgi.service.blueprint.reflect.Metadata) WrappedServiceMetadata(org.apache.aries.application.modelling.WrappedServiceMetadata) ServiceMetadata(org.osgi.service.blueprint.reflect.ServiceMetadata) RefMetadata(org.osgi.service.blueprint.reflect.RefMetadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) ServiceReferenceMetadata(org.osgi.service.blueprint.reflect.ServiceReferenceMetadata) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) MapMetadata(org.osgi.service.blueprint.reflect.MapMetadata) ReferenceListMetadata(org.osgi.service.blueprint.reflect.ReferenceListMetadata) ComponentMetadata(org.osgi.service.blueprint.reflect.ComponentMetadata) MapMetadata(org.osgi.service.blueprint.reflect.MapMetadata)

Aggregations

MapEntry (org.osgi.service.blueprint.reflect.MapEntry)15 ArrayList (java.util.ArrayList)7 BeanMetadata (org.osgi.service.blueprint.reflect.BeanMetadata)5 ServiceMetadata (org.osgi.service.blueprint.reflect.ServiceMetadata)5 MutableMapEntry (org.apache.aries.blueprint.mutable.MutableMapEntry)4 CollectionMetadata (org.osgi.service.blueprint.reflect.CollectionMetadata)4 ComponentMetadata (org.osgi.service.blueprint.reflect.ComponentMetadata)4 MapMetadata (org.osgi.service.blueprint.reflect.MapMetadata)4 Metadata (org.osgi.service.blueprint.reflect.Metadata)4 RefMetadata (org.osgi.service.blueprint.reflect.RefMetadata)4 ServiceReferenceMetadata (org.osgi.service.blueprint.reflect.ServiceReferenceMetadata)4 WrappedServiceMetadata (org.apache.aries.application.modelling.WrappedServiceMetadata)3 ReferenceListMetadata (org.osgi.service.blueprint.reflect.ReferenceListMetadata)3 ValueMetadata (org.osgi.service.blueprint.reflect.ValueMetadata)3 ExtendedBeanMetadata (org.apache.aries.blueprint.ExtendedBeanMetadata)2 ArrayRecipe (org.apache.aries.blueprint.di.ArrayRecipe)2 CollectionRecipe (org.apache.aries.blueprint.di.CollectionRecipe)2 ComponentFactoryRecipe (org.apache.aries.blueprint.di.ComponentFactoryRecipe)2 DependentComponentFactoryRecipe (org.apache.aries.blueprint.di.DependentComponentFactoryRecipe)2 IdRefRecipe (org.apache.aries.blueprint.di.IdRefRecipe)2