Java 类org.springframework.beans.factory.support.ManagedList 实例源码

项目:alfresco-repository    文件:ContextDependencyLister.java   
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());
         }
      }
项目:lams    文件:GroovyBeanDefinitionReader.java   
/**
 * 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;
}
项目:lams    文件:AspectJAutoProxyBeanDefinitionParser.java   
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);
    }
}
项目:game    文件:NioServerBeanDefinitionParser.java   
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;
   }
项目:dwr    文件:ControllerParser.java   
@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);

}
项目:spring4-understanding    文件:AspectJAutoProxyBeanDefinitionParser.java   
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);
    }
}
项目:spring4-understanding    文件:GroovyBeanDefinitionReader.java   
/**
 * 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;
}
项目:spring4-understanding    文件:ViewResolversBeanDefinitionParser.java   
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;
}
项目:spring4-understanding    文件:ResourcesBeanDefinitionParser.java   
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);
    }
}
项目:spring4-understanding    文件:AnnotationDrivenBeanDefinitionParser.java   
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;
}
项目:spring4-understanding    文件:AnnotationDrivenBeanDefinitionParser.java   
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;
}
项目:spring4-understanding    文件:AnnotationDrivenBeanDefinitionParser.java   
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;
}
项目:spring4-understanding    文件:Jaxb2MarshallerBeanDefinitionParser.java   
@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);
    }
}
项目:spring4-understanding    文件:DefaultListableBeanFactoryTests.java   
@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());
}
项目:spring4-understanding    文件:DefaultListableBeanFactoryTests.java   
@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());
}
项目:leopard    文件:ComponentScanBeanDefinitionParser.java   
protected BeanDefinition createTimerService() {
    String className = "io.leopard.web.timer.TimerServiceImpl";
    Class<?> clazz;
    try {
        clazz = Class.forName(className);
    }
    catch (ClassNotFoundException e) {
        return null;
    }

    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(clazz);

    ManagedList<RuntimeBeanReference> timerBeanList = new ManagedList<RuntimeBeanReference>();
    for (String beanName : timerList) {
        timerBeanList.add(new RuntimeBeanReference(beanName));
    }
    builder.addPropertyValue("timers", timerBeanList);

    builder.setScope(BeanDefinition.SCOPE_SINGLETON);
    builder.setLazyInit(false);
    return RegisterComponentUtil.registerComponent(parserContext, builder, "timerService");
}
项目:flower    文件:SyncFlowBeanDefinitionHandler.java   
protected void doParse(Element element, BeanDefinitionBuilder bean) {
    final ManagedList<Object> actions = new ManagedList<>();
    final NodeList actionNodes = element.getElementsByTagName("*");
    if (actionNodes != null && actionNodes.getLength() != 0) {
        for (int i = 0; i < actionNodes.getLength(); i++) {
            final Node node = actionNodes.item(i);
            final String type = node.getLocalName();
            if (type.equalsIgnoreCase("method")) {
                actions.add(node.getTextContent());
            } else if (type.equalsIgnoreCase("action")) {
                actions.add(new RuntimeBeanReference(node.getTextContent()));
            } else {
                throw new IllegalArgumentException("Unknown element type: " + type);
            }
        }
    }
    bean.addPropertyValue("actions", actions);
}
项目:spring    文件:GroovyBeanDefinitionReader.java   
/**
 * 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;
}
项目:spring    文件:AspectJAutoProxyBeanDefinitionParser.java   
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);
    }
}
项目:sherlock    文件:ShardingDataSourceBeanDefinitionParser.java   
private BeanDefinition parseLogicChildTable(Element element,ParserContext parserContext){
    BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(LogicChildTableConfig.class);
    factory.addPropertyValue("name", element.getAttribute(TABLE_NAME));
    String primaryKey= element.getAttribute(PRIMARY_KEY);
    if(!StringUtils.isEmpty(primaryKey)){
        factory.addPropertyValue("primaryKey", primaryKey);
    }
    String foreignKey= element.getAttribute(FOREIGN_KEY);
    if(!StringUtils.isEmpty(foreignKey)){
        factory.addPropertyValue("foreignKey", foreignKey);
    }
    List<Element> logicChildTableElements= DomUtils.getChildElementsByTagName(element, LOGIC_CHILD_TABLE);
    if(!CollectionUtils.isEmpty(logicChildTableElements)){
        ManagedList<BeanDefinition> children= new ManagedList<BeanDefinition>();
        for(Element each: logicChildTableElements){
            children.add(parseLogicChildTable(each,parserContext));
        }
        factory.addPropertyValue("children", children);
    }
    return factory.getBeanDefinition();
}
项目:elastic-jobx    文件:JobBeanDefinitionParser.java   
private List<BeanDefinition> createJobListeners(final Element element) {
    List<Element> listenerElements = DomUtils.getChildElementsByTagName(element, "listener");
    List<BeanDefinition> result = new ManagedList<BeanDefinition>(listenerElements.size());
    for (Element each : listenerElements) {
        String className = each.getAttribute("class");
        BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(className);
        factory.setScope(BeanDefinition.SCOPE_PROTOTYPE);
        try {
            Class listenerClass = Class.forName(className);
            if (AbstractDistributeOnceElasticJobListener.class.isAssignableFrom(listenerClass)) {
                factory.addConstructorArgValue(each.getAttribute("startedTimeoutMilliseconds"));
                factory.addConstructorArgValue(each.getAttribute("completedTimeoutMilliseconds"));
            }
        } catch (final ClassNotFoundException ex) {
            throw new RuntimeException(ex);
        }
        result.add(factory.getBeanDefinition());
    }
    return result;
}
项目:ElasticJob    文件:JobBeanDefinitionParser.java   
private List<BeanDefinition> createJobListeners(final Element element) {
    List<Element> listenerElements = DomUtils.getChildElementsByTagName(element, "listener");
    List<BeanDefinition> result = new ManagedList<>(listenerElements.size());
    for (Element each : listenerElements) {
        String className = each.getAttribute("class");
        BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(className);
        factory.setScope(BeanDefinition.SCOPE_PROTOTYPE);
        try {
            Class listenerClass = Class.forName(className);
            if (AbstractDistributeOnceElasticJobListener.class.isAssignableFrom(listenerClass)) {
                factory.addConstructorArgValue(each.getAttribute("startedTimeoutMilliseconds"));
                factory.addConstructorArgValue(each.getAttribute("completedTimeoutMilliseconds"));
            }
        } catch (final ClassNotFoundException ex) {
            throw new RuntimeException(ex);
        }
        result.add(factory.getBeanDefinition());
    }
    return result;
}
项目:xap-openspaces    文件:GigaSpaceBeanDefinitionParser.java   
@SuppressWarnings({"unchecked","rawtypes"})
private void handleModifierElements(Element element, ParserContext parserContext,
        BeanDefinitionBuilder builder, ModifierElement modifierElementEnum) {
    List<Element> modifiers = DomUtils.getChildElementsByTagName(element, 
                                                                 modifierElementEnum.name().toLowerCase() + "-modifier");
    if (modifiers.isEmpty()) {
        return;
    }

    ManagedList managedModifiers = new ManagedList();
    for (Element modifierElement : modifiers) {
        managedModifiers.add(parserContext.getDelegate().parsePropertySubElement(
                                      modifierElement, 
                                      builder.getRawBeanDefinition(), 
                                      null));
    }

    builder.addPropertyValue("default" + modifierElementEnum.name() + "Modifiers", 
                             managedModifiers);
}
项目:opencucina    文件:CompositeIFDefinitionParser.java   
/**
 * JAVADOC Method Level Comments
 *
 * @param element JAVADOC.
 * @param builder JAVADOC.
 */
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
    List<Element> resources = DomUtils.getChildElementsByTagName(element,
            SingletonBeanFactory.INSTANCE_FACTORY_ID);

    List<Object> resnames = new ManagedList<Object>();

    for (Element relement : resources) {
        String pack = relement.getAttribute(PACKAGE);

        if (StringUtils.isNotEmpty(pack)) {
            resnames.add(new PackageBasedInstanceFactory(pack));
        } else {
            resnames.add(new RuntimeBeanReference(relement.getAttribute(REF)));
        }
    }

    builder.addPropertyValue(INSTANCE_FACTORIES, resnames);
}
项目:kc-rice    文件:CustomSchemaParser.java   
/**
 * Parses a list of elements into a list of beans/standard content.
 *
 * @param grandChildren - The list of beans/content in a bean property
 * @param child - The property tag for the parent.
 * @param parent - The parent bean that the tag is nested in.
 * @param parserContext - Provided information and functionality regarding current bean set.
 * @return A managedList of the nested content.
 */
