use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project camel by apache.
the class CamelNamespaceHandler method getLanguageResolverReference.
private static ComponentMetadata getLanguageResolverReference(ParserContext context, String language) {
// we cannot resolve language names using property placeholders at this point in time
if (language.startsWith(PropertiesComponent.DEFAULT_PREFIX_TOKEN)) {
return null;
}
ComponentDefinitionRegistry componentDefinitionRegistry = context.getComponentDefinitionRegistry();
ComponentMetadata cm = componentDefinitionRegistry.getComponentDefinition(".camelBlueprint.languageResolver." + language);
if (cm == null) {
MutableReferenceMetadata svc = context.createMetadata(MutableReferenceMetadata.class);
svc.setId(".camelBlueprint.languageResolver." + language);
svc.setFilter("(language=" + language + ")");
svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(language) ? 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, LanguageResolver.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(LanguageResolver.class.getName()) != LanguageResolver.class) {
throw new UnsupportedOperationException();
}
svc.setInterface(LanguageResolver.class.getName());
} catch (Throwable t2) {
throw new UnsupportedOperationException();
}
}
componentDefinitionRegistry.registerComponentDefinition(svc);
cm = svc;
}
return cm;
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project camel by apache.
the class CamelNamespaceHandler method getComponentResolverReference.
private static ComponentMetadata getComponentResolverReference(ParserContext context, String component) {
// we cannot resolve component names using property placeholders at this point in time
if (component.startsWith(PropertiesComponent.DEFAULT_PREFIX_TOKEN)) {
return null;
}
ComponentDefinitionRegistry componentDefinitionRegistry = context.getComponentDefinitionRegistry();
ComponentMetadata cm = componentDefinitionRegistry.getComponentDefinition(".camelBlueprint.componentResolver." + component);
if (cm == null) {
MutableReferenceMetadata svc = context.createMetadata(MutableReferenceMetadata.class);
svc.setId(".camelBlueprint.componentResolver." + component);
svc.setFilter("(component=" + component + ")");
svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(component) ? 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, ComponentResolver.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(ComponentResolver.class.getName()) != ComponentResolver.class) {
throw new UnsupportedOperationException();
}
svc.setInterface(ComponentResolver.class.getName());
} catch (Throwable t2) {
throw new UnsupportedOperationException();
}
}
componentDefinitionRegistry.registerComponentDefinition(svc);
cm = svc;
}
return cm;
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project controller by opendaylight.
the class OpendaylightNamespaceHandler method registerNotificationServiceRefBean.
private static void registerNotificationServiceRefBean(final ParserContext context) {
ComponentDefinitionRegistry registry = context.getComponentDefinitionRegistry();
if (registry.getComponentDefinition(NOTIFICATION_SERVICE_NAME) == null) {
MutableReferenceMetadata metadata = createServiceRef(context, NotificationService.class, null);
metadata.setId(NOTIFICATION_SERVICE_NAME);
registry.registerComponentDefinition(metadata);
}
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project controller by opendaylight.
the class OpendaylightNamespaceHandler method registerComponentProcessor.
private static MutableBeanMetadata registerComponentProcessor(final ParserContext context) {
ComponentDefinitionRegistry registry = context.getComponentDefinitionRegistry();
MutableBeanMetadata metadata = (MutableBeanMetadata) registry.getComponentDefinition(COMPONENT_PROCESSOR_NAME);
if (metadata == null) {
metadata = createBeanMetadata(context, COMPONENT_PROCESSOR_NAME, ComponentProcessor.class, false, true);
metadata.setProcessor(true);
addBlueprintBundleRefProperty(context, metadata);
metadata.addProperty("blueprintContainerRestartService", createServiceRef(context, BlueprintContainerRestartService.class, null));
LOG.debug("Registering ComponentProcessor bean: {}", metadata);
registry.registerComponentDefinition(metadata);
}
return metadata;
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project controller by opendaylight.
the class OpendaylightNamespaceHandler method registerRefBean.
private static void registerRefBean(final ParserContext context, final String name, final Class<?> clazz) {
ComponentDefinitionRegistry registry = context.getComponentDefinitionRegistry();
if (registry.getComponentDefinition(name) == null) {
MutableReferenceMetadata metadata = createServiceRef(context, clazz, null);
metadata.setId(name);
registry.registerComponentDefinition(metadata);
}
}
Aggregations