use of org.apache.aries.blueprint.ExtendedBeanMetadata in project camel by apache.
the class BlueprintPropertiesParser method lookupPropertyPlaceholderIds.
/**
* Lookup the ids of the Blueprint property placeholder services in the
* Blueprint container.
*
* @return the ids, will be an empty array if none found.
*/
public String[] lookupPropertyPlaceholderIds() {
List<String> ids = new ArrayList<String>();
for (Object componentId : container.getComponentIds()) {
String id = (String) componentId;
ComponentMetadata meta = container.getComponentMetadata(id);
if (meta instanceof ExtendedBeanMetadata) {
Class<?> clazz = ((ExtendedBeanMetadata) meta).getRuntimeClass();
if (clazz != null && AbstractPropertyPlaceholder.class.isAssignableFrom(clazz)) {
ids.add(id);
}
}
}
return ids.toArray(new String[ids.size()]);
}
use of org.apache.aries.blueprint.ExtendedBeanMetadata in project aries by apache.
the class BlueprintContainerImpl method processProcessors.
private void processProcessors() throws Exception {
// Instantiate ComponentDefinitionRegistryProcessor and BeanProcessor
for (BeanMetadata bean : getMetadata(BeanMetadata.class)) {
if (bean instanceof ExtendedBeanMetadata && !((ExtendedBeanMetadata) bean).isProcessor()) {
continue;
}
Class clazz = null;
if (bean instanceof ExtendedBeanMetadata) {
clazz = ((ExtendedBeanMetadata) bean).getRuntimeClass();
}
if (clazz == null && bean.getClassName() != null) {
clazz = loadClass(bean.getClassName());
}
if (clazz == null) {
continue;
}
if (ComponentDefinitionRegistryProcessor.class.isAssignableFrom(clazz)) {
Object obj = repository.create(bean.getId(), Arrays.<Class<?>>asList(ComponentDefinitionRegistryProcessor.class));
((ComponentDefinitionRegistryProcessor) obj).process(componentDefinitionRegistry);
} else if (Processor.class.isAssignableFrom(clazz)) {
Object obj = repository.create(bean.getId(), Arrays.<Class<?>>asList(Processor.class));
this.processors.add((Processor) obj);
} else {
continue;
}
updateUninstantiatedRecipes();
}
}
use of org.apache.aries.blueprint.ExtendedBeanMetadata in project aries by apache.
the class PlaceholdersUtils method validatePlaceholder.
public static void validatePlaceholder(MutableBeanMetadata metadata, ComponentDefinitionRegistry registry) {
String prefix = getPlaceholderProperty(metadata, "placeholderPrefix");
String suffix = getPlaceholderProperty(metadata, "placeholderSuffix");
for (String id : registry.getComponentDefinitionNames()) {
ComponentMetadata component = registry.getComponentDefinition(id);
if (component instanceof ExtendedBeanMetadata) {
ExtendedBeanMetadata bean = (ExtendedBeanMetadata) component;
if (bean.getRuntimeClass() != null && AbstractPropertyPlaceholderExt.class.isAssignableFrom(bean.getRuntimeClass())) {
String otherPrefix = getPlaceholderProperty(bean, "placeholderPrefix");
String otherSuffix = getPlaceholderProperty(bean, "placeholderSuffix");
if (prefix.equals(otherPrefix) && suffix.equals(otherSuffix)) {
throw new ComponentDefinitionException("Multiple placeholders with the same prefix and suffix are not allowed");
}
}
}
}
}
use of org.apache.aries.blueprint.ExtendedBeanMetadata in project aries by apache.
the class SpringBeanProcessor method getProcessors.
private <T> List<T> getProcessors(Class<T> type) {
List<T> processors = new ArrayList<T>();
if (!creatingProcessor) {
creatingProcessor = true;
for (BeanMetadata bean : blueprintContainer.getMetadata(BeanMetadata.class)) {
Class clazz = null;
if (bean instanceof ExtendedBeanMetadata) {
clazz = ((ExtendedBeanMetadata) bean).getRuntimeClass();
}
if (clazz == null && bean.getClassName() != null) {
try {
clazz = bundleContext.getBundle().loadClass(bean.getClassName());
} catch (ClassNotFoundException e) {
}
}
if (clazz == null) {
continue;
}
if (type.isAssignableFrom(clazz)) {
Object p = blueprintContainer.getComponentInstance(bean.getId());
processors.add(type.cast(p));
}
}
creatingProcessor = false;
}
return processors;
}
Aggregations