use of org.osgi.service.blueprint.reflect.BeanMetadata 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);
}
}
}
use of org.osgi.service.blueprint.reflect.BeanMetadata in project aries by apache.
the class BlueprintRepository method createInstances.
private Map<String, Object> createInstances(Collection<String> names) {
// Instance creation is synchronized inside each create method (via the use of futures), so that
// a recipe will only created once where appropriate
DependencyGraph graph = new DependencyGraph(this);
HashMap<String, Object> objects = new LinkedHashMap<String, Object>();
for (Map.Entry<String, Recipe> entry : graph.getSortedRecipes(names).entrySet()) {
String name = entry.getKey();
ComponentMetadata component = blueprintContainer.getComponentDefinitionRegistry().getComponentDefinition(name);
boolean prototype = (component instanceof BeanMetadata) && MetadataUtil.isPrototypeScope((BeanMetadata) component);
if (!prototype || names.contains(name)) {
objects.put(name, entry.getValue().create());
}
}
return objects;
}
use of org.osgi.service.blueprint.reflect.BeanMetadata 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.BeanMetadata in project aries by apache.
the class NSHandlerThree method decorate.
public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
if (node.getLocalName().equals(ATTRIB_ONE)) {
if (component instanceof BeanMetadata) {
if (context.getComponentDefinitionRegistry().getComponentDefinition(NSURI + "/BeanProcessor") == null) {
BeanMetadata bm = context.createMetadata(BeanMetadata.class);
MutableBeanMetadata mbm = (MutableBeanMetadata) bm;
mbm.setProcessor(true);
mbm.setRuntimeClass(BeanProcessorTest.class);
mbm.setScope(BeanMetadata.SCOPE_SINGLETON);
mbm.setId(NSURI + "/BeanProcessor");
context.getComponentDefinitionRegistry().registerComponentDefinition(mbm);
}
}
}
return component;
}
use of org.osgi.service.blueprint.reflect.BeanMetadata in project aries by apache.
the class AnnotationEnablingNameSpaceHandlerTest method testAnnotationEnabled.
@Test
public void testAnnotationEnabled() throws Exception {
ComponentDefinitionRegistry cdr = parseCDR("enable-annotations.xml");
checkCompTop(cdr);
BeanMetadata pmd = (BeanMetadata) cdr.getComponentDefinition(TxNamespaceHandler.ANNOTATION_PARSER_BEAN_NAME);
assertNotNull(pmd);
assertEquals(3, pmd.getArguments().size());
assertEquals(cdr, ((PassThroughMetadata) pmd.getArguments().get(0).getValue()).getObject());
// assertEquals(tm, ((PassThroughMetadata) pmd.getArguments().get(2).getValue()).getObject());
}
Aggregations