use of org.apache.aries.blueprint.PassThroughMetadata 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.PassThroughMetadata 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.PassThroughMetadata in project admin-console-beta by connexta.
the class BundleUtils method populateServices.
private void populateServices(Bundle bundle, BundleField toPopulate) {
Optional<BlueprintContainer> blueprintContainer = getBlueprintContainer(bundle);
if (blueprintContainer.isPresent()) {
List<ComponentMetadata> cmpMetas = blueprintContainer.get().getComponentIds().stream().map(id -> blueprintContainer.get().getComponentMetadata(id)).collect(Collectors.toList());
for (ComponentMetadata meta : cmpMetas) {
if (meta instanceof ReferenceListMetadata) {
populateServiceRefLists((ReferenceListMetadata) meta, bundle, toPopulate);
} else if (meta instanceof ReferenceMetadata) {
populateServiceRef((ReferenceMetadata) meta, bundle, toPopulate);
} else if (meta instanceof BeanMetadata || meta instanceof ServiceMetadata || meta instanceof PassThroughMetadata) {
continue;
} else {
LOGGER.warn("Unable to handle blueprint metadata of type {} for bundle {}.", meta.getClass(), bundle.getSymbolicName());
}
}
getRegisteredServices(bundle).forEach(ref -> toPopulate.addService(createServiceField(ref)));
}
}
use of org.apache.aries.blueprint.PassThroughMetadata in project aries by apache.
the class Aries1503bNamespaceHandler method parse.
@Override
public Metadata parse(Element element, ParserContext context) {
MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
metadata.setProcessor(true);
metadata.setId("aries-1503");
metadata.setScope(BeanMetadata.SCOPE_SINGLETON);
metadata.addArgument(new PassThroughMetadata() {
@Override
public Object getObject() {
return "ARIES-1503";
}
@Override
public String getId() {
return "aries-1503-arg";
}
@Override
public int getActivation() {
return 0;
}
@Override
public List<String> getDependsOn() {
return null;
}
}, null, 0);
metadata.setRuntimeClass(String.class);
return metadata;
}
use of org.apache.aries.blueprint.PassThroughMetadata in project aries by apache.
the class Aries1682NamespaceHandler method parse.
@Override
public Metadata parse(Element element, ParserContext context) {
MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
metadata.setProcessor(true);
metadata.setId("aries-1682");
metadata.setScope(BeanMetadata.SCOPE_SINGLETON);
metadata.addArgument(new PassThroughMetadata() {
@Override
public Object getObject() {
return "ARIES-1682";
}
@Override
public String getId() {
return "aries-1682-arg";
}
@Override
public int getActivation() {
return 0;
}
@Override
public List<String> getDependsOn() {
return null;
}
}, null, 0);
metadata.setRuntimeClass(String.class);
return metadata;
}
Aggregations