protected ManagedList parseList(ArrayList<Element> grandChildren, Element child, BeanDefinitionBuilder parent,
        ParserContext parserContext) {
    ArrayList<Object> listItems = new ArrayList<Object>();

    for (int i = 0; i < grandChildren.size(); i++) {
        Element grandChild = grandChildren.get(i);

        if (grandChild.getTagName().compareTo("value") == 0) {
            listItems.add(grandChild.getTextContent());
        } else {
            listItems.add(parseBean(grandChild, parent, parserContext));
        }
    }

    String merge = child.getAttribute("merge");

    ManagedList beans = new ManagedList(listItems.size());
    beans.addAll(listItems);

    if (merge != null) {
        beans.setMergeEnabled(Boolean.valueOf(merge));
    }

    return beans;
}
项目:kc-rice    文件:DictionaryBeanFactoryPostProcessor.java   
/**
 * Iterates through the list values and calls helpers to process the value
 *
 * @param listVal the list to process
 * @param propertyName name of the property which has the list value
 * @param nestedBeanStack stack of bean containers which contains the list property
 */
protected void visitList(List<?> listVal, String propertyName, Stack<BeanDefinitionHolder> nestedBeanStack) {
    boolean isMergeEnabled = false;
    if (listVal instanceof ManagedList) {
        isMergeEnabled = ((ManagedList) listVal).isMergeEnabled();
    }

    ManagedList newList = new ManagedList();
    newList.setMergeEnabled(isMergeEnabled);

    for (int i = 0; i < listVal.size(); i++) {
        Object elem = listVal.get(i);

        if (isStringValue(elem)) {
            elem = processListStringPropertyValue(propertyName, listVal, getString(elem), i, nestedBeanStack,
                    beanProcessors);
        } else {
            elem = visitPropertyValue(propertyName, elem, nestedBeanStack);
        }

        newList.add(i, elem);
    }

    listVal.clear();
    listVal.addAll(newList);
}
项目:compass    文件:DatasourceBeanDefinitionParser.java   
private void parseSlaveDataSources(
        List<Element> slaveElements,
        BeanDefinitionBuilder masterSlaveDataSourceBeanDefinitionBuilder,
        ParserContext parserContext,
        String masterSlaveDataSourceId,
        String dataSourcePrototypeAttributeValue)
{
    ManagedList<AbstractBeanDefinition> slaveBeanDefinitions = new ManagedList<AbstractBeanDefinition>(slaveElements.size()); 
    int index=0;
    for (Element slaveElement : slaveElements) 
    {
        index++;
        AbstractBeanDefinition slaveBeanDefinition=this.createSlaveBeanDefinition(
                index, 
                slaveElement, 
                masterSlaveDataSourceId, 
                dataSourcePrototypeAttributeValue, 
                parserContext);

        slaveBeanDefinitions.add(slaveBeanDefinition);

    }

    masterSlaveDataSourceBeanDefinitionBuilder.addPropertyValue(MasterSlaveDataSource.SLAVE_DATA_SOURCES_PROPERTY_NAME, slaveBeanDefinitions);
}
项目:gomall.la    文件:NamespaceHandler.java   
@Override
protected void doParse(final Element element, final ParserContext parserContext, final BeanDefinitionBuilder builder) {
    String listClass = element.getAttribute("list-class");
    List<?> currentParsedList = parserContext.getDelegate().parseListElement(element, builder.getRawBeanDefinition());

    String id = element.getAttribute(AbstractBeanDefinitionParser.ID_ATTRIBUTE);
    if (parserContext.getRegistry().isBeanNameInUse(id)) {
        PropertyValue propValue = parserContext.getRegistry().getBeanDefinition(id).getPropertyValues()
                .getPropertyValue("sourceList");
        ManagedList oldList = (ManagedList) propValue.getValue();

        currentParsedList.addAll(oldList);
    }

    builder.addPropertyValue("sourceList", currentParsedList);
    if (StringUtils.hasText(listClass)) {
        builder.addPropertyValue("targetListClass", listClass);
    }
    String scope = element.getAttribute(NamespaceHandler.SCOPE_ATTRIBUTE);
    if (StringUtils.hasLength(scope)) {
        builder.setScope(scope);
    }
}
项目:community-edition-old    文件:ContextDependencyLister.java   
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());
         }
      }
