use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.
the class NSHandlerHeight method parse.
//process elements
public Metadata parse(Element element, ParserContext context) {
Metadata retval = null;
if (element.getLocalName().equals(ELT_NAME)) {
final String id = element.getAttributeNS(NSURI, ATTRIB_ID);
MutableBeanMetadata bm = context.createMetadata(MutableBeanMetadata.class);
bm.setId(id);
bm.setScope("PROTOTYPE");
bm.setClassName(TestBean.class.getName());
retval = bm;
}
return retval;
}
use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.
the class TxNamespaceHandler method createAnnotationParserBean.
private MutableBeanMetadata createAnnotationParserBean(ParserContext pc, ComponentDefinitionRegistry cdr) {
MutableBeanMetadata meta = pc.createMetadata(MutableBeanMetadata.class);
meta.setId(ANNOTATION_PARSER_BEAN_NAME);
meta.setRuntimeClass(AnnotationProcessor.class);
meta.setProcessor(true);
meta.addArgument(passThrough(pc, cdr), ComponentDefinitionRegistry.class.getName(), 0);
meta.addArgument(passThrough(pc, tm), TransactionManager.class.getName(), 1);
meta.addArgument(passThrough(pc, coordinator), Coordinator.class.getName(), 1);
return meta;
}
use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.
the class CmNamespaceHandler method decorateCmProperties.
private ComponentMetadata decorateCmProperties(ParserContext context, Element element, ComponentMetadata component) {
generateIdIfNeeded(context, ((MutableComponentMetadata) component));
MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
metadata.setProcessor(true);
metadata.setId(getId(context, element));
metadata.setRuntimeClass(CmProperties.class);
String persistentId = element.getAttribute(PERSISTENT_ID_ATTRIBUTE);
// ManagedService if the persistentId is not an empty string.
if (persistentId.length() > 0) {
metadata.setInitMethod("init");
metadata.setDestroyMethod("destroy");
}
metadata.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
metadata.addProperty("configAdmin", createConfigurationAdminRef(context));
metadata.addProperty("managedObjectManager", createRef(context, MANAGED_OBJECT_MANAGER_NAME));
metadata.addProperty("persistentId", createValue(context, persistentId));
if (element.hasAttribute(UPDATE_ATTRIBUTE)) {
metadata.addProperty("update", createValue(context, element.getAttribute(UPDATE_ATTRIBUTE)));
}
metadata.addProperty("serviceId", createIdRef(context, component.getId()));
context.getComponentDefinitionRegistry().registerComponentDefinition(metadata);
return component;
}
use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.
the class CmNamespaceHandler method parseCmProperties.
private ComponentMetadata parseCmProperties(ParserContext context, Element element) {
String id = getId(context, element);
MutableBeanMetadata factoryMetadata = context.createMetadata(MutableBeanMetadata.class);
generateIdIfNeeded(context, factoryMetadata);
factoryMetadata.setScope(BeanMetadata.SCOPE_SINGLETON);
factoryMetadata.setRuntimeClass(CmProperties.class);
factoryMetadata.setInitMethod("init");
factoryMetadata.setDestroyMethod("destroy");
factoryMetadata.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
factoryMetadata.addProperty("configAdmin", createConfigurationAdminRef(context));
factoryMetadata.addProperty("managedObjectManager", createRef(context, MANAGED_OBJECT_MANAGER_NAME));
String persistentId = element.getAttribute(PERSISTENT_ID_ATTRIBUTE);
factoryMetadata.addProperty("persistentId", createValue(context, persistentId));
context.getComponentDefinitionRegistry().registerComponentDefinition(factoryMetadata);
MutableBeanMetadata propertiesMetadata = context.createMetadata(MutableBeanMetadata.class);
propertiesMetadata.setId(id);
propertiesMetadata.setScope(BeanMetadata.SCOPE_SINGLETON);
propertiesMetadata.setRuntimeClass(Properties.class);
propertiesMetadata.setFactoryComponent(createRef(context, factoryMetadata.getId()));
propertiesMetadata.setFactoryComponent(factoryMetadata);
propertiesMetadata.setFactoryMethod("getProperties");
// Work around ARIES-877
propertiesMetadata.setDependsOn(Arrays.asList(factoryMetadata.getId()));
return propertiesMetadata;
}
use of org.apache.aries.blueprint.mutable.MutableBeanMetadata in project aries by apache.
the class AbstractPropertyPlaceholder method processBeanMetadata.
protected Metadata processBeanMetadata(BeanMetadata component) {
for (BeanArgument arg : component.getArguments()) {
try {
processingStack.add("Argument index " + arg.getIndex() + " and value type " + arg.getValueType() + "->");
if (arg instanceof MutableBeanArgument) {
((MutableBeanArgument) arg).setValue(processMetadata(arg.getValue()));
} else {
//Say that we can't change this argument, but continue processing
//If the value is mutable then we may be ok!
printWarning(arg, "Constructor Argument");
processMetadata(arg.getValue());
}
} finally {
processingStack.removeLast();
}
}
for (BeanProperty prop : component.getProperties()) {
try {
processingStack.add("Property named " + prop.getName() + "->");
if (prop instanceof MutableBeanProperty) {
((MutableBeanProperty) prop).setValue(processMetadata(prop.getValue()));
} else {
//Say that we can't change this property, but continue processing
//If the value is mutable then we may be ok!
printWarning(prop, "Injection Property");
processMetadata(prop.getValue());
}
} finally {
processingStack.removeLast();
}
}
Target factoryComponent = component.getFactoryComponent();
if (factoryComponent != null) {
try {
if (component instanceof MutableBeanMetadata) {
processingStack.add("Factory Component->");
((MutableBeanMetadata) component).setFactoryComponent((Target) processMetadata(factoryComponent));
} else {
printWarning(component, "Factory Component");
processingStack.add("Factory Component->");
processMetadata(factoryComponent);
}
} finally {
processingStack.removeLast();
}
}
return component;
}
Aggregations