use of org.springframework.beans.factory.support.ManagedList in project spring-framework by spring-projects.
the class MessageBrokerBeanDefinitionParser method getMessageChannel.
private RuntimeBeanReference getMessageChannel(String name, Element element, ParserContext context, Object source) {
RootBeanDefinition executor;
if (element == null) {
executor = getDefaultExecutorBeanDefinition(name);
} else {
Element executorElem = DomUtils.getChildElementByTagName(element, "executor");
if (executorElem == null) {
executor = getDefaultExecutorBeanDefinition(name);
} else {
executor = new RootBeanDefinition(ThreadPoolTaskExecutor.class);
if (executorElem.hasAttribute("core-pool-size")) {
executor.getPropertyValues().add("corePoolSize", executorElem.getAttribute("core-pool-size"));
}
if (executorElem.hasAttribute("max-pool-size")) {
executor.getPropertyValues().add("maxPoolSize", executorElem.getAttribute("max-pool-size"));
}
if (executorElem.hasAttribute("keep-alive-seconds")) {
executor.getPropertyValues().add("keepAliveSeconds", executorElem.getAttribute("keep-alive-seconds"));
}
if (executorElem.hasAttribute("queue-capacity")) {
executor.getPropertyValues().add("queueCapacity", executorElem.getAttribute("queue-capacity"));
}
}
}
ConstructorArgumentValues argValues = new ConstructorArgumentValues();
if (executor != null) {
executor.getPropertyValues().add("threadNamePrefix", name + "-");
String executorName = name + "Executor";
registerBeanDefByName(executorName, executor, context, source);
argValues.addIndexedArgumentValue(0, new RuntimeBeanReference(executorName));
}
RootBeanDefinition channelDef = new RootBeanDefinition(ExecutorSubscribableChannel.class, argValues, null);
ManagedList<? super Object> interceptors = new ManagedList<>();
if (element != null) {
Element interceptorsElement = DomUtils.getChildElementByTagName(element, "interceptors");
interceptors.addAll(WebSocketNamespaceUtils.parseBeanSubElements(interceptorsElement, context));
}
interceptors.add(new ImmutableMessageChannelInterceptor());
channelDef.getPropertyValues().add("interceptors", interceptors);
registerBeanDefByName(name, channelDef, context, source);
return new RuntimeBeanReference(name);
}
use of org.springframework.beans.factory.support.ManagedList in project spring-framework by spring-projects.
the class ComponentBeanDefinitionParser method parseChildComponents.
private static void parseChildComponents(List<Element> childElements, BeanDefinitionBuilder factory) {
ManagedList<BeanDefinition> children = new ManagedList<>(childElements.size());
for (Element element : childElements) {
children.add(parseComponentElement(element));
}
factory.addPropertyValue("children", children);
}
use of org.springframework.beans.factory.support.ManagedList in project spring-framework by spring-projects.
the class AspectJAutoProxyBeanDefinitionParser method addIncludePatterns.
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) {
ManagedList<TypedStringValue> includePatterns = new ManagedList<>();
NodeList childNodes = element.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if (node instanceof Element) {
Element includeElement = (Element) node;
TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name"));
valueHolder.setSource(parserContext.extractSource(includeElement));
includePatterns.add(valueHolder);
}
}
if (!includePatterns.isEmpty()) {
includePatterns.setSource(parserContext.extractSource(element));
beanDef.getPropertyValues().add("includePatterns", includePatterns);
}
}
use of org.springframework.beans.factory.support.ManagedList in project spring-framework by spring-projects.
the class DefaultListableBeanFactoryTests method testPrototypeWithArrayConversionForFactoryMethod.
@Test
public void testPrototypeWithArrayConversionForFactoryMethod() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
List<String> list = new ManagedList<>();
list.add("myName");
list.add("myBeanName");
RootBeanDefinition bd = new RootBeanDefinition(DerivedTestBean.class);
bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
bd.setFactoryMethodName("create");
bd.getConstructorArgumentValues().addGenericArgumentValue(list);
lbf.registerBeanDefinition("test", bd);
DerivedTestBean tb = (DerivedTestBean) lbf.getBean("test");
assertEquals("myName", tb.getName());
assertEquals("myBeanName", tb.getBeanName());
DerivedTestBean tb2 = (DerivedTestBean) lbf.getBean("test");
assertTrue(tb != tb2);
assertEquals("myName", tb2.getName());
assertEquals("myBeanName", tb2.getBeanName());
}
use of org.springframework.beans.factory.support.ManagedList in project spring-framework by spring-projects.
the class BeanDefinitionParserDelegate method parseListElement.
/**
* Parse a list element.
*/
public List<Object> parseListElement(Element collectionEle, BeanDefinition bd) {
String defaultElementType = collectionEle.getAttribute(VALUE_TYPE_ATTRIBUTE);
NodeList nl = collectionEle.getChildNodes();
ManagedList<Object> target = new ManagedList<>(nl.getLength());
target.setSource(extractSource(collectionEle));
target.setElementTypeName(defaultElementType);
target.setMergeEnabled(parseMergeAttribute(collectionEle));
parseCollectionElements(nl, target, bd, defaultElementType);
return target;
}
Aggregations