use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.
the class AbstractParserProxy method parse.
public List<? extends WrappedServiceMetadata> parse(InputStream blueprintToParse) throws Exception {
_logger.debug(LOG_ENTRY, "parse", new Object[] { blueprintToParse });
ComponentDefinitionRegistry cdr = parseCDR(blueprintToParse);
List<? extends WrappedServiceMetadata> result = parseCDRForServices(cdr, true);
_logger.debug(LOG_EXIT, "parse", new Object[] { result });
return result;
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.
the class AbstractParserProxy method parseAllServiceElements.
public ParsedServiceElements parseAllServiceElements(InputStream blueprintToParse) throws Exception {
_logger.debug(LOG_ENTRY, "parseAllServiceElements", new Object[] { blueprintToParse });
ComponentDefinitionRegistry cdr = parseCDR(blueprintToParse);
Collection<ExportedService> services = parseCDRForServices(cdr, false);
Collection<ImportedService> references = parseCDRForReferences(cdr);
ParsedServiceElements result = _modellingManager.getParsedServiceElements(services, references);
_logger.debug(LOG_EXIT, "parseAllServiceElements", new Object[] { result });
return result;
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.
the class BlueprintNamespaceHandler method parse.
@Override
public Metadata parse(Element element, ParserContext parserContext) {
try {
// Get the spring context
org.springframework.beans.factory.xml.ParserContext springContext = getOrCreateParserContext(parserContext);
// Parse spring bean
BeanDefinition bd = springHandler.parse(element, springContext);
for (String name : springContext.getRegistry().getBeanDefinitionNames()) {
if (springContext.getRegistry().getBeanDefinition(name) == bd) {
ComponentDefinitionRegistry registry = parserContext.getComponentDefinitionRegistry();
if (registry.containsComponentDefinition(name)) {
// Hack: we can't really make the difference between a top level bean
// and an inlined bean when using custom (eventually nested) namespaces.
// To work around the problem, the BlueprintBeanFactory will always register
// a BeanMetadata for each bean, but here, we unregister it and return it instead
// so that the caller is responsible for registering the metadata.
ComponentMetadata metadata = registry.getComponentDefinition(name);
registry.removeComponentDefinition(name);
return metadata;
}
}
}
return null;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project camel by apache.
the class CamelNamespaceHandler method getDataformatResolverReference.
private static ComponentMetadata getDataformatResolverReference(ParserContext context, String dataformat) {
// we cannot resolve dataformat names using property placeholders at this point in time
if (dataformat.startsWith(PropertiesComponent.DEFAULT_PREFIX_TOKEN)) {
return null;
}
ComponentDefinitionRegistry componentDefinitionRegistry = context.getComponentDefinitionRegistry();
ComponentMetadata cm = componentDefinitionRegistry.getComponentDefinition(".camelBlueprint.dataformatResolver." + dataformat);
if (cm == null) {
MutableReferenceMetadata svc = context.createMetadata(MutableReferenceMetadata.class);
svc.setId(".camelBlueprint.dataformatResolver." + dataformat);
svc.setFilter("(dataformat=" + dataformat + ")");
svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(dataformat) ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
try {
// Try to set the runtime interface (only with aries blueprint > 0.1
svc.getClass().getMethod("setRuntimeInterface", Class.class).invoke(svc, DataFormatResolver.class);
} catch (Throwable t) {
// Check if the bundle can see the class
try {
PassThroughMetadata ptm = (PassThroughMetadata) componentDefinitionRegistry.getComponentDefinition("blueprintBundle");
Bundle b = (Bundle) ptm.getObject();
if (b.loadClass(DataFormatResolver.class.getName()) != DataFormatResolver.class) {
throw new UnsupportedOperationException();
}
svc.setInterface(DataFormatResolver.class.getName());
} catch (Throwable t2) {
throw new UnsupportedOperationException();
}
}
componentDefinitionRegistry.registerComponentDefinition(svc);
cm = svc;
}
return cm;
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.
the class CmNamespaceHandler method decorate.
public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
LOGGER.debug("Decorating node {{}}{}", node.getNamespaceURI(), node.getLocalName());
ComponentDefinitionRegistry registry = context.getComponentDefinitionRegistry();
registerManagedObjectManager(context, registry);
if (node instanceof Element) {
if (nodeNameEquals(node, MANAGED_PROPERTIES_ELEMENT)) {
return decorateManagedProperties(context, (Element) node, component);
} else if (nodeNameEquals(node, CM_PROPERTIES_ELEMENT)) {
return decorateCmProperties(context, (Element) node, component);
} else {
throw new ComponentDefinitionException("Unsupported element: " + node.getNodeName());
}
} else {
throw new ComponentDefinitionException("Illegal use of blueprint cm namespace");
}
}
Aggregations