Search in sources :

Example 6 with ValueMetadata

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

the class AbstractPropertyPlaceholder method processServiceReferenceMetadata.

private Metadata processServiceReferenceMetadata(ServiceReferenceMetadata component) {
    if (component instanceof MutableServiceReferenceMetadata) {
        ValueMetadata valueMetadata = ((MutableServiceReferenceMetadata) component).getExtendedFilter();
        if (valueMetadata != null) {
            ((MutableServiceReferenceMetadata) component).setExtendedFilter(doProcessValueMetadata(valueMetadata));
        }
    }
    for (ReferenceListener listener : component.getReferenceListeners()) {
        Target listenerComponent = listener.getListenerComponent();
        try {
            processingStack.add("Reference Listener " + listenerComponent + "->");
            if (listener instanceof MutableReferenceListener) {
                ((MutableReferenceListener) 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, "Reference Binding Listener");
                processMetadata(listenerComponent);
            }
        } finally {
            processingStack.removeLast();
        }
    }
    return component;
}
Also used : MutableReferenceListener(org.apache.aries.blueprint.mutable.MutableReferenceListener) Target(org.osgi.service.blueprint.reflect.Target) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) MutableReferenceListener(org.apache.aries.blueprint.mutable.MutableReferenceListener) ReferenceListener(org.osgi.service.blueprint.reflect.ReferenceListener) MutableServiceReferenceMetadata(org.apache.aries.blueprint.mutable.MutableServiceReferenceMetadata)

Example 7 with ValueMetadata

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

the class RecipeBuilder method createReferenceRecipe.

private ReferenceRecipe createReferenceRecipe(ReferenceMetadata metadata) {
    ValueRecipe filterRecipe = null;
    if (metadata instanceof ExtendedReferenceMetadata) {
        ValueMetadata filterMetadata = ((ExtendedServiceReferenceMetadata) metadata).getExtendedFilter();
        if (filterMetadata != null) {
            filterRecipe = (ValueRecipe) getValue(filterMetadata, null);
        }
    }
    CollectionRecipe listenersRecipe = null;
    if (metadata.getReferenceListeners() != null) {
        listenersRecipe = new CollectionRecipe(getName(null), ArrayList.class, Object.class.getName());
        for (ReferenceListener listener : metadata.getReferenceListeners()) {
            listenersRecipe.add(createRecipe(listener));
        }
    }
    ReferenceRecipe recipe = new ReferenceRecipe(getName(metadata.getId()), blueprintContainer, metadata, filterRecipe, listenersRecipe, getDependencies(metadata));
    return recipe;
}
Also used : ExtendedReferenceMetadata(org.apache.aries.blueprint.ExtendedReferenceMetadata) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) ArrayList(java.util.ArrayList) ReferenceListener(org.osgi.service.blueprint.reflect.ReferenceListener) ExtendedServiceReferenceMetadata(org.apache.aries.blueprint.ExtendedServiceReferenceMetadata) ValueRecipe(org.apache.aries.blueprint.di.ValueRecipe) CollectionRecipe(org.apache.aries.blueprint.di.CollectionRecipe)

Example 8 with ValueMetadata

use of org.osgi.service.blueprint.reflect.ValueMetadata 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();
    }
}
Also used : MutablePropsMetadata(org.apache.aries.blueprint.mutable.MutablePropsMetadata) PropsMetadata(org.osgi.service.blueprint.reflect.PropsMetadata) CollectionMetadata(org.osgi.service.blueprint.reflect.CollectionMetadata) MutableCollectionMetadata(org.apache.aries.blueprint.mutable.MutableCollectionMetadata) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) ValueMetadata(org.osgi.service.blueprint.reflect.ValueMetadata) MapMetadata(org.osgi.service.blueprint.reflect.MapMetadata) MutableMapMetadata(org.apache.aries.blueprint.mutable.MutableMapMetadata)

Aggregations

ValueMetadata (org.osgi.service.blueprint.reflect.ValueMetadata)8 BeanMetadata (org.osgi.service.blueprint.reflect.BeanMetadata)5 CollectionMetadata (org.osgi.service.blueprint.reflect.CollectionMetadata)5 ArrayList (java.util.ArrayList)4 ComponentMetadata (org.osgi.service.blueprint.reflect.ComponentMetadata)4 MapMetadata (org.osgi.service.blueprint.reflect.MapMetadata)4 RefMetadata (org.osgi.service.blueprint.reflect.RefMetadata)4 ExtendedReferenceMetadata (org.apache.aries.blueprint.ExtendedReferenceMetadata)3 ExtendedServiceReferenceMetadata (org.apache.aries.blueprint.ExtendedServiceReferenceMetadata)3 CollectionRecipe (org.apache.aries.blueprint.di.CollectionRecipe)3 ValueRecipe (org.apache.aries.blueprint.di.ValueRecipe)3 Metadata (org.osgi.service.blueprint.reflect.Metadata)3 ReferenceListMetadata (org.osgi.service.blueprint.reflect.ReferenceListMetadata)3 ReferenceListener (org.osgi.service.blueprint.reflect.ReferenceListener)3 ServiceMetadata (org.osgi.service.blueprint.reflect.ServiceMetadata)3 WrappedServiceMetadata (org.apache.aries.application.modelling.WrappedServiceMetadata)2 MutableMapMetadata (org.apache.aries.blueprint.mutable.MutableMapMetadata)2 MapEntry (org.osgi.service.blueprint.reflect.MapEntry)2 NullMetadata (org.osgi.service.blueprint.reflect.NullMetadata)2 PropsMetadata (org.osgi.service.blueprint.reflect.PropsMetadata)2