本文整理汇总了Java中org.springframework.beans.factory.support.ManagedList类的典型用法代码示例。如果您正苦于以下问题:Java ManagedList类的具体用法?Java ManagedList怎么用?Java ManagedList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ManagedList类属于org.springframework.beans.factory.support包,在下文中一共展示了ManagedList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRefIfNeeded
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
private void addRefIfNeeded(Object v, List<String> refs) {
if(v == null) return;
if(v instanceof RuntimeBeanReference) {
RuntimeBeanReference r = (RuntimeBeanReference)v;
String name = r.getBeanName();
addRefIfNeeded(name, refs);
if(name == null || name.length() == 0) {
System.err.println("Warning - empty reference " + r);
}
} else if(v instanceof BeanDefinitionHolder) {
// Nested bean definition
BeanDefinitionHolder bdh = (BeanDefinitionHolder)v;
processBeanDefinition(bdh.getBeanName(), bdh.getBeanDefinition());
} else if(v instanceof ManagedList<?>) {
ManagedList<?> ml = (ManagedList<?>)v;
for(Object le : ml) {
addRefIfNeeded(le, refs);
}
// } else {
// System.err.println(v.getClass());
}
}
示例2: manageListIfNecessary
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
/**
* Checks whether there are any {@link RuntimeBeanReference}s inside the List
* and converts it to a ManagedList if necessary.
* @param list the original List
* @return either the original list or a managed copy of it
*/
private Object manageListIfNecessary(List<?> list) {
boolean containsRuntimeRefs = false;
for (Object element : list) {
if (element instanceof RuntimeBeanReference) {
containsRuntimeRefs = true;
break;
}
}
if (containsRuntimeRefs) {
List<Object> managedList = new ManagedList<Object>();
managedList.addAll(list);
return managedList;
}
return list;
}
示例3: addIncludePatterns
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) {
ManagedList<TypedStringValue> includePatterns = new ManagedList<TypedStringValue>();
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);
}
}
示例4: parse
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
public BeanDefinition parse(Element element, ParserContext parserContext)
{
BeanDefinitionBuilder dwrController = BeanDefinitionBuilder.rootBeanDefinition(DwrController.class);
List configurators = new ManagedList();
configurators.add(new RuntimeBeanReference(DEFAULT_SPRING_CONFIGURATOR_ID));
dwrController.addPropertyValue("configurators", configurators);
String debug = element.getAttribute("debug");
if (StringUtils.hasText(debug))
{
dwrController.addPropertyValue("debug", debug);
}
String beanName = element.getAttribute(BeanDefinitionParserDelegate.ID_ATTRIBUTE);
String nameAttr = element.getAttribute(BeanDefinitionParserDelegate.NAME_ATTRIBUTE);
String[] aliases = null;
if (!StringUtils.hasText(beanName))
{
beanName = element.getAttribute("name");
}
else
{
String aliasName = element.getAttribute("name");
if (StringUtils.hasText(aliasName))
{
aliases = StringUtils.tokenizeToStringArray(nameAttr, BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
}
}
parseControllerParameters(dwrController, element);
BeanDefinitionHolder holder = new BeanDefinitionHolder(dwrController.getBeanDefinition(), beanName, aliases);
BeanDefinitionReaderUtils.registerBeanDefinition(holder, parserContext.getRegistry());
return dwrController.getBeanDefinition();
}
示例5: parseServerConfig
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
private String parseServerConfig(Element element, ParserContext parserContext) {
Element ipconfigs = DomUtils.getChildElementByTagName(element, AttributeNames.IPCONFIGS);
List<Element> ips = DomUtils.getChildElementsByTagName(ipconfigs, AttributeNames.IPCONFIG);
BeanDefinitionBuilder serverConfigBuilder = BeanDefinitionBuilder.genericBeanDefinition(ServerConfig.class);
serverConfigBuilder.addConstructorArgValue(element.getAttribute(AttributeNames.READ_SIZE));
serverConfigBuilder.addConstructorArgValue(element.getAttribute(AttributeNames.WRITE_SIZE));
ManagedList<BeanDefinition> inetSocketAddress = new ManagedList<BeanDefinition>();
for (Element ip : ips) {
BeanDefinitionBuilder inetBuilder = BeanDefinitionBuilder.genericBeanDefinition(IpConfig.class);
inetBuilder.addConstructorArgValue(ip.getAttribute(AttributeNames.HOST_NAME));
inetBuilder.addConstructorArgValue(ip.getAttribute(AttributeNames.PORT));
inetSocketAddress.add(inetBuilder.getBeanDefinition());
}
serverConfigBuilder.addConstructorArgValue(inetSocketAddress);
String serverConfig = StringUtils.uncapitalize(ServerConfig.class.getSimpleName());
parserContext.getRegistry().registerBeanDefinition(serverConfig, serverConfigBuilder.getBeanDefinition());
return serverConfig;
}
示例6: doParse
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void doParse(Element element, BeanDefinitionBuilder dwrController)
{
List<Object> configurators = new ManagedList();
configurators.add(new RuntimeBeanReference(ConfigurationParser.DEFAULT_SPRING_CONFIGURATOR_ID));
dwrController.addPropertyValue("configurators", configurators);
String debug = element.getAttribute("debug");
if (StringUtils.hasText(debug))
{
dwrController.addPropertyValue("debug", debug);
}
parseControllerParameters(dwrController, element);
}
示例7: manageListIfNecessary
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
/**
* Checks whether there are any {@link RuntimeBeanReference}s inside the {@link List}
* and converts it to a {@link ManagedList} if necessary.
* @param list the original List
* @return either the original list or a managed copy of it
*/
private Object manageListIfNecessary(List<?> list) {
boolean containsRuntimeRefs = false;
for (Object element : list) {
if (element instanceof RuntimeBeanReference) {
containsRuntimeRefs = true;
break;
}
}
if (containsRuntimeRefs) {
List<Object> managedList = new ManagedList<Object>();
managedList.addAll(list);
return managedList;
}
return list;
}
示例8: createContentNegotiatingViewResolver
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
private BeanDefinition createContentNegotiatingViewResolver(Element resolverElement, ParserContext context) {
RootBeanDefinition beanDef = new RootBeanDefinition(ContentNegotiatingViewResolver.class);
beanDef.setSource(context.extractSource(resolverElement));
beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
MutablePropertyValues values = beanDef.getPropertyValues();
List<Element> elements = DomUtils.getChildElementsByTagName(resolverElement, new String[] {"default-views"});
if (!elements.isEmpty()) {
ManagedList<Object> list = new ManagedList<Object>();
for (Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) {
list.add(context.getDelegate().parsePropertySubElement(element, null));
}
values.add("defaultViews", list);
}
if (resolverElement.hasAttribute("use-not-acceptable")) {
values.add("useNotAcceptableStatusCode", resolverElement.getAttribute("use-not-acceptable"));
}
Object manager = getContentNegotiationManager(context);
if (manager != null) {
values.add("contentNegotiationManager", manager);
}
return beanDef;
}
示例9: parseResourceChain
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
private void parseResourceChain(RootBeanDefinition resourceHandlerDef, ParserContext parserContext,
Element element, Object source) {
String autoRegistration = element.getAttribute("auto-registration");
boolean isAutoRegistration = !(StringUtils.hasText(autoRegistration) && "false".equals(autoRegistration));
ManagedList<? super Object> resourceResolvers = new ManagedList<Object>();
resourceResolvers.setSource(source);
ManagedList<? super Object> resourceTransformers = new ManagedList<Object>();
resourceTransformers.setSource(source);
parseResourceCache(resourceResolvers, resourceTransformers, element, source);
parseResourceResolversTransformers(isAutoRegistration, resourceResolvers, resourceTransformers,
parserContext, element, source);
if (!resourceResolvers.isEmpty()) {
resourceHandlerDef.getPropertyValues().add("resourceResolvers", resourceResolvers);
}
if (!resourceTransformers.isEmpty()) {
resourceHandlerDef.getPropertyValues().add("resourceTransformers", resourceTransformers);
}
}
示例10: getCallableInterceptors
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
private ManagedList<?> getCallableInterceptors(Element element, Object source, ParserContext parserContext) {
ManagedList<? super Object> interceptors = new ManagedList<Object>();
Element asyncElement = DomUtils.getChildElementByTagName(element, "async-support");
if (asyncElement != null) {
Element interceptorsElement = DomUtils.getChildElementByTagName(asyncElement, "callable-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;
}
示例11: getDeferredResultInterceptors
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
private ManagedList<?> getDeferredResultInterceptors(Element element, Object source, ParserContext parserContext) {
ManagedList<? super Object> interceptors = new ManagedList<Object>();
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;
}
示例12: wrapLegacyResolvers
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
private ManagedList<Object> wrapLegacyResolvers(List<Object> list, ParserContext context) {
ManagedList<Object> result = new ManagedList<Object>();
for (Object object : list) {
if (object instanceof BeanDefinitionHolder) {
BeanDefinitionHolder beanDef = (BeanDefinitionHolder) object;
String className = beanDef.getBeanDefinition().getBeanClassName();
Class<?> clazz = ClassUtils.resolveClassName(className, context.getReaderContext().getBeanClassLoader());
if (WebArgumentResolver.class.isAssignableFrom(clazz)) {
RootBeanDefinition adapter = new RootBeanDefinition(ServletWebArgumentResolverAdapter.class);
adapter.getConstructorArgumentValues().addIndexedArgumentValue(0, beanDef);
result.add(new BeanDefinitionHolder(adapter, beanDef.getBeanName() + "Adapter"));
continue;
}
}
result.add(object);
}
return result;
}
示例13: doParse
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
String contextPath = element.getAttribute("context-path");
if (!StringUtils.hasText(contextPath)) {
// Backwards compatibility with 3.x version of the xsd
contextPath = element.getAttribute("contextPath");
}
if (StringUtils.hasText(contextPath)) {
beanDefinitionBuilder.addPropertyValue("contextPath", contextPath);
}
List<Element> classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound");
if (!classes.isEmpty()) {
ManagedList<String> classesToBeBound = new ManagedList<String>(classes.size());
for (Element classToBeBound : classes) {
String className = classToBeBound.getAttribute("name");
classesToBeBound.add(className);
}
beanDefinitionBuilder.addPropertyValue("classesToBeBound", classesToBeBound);
}
}
示例14: testPrototypeWithArrayConversionForConstructor
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
@Test
public void testPrototypeWithArrayConversionForConstructor() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
List<String> list = new ManagedList<String>();
list.add("myName");
list.add("myBeanName");
RootBeanDefinition bd = new RootBeanDefinition(DerivedTestBean.class);
bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
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());
}
示例15: testPrototypeWithArrayConversionForFactoryMethod
import org.springframework.beans.factory.support.ManagedList; //导入依赖的package包/类
@Test
public void testPrototypeWithArrayConversionForFactoryMethod() {
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
List<String> list = new ManagedList<String>();
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());
}