use of org.springframework.beans.factory.config.RuntimeBeanReference in project dubbo by alibaba.
the class DubboBeanDefinitionParser method parseMultiRef.
@SuppressWarnings("unchecked")
private static void parseMultiRef(String property, String value, RootBeanDefinition beanDefinition, ParserContext parserContext) {
String[] values = value.split("\\s*[,]+\\s*");
ManagedList list = null;
for (int i = 0; i < values.length; i++) {
String v = values[i];
if (v != null && v.length() > 0) {
if (list == null) {
list = new ManagedList();
}
list.add(new RuntimeBeanReference(v));
}
}
beanDefinition.getPropertyValues().addPropertyValue(property, list);
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project dubbo by alibaba.
the class DubboBeanDefinitionParser method parseNested.
private static void parseNested(Element element, ParserContext parserContext, Class<?> beanClass, boolean required, String tag, String property, String ref, BeanDefinition beanDefinition) {
NodeList nodeList = element.getChildNodes();
if (nodeList != null && nodeList.getLength() > 0) {
boolean first = true;
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node instanceof Element) {
if (tag.equals(node.getNodeName()) || tag.equals(node.getLocalName())) {
if (first) {
first = false;
String isDefault = element.getAttribute("default");
if (isDefault == null || isDefault.length() == 0) {
beanDefinition.getPropertyValues().addPropertyValue("default", "false");
}
}
BeanDefinition subDefinition = parse((Element) node, parserContext, beanClass, required);
if (subDefinition != null && ref != null && ref.length() > 0) {
subDefinition.getPropertyValues().addPropertyValue(property, new RuntimeBeanReference(ref));
}
}
}
}
}
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterParser method parseConverter.
public BeanMetadataElement parseConverter(Element element, ParserContext parserContext) {
String converterRef = element.getAttribute("ref");
if (StringUtils.hasText(converterRef)) {
return new RuntimeBeanReference(converterRef);
}
Element beanElement = DomUtils.getChildElementByTagName(element, "bean");
if (beanElement != null) {
BeanDefinitionHolder beanDef = parserContext.getDelegate().parseBeanDefinitionElement(beanElement);
beanDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(beanElement, beanDef);
return beanDef;
}
parserContext.getReaderContext().error("Element <converter> must specify 'ref' or contain a bean definition for the converter", element);
return null;
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project cxf by apache.
the class BusWiringBeanFactoryPostProcessor method getBusForName.
private Object getBusForName(String name, ConfigurableListableBeanFactory factory, boolean create, String cn) {
if (!factory.containsBeanDefinition(name) && (create || Bus.DEFAULT_BUS_ID.equals(name))) {
DefaultListableBeanFactory df = (DefaultListableBeanFactory) factory;
RootBeanDefinition rbd = new RootBeanDefinition(SpringBus.class);
if (cn != null) {
rbd.setAttribute("busConfig", new RuntimeBeanReference(cn));
}
df.registerBeanDefinition(name, rbd);
} else if (cn != null) {
BeanDefinition bd = factory.getBeanDefinition(name);
bd.getPropertyValues().addPropertyValue("busConfig", new RuntimeBeanReference(cn));
}
return new RuntimeBeanReference(name);
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project leopard by tanhaichao.
the class MemdbBeanDefinitionParserTest method parse.
@Test
public void parse() {
MemdbBeanDefinitionParser beanDefinitionParser = Mockito.spy(new MemdbBeanDefinitionParser());
Mockito.doReturn("1").when(this.element).getAttribute("maxSize");
Mockito.doReturn("redis").when(this.element).getAttribute("redis-ref");
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition();
beanDefinitionParser.doParse(element, builder);
RuntimeBeanReference redisReference = (RuntimeBeanReference) builder.getBeanDefinition().getPropertyValues().getPropertyValue("redis").getValue();
Assert.assertEquals("redis", redisReference.getBeanName());
}
Aggregations