use of org.osgi.service.blueprint.reflect.ReferenceListener in project aries by apache.
the class ServiceReferenceMetadataImpl method addServiceListener.
public ReferenceListener addServiceListener(Target listenerComponent, String bindMethodName, String unbindMethodName) {
ReferenceListener listener = new ReferenceListenerImpl(listenerComponent, bindMethodName, unbindMethodName);
addServiceListener(listener);
return listener;
}
use of org.osgi.service.blueprint.reflect.ReferenceListener 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.ReferenceListener in project aries by apache.
the class RecipeBuilder method createReferenceListRecipe.
private Recipe createReferenceListRecipe(ReferenceListMetadata 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));
}
}
ReferenceListRecipe recipe = new ReferenceListRecipe(getName(metadata.getId()), blueprintContainer, metadata, filterRecipe, listenersRecipe, getDependencies(metadata));
return recipe;
}
use of org.osgi.service.blueprint.reflect.ReferenceListener 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;
}
use of org.osgi.service.blueprint.reflect.ReferenceListener 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);
}
}
}
Aggregations