项目:txnmgr-springframework-ext    文件:TransactionManagerBeanDefinitionParser.java   
private BeanDefinition createGroupRegistryDefinition(String name,
        Element element) {
    ManagedMap<String, BeanDefinition> ptpGroupsMap = new ManagedMap<String, BeanDefinition>();

    String currentGroupName = ParticipantsGroupRegistry.GROUPS_REGISTRY__ROOT_GROUPNAME;
    ManagedList<BeanDefinition> rootGrpParticipants = registerGroup(
            ptpGroupsMap, currentGroupName);
    processGroup(ptpGroupsMap, element, currentGroupName,
            rootGrpParticipants);

    RootBeanDefinition grpRegistryDef = new RootBeanDefinition(
            ParticipantsGroupRegistry.class);
    ConstructorArgumentValues cav = grpRegistryDef
            .getConstructorArgumentValues();
    cav.addGenericArgumentValue(ptpGroupsMap);

    return grpRegistryDef;
}
项目:class-guard    文件:AspectJAutoProxyBeanDefinitionParser.java   
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);
    }
}
项目:class-guard    文件:ResourcesBeanDefinitionParser.java   
private String registerResourceHandler(ParserContext parserContext, Element element, Object source) {
    String locationAttr = element.getAttribute("location");
    if (!StringUtils.hasText(locationAttr)) {
        parserContext.getReaderContext().error("The 'location' attribute is required.", parserContext.extractSource(element));
        return null;
    }

    ManagedList<String> locations = new ManagedList<String>();
    locations.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(locationAttr)));

    RootBeanDefinition resourceHandlerDef = new RootBeanDefinition(ResourceHttpRequestHandler.class);
    resourceHandlerDef.setSource(source);
    resourceHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    resourceHandlerDef.getPropertyValues().add("locations", locations);

    String cacheSeconds = element.getAttribute("cache-period");
    if (StringUtils.hasText(cacheSeconds)) {
        resourceHandlerDef.getPropertyValues().add("cacheSeconds", cacheSeconds);
    }

    String beanName = parserContext.getReaderContext().generateBeanName(resourceHandlerDef);
    parserContext.getRegistry().registerBeanDefinition(beanName, resourceHandlerDef);
    parserContext.registerComponent(new BeanComponentDefinition(resourceHandlerDef, beanName));
    return beanName;
}
项目:class-guard    文件:AnnotationDrivenBeanDefinitionParser.java   
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;
}
项目:class-guard    文件:AnnotationDrivenBeanDefinitionParser.java   
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;
}
项目:class-guard    文件:AnnotationDrivenBeanDefinitionParser.java   
private ManagedList<BeanDefinitionHolder> wrapWebArgumentResolverBeanDefs(
        List<BeanDefinitionHolder> beanDefs, ParserContext parserContext) {

    ManagedList<BeanDefinitionHolder> result = new ManagedList<BeanDefinitionHolder>();
    for (BeanDefinitionHolder beanDef : beanDefs) {
        String className = beanDef.getBeanDefinition().getBeanClassName();
        Class<?> clazz = ClassUtils.resolveClassName(className, parserContext.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"));
        }
        else {
            result.add(beanDef);
        }
    }
    return result;
}
项目:class-guard    文件:Jaxb2MarshallerBeanDefinitionParser.java   
@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
    String contextPath = element.getAttribute("contextPath");
    if (StringUtils.hasText(contextPath)) {
        beanDefinitionBuilder.addPropertyValue("contextPath", contextPath);
    }
    List classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound");
    if (!classes.isEmpty()) {
        ManagedList classesToBeBound = new ManagedList(classes.size());
        for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
            Element classToBeBound = (Element) iterator.next();
            String className = classToBeBound.getAttribute("name");
            classesToBeBound.add(className);
        }
        beanDefinitionBuilder.addPropertyValue("classesToBeBound", classesToBeBound);
    }
}
项目:class-guard    文件:DefaultListableBeanFactoryTests.java   
@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());
}
项目:class-guard    文件:DefaultListableBeanFactoryTests.java   
@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());
}
项目:AGIA    文件:NodeDefinitionParser.java   
protected BeanDefinition parseProperty(Element sElement, ParserContext sParserContext) {
    BeanDefinitionBuilder aBuilder = BeanDefinitionBuilder.genericBeanDefinition(PropertyDefinitionFactoryBean.class);
    aBuilder.addPropertyValue("localName", sElement.getAttribute(PROPDEF_LOCALNAME));

    String aConverterID = sElement.getAttribute(PROPDEF_CONVERTERREF);
    if (StringUtils.hasText(aConverterID)) {
        aBuilder.addPropertyReference("converter", aConverterID);
    }

    List<Element> aValuesElements = DomUtils.getChildElementsByTagName(sElement, PROPDEF_VALUE);
    ManagedList<String> aValues = new ManagedList<String>(aValuesElements.size());

    for (Element aElement : aValuesElements) {
        aValues.add(aElement.getTextContent());
    }

    aBuilder.addPropertyValue("values", aValues);

    return aBuilder.getBeanDefinition();
}
项目:AGIA    文件:SimpleNodeFactory.java   
public NodeList getNodes(EvaluationContext sContext) throws ConversionException {
    Assert.notNull(sContext, "The evaluation context is mandatory.");
    ManagedList<Node> aResult = new ManagedList<Node>();

    if (nodeDefinition instanceof FolderDefinition) {
        // Regular usecase
        FolderDefinition aFolderDefinition = (FolderDefinition) nodeDefinition;
        addFolderNode(aResult, aFolderDefinition, null, sContext);
    }
    // TODO : special usecase: document with a path in its name. Folders
    // should be created as default ones _without_ coyping document
    // properties.
    // If the document has no path in its name, then a default
    // app:company_home is added.

    return new NodeList(aResult);
}