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 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 hudson-2.x by hudson.
the class BeanBuilder method manageMapIfNecessary.
/**
* Checks whether there are any runtime refs inside a Map and converts
* it to a ManagedMap if necessary
*
* @param value The current map
* @return A ManagedMap or a normal map
*/
private Object manageMapIfNecessary(Object value) {
Map<Object, Object> map = (Map) value;
boolean containsRuntimeRefs = false;
for (Entry<Object, Object> e : map.entrySet()) {
Object v = e.getValue();
if (v instanceof RuntimeBeanReference) {
containsRuntimeRefs = true;
}
if (v instanceof BeanConfiguration) {
BeanConfiguration c = (BeanConfiguration) v;
e.setValue(c.getBeanDefinition());
containsRuntimeRefs = true;
}
}
if (containsRuntimeRefs) {
// return new ManagedMap(map);
ManagedMap m = new ManagedMap();
m.putAll(map);
return m;
}
return value;
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project hudson-2.x by hudson.
the class BeanBuilder method methodMissing.
/**
* This method is invoked by Groovy when a method that's not defined in Java is invoked.
* We use that as a syntax for bean definition.
*/
public Object methodMissing(String name, Object arg) {
Object[] args = (Object[]) arg;
if (args.length == 0)
throw new MissingMethodException(name, getClass(), args);
if (args[0] instanceof Closure) {
// abstract bean definition
return invokeBeanDefiningMethod(name, args);
} else if (args[0] instanceof Class || args[0] instanceof RuntimeBeanReference || args[0] instanceof Map) {
return invokeBeanDefiningMethod(name, args);
} else if (args.length > 1 && args[args.length - 1] instanceof Closure) {
return invokeBeanDefiningMethod(name, args);
}
WebApplicationContext ctx = springConfig.getUnrefreshedApplicationContext();
MetaClass mc = DefaultGroovyMethods.getMetaClass(ctx);
if (!mc.respondsTo(ctx, name, args).isEmpty()) {
return mc.invokeMethod(ctx, name, args);
}
return this;
}
use of org.springframework.beans.factory.config.RuntimeBeanReference in project redisson by redisson.
the class DelayedQueueDecorator method decorate.
@Override
public void decorate(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, RedissonNamespaceParserSupport helper) {
Assert.state(element.hasAttribute(DESTINATION_QUEUE_REF), "Illegal state. property \"" + DESTINATION_QUEUE_REF + "\" is required in the \"" + helper.getName(element) + "\" element.");
helper.addConstructorArgs(new RuntimeBeanReference(helper.getAttribute(element, DESTINATION_QUEUE_REF)), RQueue.class, builder);
}
Aggregations