use of org.springframework.beans.factory.support.ManagedList in project redisson by redisson.
the class RedissonLiveObjectDefinitionParser method parseNested.
@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
Class<?> apiClass;
try {
apiClass = Class.forName(helper.getAttribute(element, RedissonNamespaceParserSupport.CLASS_ATTRIBUTE));
} catch (ClassNotFoundException ex) {
throw new IllegalArgumentException("The class [" + helper.getAttribute(element, RedissonNamespaceParserSupport.CLASS_ATTRIBUTE) + "] specified in \"api-class\" attribute has not " + "found. Please check the class path.", ex);
}
Assert.state(helper.hasAttribute(element, RedissonNamespaceParserSupport.OBJECT_ID_ATTRIBUTE) || helper.hasAttribute(element, RedissonNamespaceParserSupport.OBJECT_ID_REF_ATTRIBUTE), "One of \"" + RedissonNamespaceParserSupport.OBJECT_ID_ATTRIBUTE + "\" or \"" + RedissonNamespaceParserSupport.OBJECT_ID_REF_ATTRIBUTE + "\" attribute is required in the \"" + RedissonNamespaceParserSupport.LIVE_OBJECT_ELEMENT + "\" element.");
builder.addPropertyValue("targetObject", new RuntimeBeanReference(helper.getAttribute(element, RedissonNamespaceParserSupport.LIVE_OBJECT_SERVICE_REF_ATTRIBUTE)));
builder.addPropertyValue("targetMethod", "get");
ManagedList args = new ManagedList();
args.add(apiClass);
if (helper.hasAttribute(element, RedissonNamespaceParserSupport.OBJECT_ID_ATTRIBUTE)) {
args.add(helper.getAttribute(element, RedissonNamespaceParserSupport.OBJECT_ID_ATTRIBUTE));
}
if (helper.hasAttribute(element, RedissonNamespaceParserSupport.OBJECT_ID_REF_ATTRIBUTE)) {
args.add(new RuntimeBeanReference(helper.getAttribute(element, RedissonNamespaceParserSupport.OBJECT_ID_REF_ATTRIBUTE)));
}
builder.addPropertyValue("arguments", args);
}
use of org.springframework.beans.factory.support.ManagedList in project redisson by redisson.
the class RedissonMultiLockDefinitionParser method parseNested.
@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
bd.setDependsOn(element.getAttribute(RedissonNamespaceParserSupport.REDISSON_REF_ATTRIBUTE));
List<Element> childElements = DomUtils.getChildElements(element);
for (Element elt : childElements) {
String localName = elt.getLocalName();
if (BeanDefinitionParserDelegate.QUALIFIER_ELEMENT.equals(localName)) {
//parsed elsewhere
continue;
}
String id;
if (BeanDefinitionParserDelegate.REF_ELEMENT.equals(localName)) {
id = elt.getAttribute(BeanDefinitionParserDelegate.BEAN_REF_ATTRIBUTE);
} else {
if (!elt.hasAttribute(RedissonNamespaceParserSupport.REDISSON_REF_ATTRIBUTE)) {
helper.setAttribute(elt, RedissonNamespaceParserSupport.REDISSON_REF_ATTRIBUTE, element.getAttribute(RedissonNamespaceParserSupport.REDISSON_REF_ATTRIBUTE));
}
helper.populateIdAttribute(elt, builder, parserContext);
parserContext.getDelegate().parseCustomElement(elt, bd);
id = elt.getAttribute(RedissonNamespaceParserSupport.ID_ATTRIBUTE);
}
ConstructorArgumentValues args = builder.getRawBeanDefinition().getConstructorArgumentValues();
if (args.getArgumentCount() > 0) {
ConstructorArgumentValues.ValueHolder value = args.getIndexedArgumentValues().get(0);
ManagedList list;
if (value.getValue() instanceof ManagedList) {
list = (ManagedList) value.getValue();
} else {
list = new ManagedList();
list.add(value.getValue());
value.setValue(list);
value.setType(ManagedList.class.getName());
}
list.add(new RuntimeBeanReference(id));
} else {
builder.addConstructorArgReference(id);
}
}
}
use of org.springframework.beans.factory.support.ManagedList in project sharding-jdbc by dangdangdotcom.
the class ShardingJdbcDataSourceBeanDefinitionParser method parseBindingTablesConfig.
private List<BeanDefinition> parseBindingTablesConfig(final Element element) {
Element bindingTableRulesElement = DomUtils.getChildElementByTagName(element, ShardingJdbcDataSourceBeanDefinitionParserTag.BINDING_TABLE_RULES_TAG);
if (null == bindingTableRulesElement) {
return Collections.emptyList();
}
List<Element> bindingTableRuleElements = DomUtils.getChildElementsByTagName(bindingTableRulesElement, ShardingJdbcDataSourceBeanDefinitionParserTag.BINDING_TABLE_RULE_TAG);
BeanDefinitionBuilder bindingTableRuleFactory = BeanDefinitionBuilder.rootBeanDefinition(BindingTableRuleConfig.class);
List<BeanDefinition> result = new ManagedList<>(bindingTableRuleElements.size());
for (Element bindingTableRuleElement : bindingTableRuleElements) {
bindingTableRuleFactory.addPropertyValue("tableNames", bindingTableRuleElement.getAttribute(ShardingJdbcDataSourceBeanDefinitionParserTag.LOGIC_TABLES_ATTRIBUTE));
result.add(bindingTableRuleFactory.getBeanDefinition());
}
return result;
}
use of org.springframework.beans.factory.support.ManagedList in project elastic-job by dangdangdotcom.
the class AbstractJobBeanDefinitionParser method createJobListeners.
private List<BeanDefinition> createJobListeners(final Element element) {
Element listenerElement = DomUtils.getChildElementByTagName(element, LISTENER_TAG);
Element distributedListenerElement = DomUtils.getChildElementByTagName(element, DISTRIBUTED_LISTENER_TAG);
List<BeanDefinition> result = new ManagedList<>(2);
if (null != listenerElement) {
BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(listenerElement.getAttribute(CLASS_ATTRIBUTE));
factory.setScope(BeanDefinition.SCOPE_PROTOTYPE);
result.add(factory.getBeanDefinition());
}
if (null != distributedListenerElement) {
BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(distributedListenerElement.getAttribute(CLASS_ATTRIBUTE));
factory.setScope(BeanDefinition.SCOPE_PROTOTYPE);
factory.addConstructorArgValue(distributedListenerElement.getAttribute(DISTRIBUTED_LISTENER_STARTED_TIMEOUT_MILLISECONDS_ATTRIBUTE));
factory.addConstructorArgValue(distributedListenerElement.getAttribute(DISTRIBUTED_LISTENER_COMPLETED_TIMEOUT_MILLISECONDS_ATTRIBUTE));
result.add(factory.getBeanDefinition());
}
return result;
}
use of org.springframework.beans.factory.support.ManagedList in project spring-framework by spring-projects.
the class AnnotationDrivenBeanDefinitionParser method getDeferredResultInterceptors.
private ManagedList<?> getDeferredResultInterceptors(Element element, Object source, ParserContext parserContext) {
ManagedList<? super Object> interceptors = new ManagedList<>();
Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
if (asyncElement != null) {
Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "deferred-result-interceptors");
if (interceptorsElement != null) {
interceptors.setSource(source);
for (Element converter : DomUtils.getChildElementsByTagName(interceptorsElement, "bean")) {
BeanDefinitionHolder beanDef = parserContext.getDelegate().parseBeanDefinitionElement(converter);
beanDef = parserContext.getDelegate().decorateBeanDefinitionIfRequired(converter, beanDef);
interceptors.add(beanDef);
}
}
}
return interceptors;
}
Aggregations