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

项目:hekate    文件:HekateBeanDefinitionParser.java   
private Optional<Map<String, String>> parseProperties(Element el) {
    List<Element> propEls = subElements(el, "properties", "prop");

    if (!propEls.isEmpty()) {
        Map<String, String> props = new ManagedMap<>();

        for (Element propEl : propEls) {
            String name = propEl.getAttribute("name").trim();
            String value = getTextValue(propEl).trim();

            props.put(name, value);
        }

        return Optional.of(props);
    }

    return Optional.empty();
}
项目:lams    文件:GroovyBeanDefinitionReader.java   
/**
 * Checks whether there are any {@link RuntimeBeanReference}s inside the Map
 * and converts it to a ManagedMap if necessary.
 * @param map the original Map
 * @return either the original map or a managed copy of it
 */
private Object manageMapIfNecessary(Map<?, ?> map) {
    boolean containsRuntimeRefs = false;
    for (Object element : map.values()) {
        if (element instanceof RuntimeBeanReference) {
            containsRuntimeRefs = true;
            break;
        }
    }
    if (containsRuntimeRefs) {
        Map<Object, Object> managedMap = new ManagedMap<Object, Object>();
        managedMap.putAll(map);
        return managedMap;
    }
    return map;
}
项目:Lagerta    文件:BaseActiveStoreConfiguration.java   
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void postProcessBeanFactory(
    ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
    String[] igniteConfigNames = configurableListableBeanFactory.getBeanNamesForType(IgniteConfiguration.class);
    if (igniteConfigNames.length != 1) {
        throw new IllegalArgumentException("Spring config must contain exactly one ignite configuration!");
    }
    String[] activeStoreConfigNames = configurableListableBeanFactory.getBeanNamesForType(BaseActiveStoreConfiguration.class);
    if (activeStoreConfigNames.length != 1) {
        throw new IllegalArgumentException("Spring config must contain exactly one active store configuration!");
    }
    BeanDefinition igniteConfigDef = configurableListableBeanFactory.getBeanDefinition(igniteConfigNames[0]);
    MutablePropertyValues propertyValues = igniteConfigDef.getPropertyValues();
    if (!propertyValues.contains(USER_ATTRS_PROP_NAME)) {
        propertyValues.add(USER_ATTRS_PROP_NAME, new ManagedMap());
    }
    PropertyValue propertyValue = propertyValues.getPropertyValue(USER_ATTRS_PROP_NAME);
    Map userAttrs = (Map)propertyValue.getValue();
    TypedStringValue key = new TypedStringValue(CONFIG_USER_ATTR);
    RuntimeBeanReference value = new RuntimeBeanReference(beanName);
    userAttrs.put(key, value);
}
项目:Lagerta    文件:BaseActiveStoreConfiguration.java   
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void postProcessBeanFactory(
    ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
    String[] igniteConfigNames = configurableListableBeanFactory.getBeanNamesForType(IgniteConfiguration.class);
    if (igniteConfigNames.length != 1) {
        throw new IllegalArgumentException("Spring config must contain exactly one ignite configuration!");
    }
    String[] activeStoreConfigNames = configurableListableBeanFactory.getBeanNamesForType(BaseActiveStoreConfiguration.class);
    if (activeStoreConfigNames.length != 1) {
        throw new IllegalArgumentException("Spring config must contain exactly one active store configuration!");
    }
    BeanDefinition igniteConfigDef = configurableListableBeanFactory.getBeanDefinition(igniteConfigNames[0]);
    MutablePropertyValues propertyValues = igniteConfigDef.getPropertyValues();
    if (!propertyValues.contains(USER_ATTRS_PROP_NAME)) {
        propertyValues.add(USER_ATTRS_PROP_NAME, new ManagedMap());
    }
    PropertyValue propertyValue = propertyValues.getPropertyValue(USER_ATTRS_PROP_NAME);
    Map userAttrs = (Map)propertyValue.getValue();
    TypedStringValue key = new TypedStringValue(CONFIG_USER_ATTR);
    RuntimeBeanReference value = new RuntimeBeanReference(beanName);
    userAttrs.put(key, value);
}
项目:spring4-understanding    文件:GroovyBeanDefinitionReader.java   
/**
 * Checks whether there are any {@link RuntimeBeanReference}s inside the {@link Map}
 * and converts it to a {@link ManagedMap} if necessary.
 * @param map the original Map
 * @return either the original map or a managed copy of it
 */
private Object manageMapIfNecessary(Map<?, ?> map) {
    boolean containsRuntimeRefs = false;
    for (Object element : map.values()) {
        if (element instanceof RuntimeBeanReference) {
            containsRuntimeRefs = true;
            break;
        }
    }
    if (containsRuntimeRefs) {
        Map<Object, Object> managedMap = new ManagedMap<Object, Object>();
        managedMap.putAll(map);
        return managedMap;
    }
    return map;
}
项目:spring4-understanding    文件:HandlersBeanDefinitionParser.java   
@Override
public void addMapping(Element element, ManagedMap<String, Object> urlMap, ParserContext context) {
    String pathAttribute = element.getAttribute("path");
    List<String> mappings = Arrays.asList(StringUtils.tokenizeToStringArray(pathAttribute, ","));
    RuntimeBeanReference handlerReference = new RuntimeBeanReference(element.getAttribute("handler"));

    ConstructorArgumentValues cavs = new ConstructorArgumentValues();
    cavs.addIndexedArgumentValue(0, handlerReference);
    if (this.handshakeHandlerReference != null) {
        cavs.addIndexedArgumentValue(1, this.handshakeHandlerReference);
    }
    RootBeanDefinition requestHandlerDef = new RootBeanDefinition(WebSocketHttpRequestHandler.class, cavs, null);
    requestHandlerDef.setSource(context.extractSource(element));
    requestHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    requestHandlerDef.getPropertyValues().add("handshakeInterceptors", this.interceptorsList);
    String requestHandlerName = context.getReaderContext().registerWithGeneratedName(requestHandlerDef);
    RuntimeBeanReference requestHandlerRef = new RuntimeBeanReference(requestHandlerName);

    for (String mapping : mappings) {
        urlMap.put(mapping, requestHandlerRef);
    }
}
项目:spring4-understanding    文件:HandlersBeanDefinitionParser.java   
@Override
public void addMapping(Element element, ManagedMap<String, Object> urlMap, ParserContext context) {
    String pathAttribute = element.getAttribute("path");
    List<String> mappings = Arrays.asList(StringUtils.tokenizeToStringArray(pathAttribute, ","));
    RuntimeBeanReference handlerReference = new RuntimeBeanReference(element.getAttribute("handler"));

    ConstructorArgumentValues cavs = new ConstructorArgumentValues();
    cavs.addIndexedArgumentValue(0, this.sockJsService, "SockJsService");
    cavs.addIndexedArgumentValue(1, handlerReference, "WebSocketHandler");

    RootBeanDefinition requestHandlerDef = new RootBeanDefinition(SockJsHttpRequestHandler.class, cavs, null);
    requestHandlerDef.setSource(context.extractSource(element));
    requestHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    String requestHandlerName = context.getReaderContext().registerWithGeneratedName(requestHandlerDef);
    RuntimeBeanReference requestHandlerRef = new RuntimeBeanReference(requestHandlerName);

    for (String mapping : mappings) {
        String pathPattern = (mapping.endsWith("/") ? mapping + "**" : mapping + "/**");
        urlMap.put(pathPattern, requestHandlerRef);
    }
}
项目:spring4-understanding    文件:MessageBrokerBeanDefinitionParser.java   
private ManagedMap<String, Object> registerHandlerMapping(Element element,
        ParserContext context, Object source) {

    RootBeanDefinition handlerMappingDef = new RootBeanDefinition(WebSocketHandlerMapping.class);

    String orderAttribute = element.getAttribute("order");
    int order = orderAttribute.isEmpty() ? DEFAULT_MAPPING_ORDER : Integer.valueOf(orderAttribute);
    handlerMappingDef.getPropertyValues().add("order", order);

    String pathHelper = element.getAttribute("path-helper");
    if (StringUtils.hasText(pathHelper)) {
        handlerMappingDef.getPropertyValues().add("urlPathHelper", new RuntimeBeanReference(pathHelper));
    }

    ManagedMap<String, Object> urlMap = new ManagedMap<String, Object>();
    urlMap.setSource(source);
    handlerMappingDef.getPropertyValues().add("urlMap", urlMap);

    registerBeanDef(handlerMappingDef, context, source);
    return urlMap;
}
项目:flower    文件:ExtensionBeanDefinitionHandler.java   
protected void doParse(Element element, BeanDefinitionBuilder bean) {
    final Map<Object, Object> configuration = new ManagedMap<>();
    final Node keywordValueNode = element
        .getElementsByTagNameNS("http://xdcrafts.github.com/schema/flower", "keyword-value")
        .item(0);
    final Node predicateNode = element
        .getElementsByTagNameNS("http://xdcrafts.github.com/schema/flower", "predicate")
        .item(0);
    if (keywordValueNode != null) {
        configuration.put("keyword-value", keywordValueNode.getTextContent());
    }
    if (predicateNode != null) {
        configuration.put("predicate", new RuntimeBeanReference(predicateNode.getTextContent()));
    }
    bean
        .addPropertyReference("action", element.getAttribute("action"))
        .addPropertyValue("configuration", configuration);
}
项目:flower    文件:FeatureBeanDefinitionHandler.java   
protected void doParse(Element element, BeanDefinitionBuilder bean) {
    final ManagedMap<Object, Object> extensions = new ManagedMap<>();
    final NodeList bindingNodes = element
        .getElementsByTagNameNS("http://xdcrafts.github.com/schema/flower", "binding");
    if (bindingNodes != null && bindingNodes.getLength() != 0) {
        for (int i = 0; i < bindingNodes.getLength(); i++) {
            final Node bindingNode = bindingNodes.item(i);
            final String extension = bindingNode
                .getAttributes()
                .getNamedItem("extension")
                .getNodeValue();
            final String selector = bindingNode
                .getAttributes()
                .getNamedItem("selector")
                .getNodeValue();
            extensions.put(new RuntimeBeanReference(extension), new RuntimeBeanReference(selector));
        }
    }
    bean.addPropertyValue("extensions", extensions);
}
项目:spring    文件:GroovyBeanDefinitionReader.java   
/**
 * Checks whether there are any {@link RuntimeBeanReference}s inside the {@link Map}
 * and converts it to a {@link ManagedMap} if necessary.
 * @param map the original Map
 * @return either the original map or a managed copy of it
 */
private Object manageMapIfNecessary(Map<?, ?> map) {
    boolean containsRuntimeRefs = false;
    for (Object element : map.values()) {
        if (element instanceof RuntimeBeanReference) {
            containsRuntimeRefs = true;
            break;
        }
    }
    if (containsRuntimeRefs) {
        Map<Object, Object> managedMap = new ManagedMap<Object, Object>();
        managedMap.putAll(map);
        return managedMap;
    }
    return map;
}
项目:kc-rice    文件:UifBeanFactoryPostProcessor.java   
/**
 * Retrieves the expression graph map set on the bean with given name. If the bean has not been processed
 * by the bean factory post processor, that is done before retrieving the map
 *
 * @param parentBeanName name of the parent bean to retrieve map for (if empty a new map will be returned)
 * @param beanFactory bean factory to retrieve bean definition from
 * @param processedBeanNames set of bean names that have been processed so far
 * @return expression graph map from parent or new instance
 */
protected Map<String, String> getExpressionGraphFromParent(String parentBeanName,
        ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) {
    Map<String, String> expressionGraph = new HashMap<String, String>();
    if (StringUtils.isBlank(parentBeanName) || !beanFactory.containsBeanDefinition(parentBeanName)) {
        return expressionGraph;
    }

    BeanDefinition beanDefinition = beanFactory.getBeanDefinition(parentBeanName);
    if (!processedBeanNames.contains(parentBeanName)) {
        processBeanDefinition(parentBeanName, beanDefinition, beanFactory, processedBeanNames);
    }

    MutablePropertyValues pvs = beanDefinition.getPropertyValues();
    PropertyValue propertyExpressionsPV = pvs.getPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH);
    if (propertyExpressionsPV != null) {
        Object value = propertyExpressionsPV.getValue();
        if ((value != null) && (value instanceof ManagedMap)) {
            expressionGraph.putAll((ManagedMap) value);
        }
    }

    return expressionGraph;
}
项目:kc-rice    文件:CustomSchemaParser.java   
/**
 * Parses a list of elements into a map 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 managedSet of the nested content.
 */
protected ManagedMap parseMap(ArrayList<Element> grandChildren, Element child, BeanDefinitionBuilder parent,
        ParserContext parserContext) {
    ManagedMap map = new ManagedMap();

    String merge = child.getAttribute("merge");
    if (merge != null) {
        map.setMergeEnabled(Boolean.valueOf(merge));
    }

    for (int j = 0; j < grandChildren.size(); j++) {
        Object key = findKey(grandChildren.get(j), parent, parserContext);
        Object value = findValue(grandChildren.get(j), parent, parserContext);

        map.put(key, value);
    }

    return map;
}
项目: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;
}
项目:se    文件:TransactionBeanDefinitionParser.java   
public void parseFields(Element element, RootBeanDefinition beandef, ParserContext parserContext) {
    Element fieldsele = DomUtils.getChildElementByTagName(element, FIELDS);
    if (fieldsele == null) {
        return;
    }
    List<Element> fieldlist = DomUtils.getChildElementsByTagName(fieldsele, FIELD);
    if (fieldlist.size() == 0) {
        return;
    }
    Map<String, RuntimeBeanReference> fields = new ManagedMap<String, RuntimeBeanReference>();
    String fieldname = null;
    for (Element field : fieldlist) {
        fieldname = field.getAttribute(NAME);
        if (!(StringUtils.hasLength(fieldname))) {
            System.out.println("Tag 'field' must have a 'name' attribute");
            return;
        }
        if("".equals(DomUtils.getTextValue(field))){
            fields.put(fieldname, null);
        } else {
            fields.put(fieldname, new RuntimeBeanReference(DomUtils.getTextValue(field)));
        }
    }
    beandef.getPropertyValues().addPropertyValue(FIELDS, fields);
}
项目:rice    文件:UifBeanFactoryPostProcessor.java   
/**
 * Retrieves the expression graph map set on the bean with given name. If the bean has not been processed
 * by the bean factory post processor, that is done before retrieving the map
 *
 * @param parentBeanName name of the parent bean to retrieve map for (if empty a new map will be returned)
 * @param beanFactory bean factory to retrieve bean definition from
 * @param processedBeanNames set of bean names that have been processed so far
 * @return expression graph map from parent or new instance
 */
protected Map<String, String> getExpressionGraphFromParent(String parentBeanName,
        ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) {
    Map<String, String> expressionGraph = new HashMap<String, String>();
    if (StringUtils.isBlank(parentBeanName) || !beanFactory.containsBeanDefinition(parentBeanName)) {
        return expressionGraph;
    }

    BeanDefinition beanDefinition = beanFactory.getBeanDefinition(parentBeanName);
    if (!processedBeanNames.contains(parentBeanName)) {
        processBeanDefinition(parentBeanName, beanDefinition, beanFactory, processedBeanNames);
    }

    MutablePropertyValues pvs = beanDefinition.getPropertyValues();
    PropertyValue propertyExpressionsPV = pvs.getPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH);
    if (propertyExpressionsPV != null) {
        Object value = propertyExpressionsPV.getValue();
        if ((value != null) && (value instanceof ManagedMap)) {
            expressionGraph.putAll((ManagedMap) value);
        }
    }

    return expressionGraph;
}
项目:rice    文件:CustomSchemaParser.java   
/**
 * Parses a list of elements into a map 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 managedSet of the nested content.
 */
protected ManagedMap parseMap(ArrayList<Element> grandChildren, Element child, BeanDefinitionBuilder parent,
        ParserContext parserContext) {
    ManagedMap map = new ManagedMap();

    String merge = child.getAttribute("merge");
    if (merge != null) {
        map.setMergeEnabled(Boolean.valueOf(merge));
    }

    for (int j = 0; j < grandChildren.size(); j++) {
        Object key = findKey(grandChildren.get(j), parent, parserContext);
        Object value = findValue(grandChildren.get(j), parent, parserContext);

        map.put(key, value);
    }

    return map;
}
项目:geomajas-project-server    文件:BeanDefinitionWriterServiceImpl.java   
private XStream createStream() {
    XStream stream = new XStream();
    stream.registerConverter(new BeanDefinitionConverter(stream.getMapper()));
    stream.registerConverter(new BeanDefinitionHolderConverter(stream.getMapper()));
    stream.registerConverter(new TypedStringValueConverter());
    stream.registerConverter(new ManagedCollectionConverter(stream.getMapper()));
    stream.registerConverter(new ManagedMapConverter(stream.getMapper()));
    stream.registerConverter(new RuntimeBeanReferenceConverter());
    stream.alias("map", ManagedMap.class);
    stream.alias("list", ManagedList.class);
    stream.alias("set", ManagedSet.class);
    stream.alias("array", ManagedArray.class);
    stream.aliasType("bean", BeanDefinition.class);
    stream.alias("bean", BeanDefinitionHolder.class);
    stream.alias("ref", RuntimeBeanReference.class);
    return stream;
}
项目:geomajas-project-server    文件:BeanDefinitionWriterServiceImpl.java   
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
    ManagedMap<?, ?> map = (ManagedMap<?, ?>) source;
    for (Map.Entry<?, ?> entry : map.entrySet()) {
        writer.startNode("entry");
        writer.startNode("key");
        if (entry.getKey().getClass().equals(TypedStringValue.class)) {
            writer.startNode("value");
            writer.setValue(((TypedStringValue) entry.getKey()).getValue());
            writer.endNode();
        } else {
            writeItem(entry.getKey(), context, writer);
        }
        writer.endNode();
        if (entry.getValue().getClass().equals(TypedStringValue.class)) {
            writer.startNode("value");
            writer.setValue(((TypedStringValue) entry.getValue()).getValue());
            writer.endNode();
        } else {
            writeItem(entry.getValue(), context, writer);
        }
        writer.endNode();
    }
}
项目:kuali_rice    文件:UifBeanFactoryPostProcessor.java   
/**
 * Retrieves the expression graph map set on the bean with given name. If the bean has not been processed
 * by the bean factory post processor, that is done before retrieving the map
 *
 * @param parentBeanName name of the parent bean to retrieve map for (if empty a new map will be returned)
 * @param beanFactory bean factory to retrieve bean definition from
 * @param processedBeanNames set of bean names that have been processed so far
 * @return expression graph map from parent or new instance
 */
protected Map<String, String> getExpressionGraphFromParent(String parentBeanName,
        ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) {
    Map<String, String> expressionGraph = new HashMap<String, String>();
    if (StringUtils.isBlank(parentBeanName) || !beanFactory.containsBeanDefinition(parentBeanName)) {
        return expressionGraph;
    }

    BeanDefinition beanDefinition = beanFactory.getBeanDefinition(parentBeanName);
    if (!processedBeanNames.contains(parentBeanName)) {
        processBeanDefinition(parentBeanName, beanDefinition, beanFactory, processedBeanNames);
    }

    MutablePropertyValues pvs = beanDefinition.getPropertyValues();
    PropertyValue propertyExpressionsPV = pvs.getPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH);
    if (propertyExpressionsPV != null) {
        Object value = propertyExpressionsPV.getValue();
        if ((value != null) && (value instanceof ManagedMap)) {
            expressionGraph.putAll((ManagedMap) value);
        }
    }

    return expressionGraph;
}
项目:kuali_rice    文件:CustomSchemaParser.java   
/**
 * Parses a list of elements into a map 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 managedSet of the nested content.
 */
private ManagedMap parseMap(ArrayList<Element> grandChildren, Element child, BeanDefinitionBuilder parent,
        ParserContext parserContext) {
    ManagedMap map = new ManagedMap();
    String merge = child.getAttribute("merge");

    for (int j = 0; j < grandChildren.size(); j++) {
        Object key = findKey(grandChildren.get(j));
        Object value = findValue(grandChildren.get(j));
        map.put(key, value);
    }

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

    return map;
}
项目:directed-graph-builder    文件:SpringGraphBuilder.java   
/**
 * @param graph Graph
 * @param beanId String
 * @param v PropertyValue
 */
private static void addGraphEdge(final Graph graph, final String beanId, final PropertyValue v) {
    if (v.getValue() instanceof RuntimeBeanReference) {
        graph.addEdge(beanId, ((RuntimeBeanReference) v.getValue()).getBeanName());
    } else if (v.getValue() instanceof ManagedList) {
        ManagedList list = (ManagedList) v.getValue();
        for (Object o : list) {
            if (o instanceof RuntimeBeanReference) {
                graph.addEdge(beanId, ((RuntimeBeanReference) o).getBeanName());
            }
        }
    } else if (v.getValue() instanceof ManagedMap) {
        ManagedMap map = (ManagedMap) v.getValue();
        for (Object value : map.values()) {
            if (value instanceof RuntimeBeanReference) {
                graph.addEdge(beanId, ((RuntimeBeanReference) value).getBeanName());
            }
        }
    }
}
项目:directed-graph-builder    文件:SpringGraphBuilder.java   
/**
     * @param graph Graph
     * @param beanId String
     * @param v ConstructorArgumentValues.ValueHolder v
     */
    private static void addGraphEdge(final Graph graph, final String beanId, final ConstructorArgumentValues.ValueHolder v) {
        if (v.getValue() instanceof BeanDefinition) {
            //In most cases this should be a field instead of an edge (?) 
//          graph.addEdge(beanId, ((BeanDefinition) v.getValue()).getBeanClassName());
        } else if (v.getValue() instanceof RuntimeBeanReference) {
            graph.addEdge(beanId, ((RuntimeBeanReference) v.getValue()).getBeanName());
        } else if (v.getValue() instanceof ManagedList) {
            ManagedList list = (ManagedList) v.getValue();
            for (Object o : list) {
                if (o instanceof RuntimeBeanReference) {
                    graph.addEdge(beanId, ((RuntimeBeanReference) o).getBeanName());
                }
            }
        } else if (v.getValue() instanceof ManagedMap) {
            ManagedMap map = (ManagedMap) v.getValue();
            for (Object value : map.values()) {
                if (value instanceof RuntimeBeanReference) {
                    graph.addEdge(beanId, ((RuntimeBeanReference) value).getBeanName());
                }
            }
        } else {
            System.out.println("Unhandled constructor argument type");
        }
    }
项目:jdal    文件:DefaultsBeanDefinitionParser.java   
/**
 * @return
 */
private ComponentDefinition registerAccessorFactory(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder bdb = BeanDefinitionBuilder.genericBeanDefinition(
            ConfigurableControlAccessorFactory.class);

    Map<Class<?>, Class<?extends ControlAccessor>> accessors = 
            new ManagedMap<Class<?>,Class<?extends ControlAccessor>>();
    accessors.put(JTextComponent.class, TextComponentAccessor.class);
    accessors.put(JList.class, ListAccessor.class);
    accessors.put(Selector.class, SelectorAccessor.class);
    accessors.put(JToggleButton.class, ToggleButtonAccessor.class);
    accessors.put(JComboBox.class, ComboAccessor.class);
    accessors.put(View.class, ViewAccessor.class);
    accessors.put(JLabel.class, LabelAccessor.class);
    accessors.put(TablePanel.class, TablePanelAccessor.class);
    bdb.addPropertyValue("accessors", accessors);

    BeanComponentDefinition bcd = new BeanComponentDefinition(bdb.getBeanDefinition(), ACCESSOR_FACTORY_BEAN_NAME);

    registerBeanComponentDefinition(element, parserContext, bcd);   
    return bcd;
}
项目:mina-ftpserver    文件:ServerBeanDefinitionParser.java   
/**
 * Parse the "ftplets" element
 */
private Map<?, ?> parseFtplets(final Element childElm,
        final ParserContext parserContext,
        final BeanDefinitionBuilder builder) {

    List<Element> childs = SpringUtil.getChildElements(childElm);

    if(childs.size() > 0 && childs.get(0).getLocalName().equals("map")) {
        // using a beans:map element
        return parserContext.getDelegate().parseMapElement(
                childs.get(0),
                builder.getBeanDefinition());
    } else {
        ManagedMap ftplets = new ManagedMap();
        for (Element ftpletElm : childs) {
            ftplets
                    .put(ftpletElm.getAttribute("name"), SpringUtil
                            .parseSpringChildElement(ftpletElm, parserContext,
                                    builder));
        }

        return ftplets;
    }
}
项目:parabuild-ci    文件:DwrNamespaceHandler.java   
protected BeanDefinition registerSpringConfiguratorIfNecessary(BeanDefinitionRegistry registry)
{
    if (!registry.containsBeanDefinition(DEFAULT_SPRING_CONFIGURATOR_ID))
    {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(SpringConfigurator.class);
        builder.addPropertyValue("creators", new ManagedMap());
        builder.addPropertyValue("converters", new ManagedMap());
        registry.registerBeanDefinition(DEFAULT_SPRING_CONFIGURATOR_ID, builder.getBeanDefinition());
    }
    return registry.getBeanDefinition(DEFAULT_SPRING_CONFIGURATOR_ID);
}
项目:dubbo-spring-boot-autoconfig    文件:DubboServiceClassPathBeanDefinitionScanner.java   
private ManagedMap buildParameters(String[] keyValues) {
    if (keyValues.length == 0 || keyValues.length % 2 != 0) {
        return null;
    }

    ManagedMap managedMap = new ManagedMap();
    for (int i = 0; i < keyValues.length; i+=2) {
        managedMap.put(keyValues[i], new TypedStringValue(keyValues[i + 1], String.class));
    }

    return managedMap;
}
项目:dwr    文件:ConfigurationParser.java   
/**
 * Checks if a configuration object (usually from a <code>&lt;dwr:configuration&gt;</code> tag) has already
 * been processed. If not it registers one automatically.
 *
 * @param registry a non null instance
 * @return the configuration bean definition currently in the context (cannot be null)
 */
public static BeanDefinition registerConfigurationIfNecessary(BeanDefinitionRegistry registry)
{
    if (!registry.containsBeanDefinition(DEFAULT_SPRING_CONFIGURATOR_ID))
    {
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(SpringConfigurator.class);
        builder.addPropertyValue("creators", new ManagedMap());
        builder.addPropertyValue("converters", new ManagedMap());
        builder.addPropertyValue("filters", new ManagedList());
        registry.registerBeanDefinition(DEFAULT_SPRING_CONFIGURATOR_ID, builder.getBeanDefinition());
    }
    return registry.getBeanDefinition(DEFAULT_SPRING_CONFIGURATOR_ID);
}
项目:lodsve-framework    文件:MongoBeanDefinitionRegistrar.java   
private BeanDefinitionBuilder getWriteConcernPropertyEditorBuilder() {
    Map<String, Class<?>> customEditors = new ManagedMap<>();
    customEditors.put("com.mongodb.WriteConcern", WriteConcernPropertyEditor.class);

    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CustomEditorConfigurer.class);
    builder.addPropertyValue("customEditors", customEditors);

    return builder;
}
项目:spring4-understanding    文件:DefaultServletHandlerBeanDefinitionParser.java   
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    Object source = parserContext.extractSource(element);

    String defaultServletName = element.getAttribute("default-servlet-name");
    RootBeanDefinition defaultServletHandlerDef = new RootBeanDefinition(DefaultServletHttpRequestHandler.class);
    defaultServletHandlerDef.setSource(source);
    defaultServletHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    if (StringUtils.hasText(defaultServletName)) {
        defaultServletHandlerDef.getPropertyValues().add("defaultServletName", defaultServletName);
    }
    String defaultServletHandlerName = parserContext.getReaderContext().generateBeanName(defaultServletHandlerDef);
    parserContext.getRegistry().registerBeanDefinition(defaultServletHandlerName, defaultServletHandlerDef);
    parserContext.registerComponent(new BeanComponentDefinition(defaultServletHandlerDef, defaultServletHandlerName));

    Map<String, String> urlMap = new ManagedMap<String, String>();
    urlMap.put("/**", defaultServletHandlerName);

    RootBeanDefinition handlerMappingDef = new RootBeanDefinition(SimpleUrlHandlerMapping.class);
    handlerMappingDef.setSource(source);
    handlerMappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    handlerMappingDef.getPropertyValues().add("urlMap", urlMap);

    String handlerMappingBeanName = parserContext.getReaderContext().generateBeanName(handlerMappingDef);
    parserContext.getRegistry().registerBeanDefinition(handlerMappingBeanName, handlerMappingDef);
    parserContext.registerComponent(new BeanComponentDefinition(handlerMappingDef, handlerMappingBeanName));

    // Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
    MvcNamespaceUtils.registerDefaultComponents(parserContext, source);

    return null;
}
项目:alfresco-mt-support    文件:TemplatedTenantBeanEmitter.java   
protected void shallowCloneManagedCollections(final AbstractBeanDefinition cloneBeanDefinition)
{
    // clone is not a deep clone - managed lists / maps are by-reference which is problematic for placeholder resolution
    final MutablePropertyValues propertyValues = cloneBeanDefinition.getPropertyValues();
    for (final PropertyValue pv : propertyValues.getPropertyValues())
    {
        final Object value = pv.getValue();
        if (value instanceof ManagedList<?>)
        {
            final ManagedList<Object> newList = new ManagedList<>();
            newList.setSource(((ManagedList<?>) value).getSource());
            newList.setElementTypeName(((ManagedList<?>) value).getElementTypeName());
            newList.addAll((ManagedList<?>) value);
            propertyValues.add(pv.getName(), newList);
        }
        else if (value instanceof ManagedSet<?>)
        {
            final ManagedSet<Object> newSet = new ManagedSet<>();
            newSet.setSource(((ManagedSet<?>) value).getSource());
            newSet.setElementTypeName(((ManagedSet<?>) value).getElementTypeName());
            newSet.addAll((ManagedSet<?>) value);
            propertyValues.add(pv.getName(), newSet);
        }
        else if (value instanceof ManagedMap<?, ?>)
        {
            final ManagedMap<Object, Object> newMap = new ManagedMap<>();
            newMap.setSource(((ManagedMap<?, ?>) value).getSource());
            newMap.setKeyTypeName(((ManagedMap<?, ?>) value).getKeyTypeName());
            newMap.setValueTypeName(((ManagedMap<?, ?>) value).getValueTypeName());
            newMap.putAll((ManagedMap<?, ?>) value);
            propertyValues.add(pv.getName(), newMap);
        }
    }
}
项目:kc-rice    文件:UifBeanFactoryPostProcessor.java   
/**
 * Processes a top level (non nested) bean definition for expressions
 *
 * <p>
 * A bean that is non nested (or top of a collection) will hold all the expressions for the graph. A new
 * expression graph is initialized and expressions are collected as the bean and all its children are processed.
 * The expression graph is then set as a property on the top bean definition
 * </p>
 *
 * @param beanName name of the bean to process
 * @param beanDefinition bean definition to process
 * @param beanFactory factory holding all the bean definitions
 * @param processedBeanNames set of bean names that have already been processed
 */
protected void processBeanDefinition(String beanName, BeanDefinition beanDefinition,
        ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) {
    Class<?> beanClass = getBeanClass(beanDefinition, beanFactory);
    if ((beanClass == null) || !UifDictionaryBean.class.isAssignableFrom(beanClass) || processedBeanNames.contains(
            beanName)) {
        return;
    }

    // process bean definition and all nested definitions for expressions
    ManagedMap<String, String> expressionGraph = new ManagedMap<String, String>();
    MutablePropertyValues pvs = beanDefinition.getPropertyValues();
    if (pvs.contains(UifPropertyPaths.EXPRESSION_GRAPH)) {
        expressionGraph = (ManagedMap<String, String>) pvs.getPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH)
                .getValue();
        if (expressionGraph == null) {
            expressionGraph = new ManagedMap<String, String>();
        }
    }

    expressionGraph.setMergeEnabled(false);
    processNestedBeanDefinition(beanName, beanDefinition, "", expressionGraph, beanFactory, processedBeanNames);

    // add property for expression graph
    pvs = beanDefinition.getPropertyValues();
    pvs.addPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH, expressionGraph);
}
项目:kc-rice    文件:DictionaryBeanFactoryPostProcessor.java   
/**
 * Iterates through the map values and calls helpers to process the value
 *
 * @param mapVal the set to process
 * @param propertyName name of the property which has the map value
 * @param nestedBeanStack stack of bean containers which contains the map property
 */
protected void visitMap(Map<?, ?> mapVal, String propertyName, Stack<BeanDefinitionHolder> nestedBeanStack) {
    boolean isMergeEnabled = false;
    if (mapVal instanceof ManagedMap) {
        isMergeEnabled = ((ManagedMap) mapVal).isMergeEnabled();
    }

    ManagedMap newMap = new ManagedMap();
    newMap.setMergeEnabled(isMergeEnabled);

    for (Map.Entry entry : mapVal.entrySet()) {
        Object key = entry.getKey();
        Object val = entry.getValue();

        if (isStringValue(val)) {
            val = processMapStringPropertyValue(propertyName, mapVal, getString(val), key, nestedBeanStack,
                    beanProcessors);
        } else {
            val = visitPropertyValue(propertyName, val, nestedBeanStack);
        }

        newMap.put(key, val);
    }

    mapVal.clear();
    mapVal.putAll(newMap);
}
项目:txnmgr-springframework-ext    文件:TransactionManagerBeanDefinitionParser.java   
protected ManagedList<BeanDefinition> registerGroup(
        ManagedMap<String, BeanDefinition> ptpGroupsMap, String groupName) {
    ManagedList<BeanDefinition> grpParticipants = new ManagedList<BeanDefinition>();

    BeanDefinitionBuilder rootGrpDefBuilder = BeanDefinitionBuilder
            .rootBeanDefinition(ParticipantsGroup.class);
    ConstructorArgumentValues constructorArgumentValues = rootGrpDefBuilder
            .getBeanDefinition().getConstructorArgumentValues();
    constructorArgumentValues.addGenericArgumentValue(groupName);
    constructorArgumentValues.addGenericArgumentValue(grpParticipants);

    ptpGroupsMap.put(groupName, rootGrpDefBuilder.getBeanDefinition());

    return grpParticipants;
}
项目:txnmgr-springframework-ext    文件:TransactionManagerBeanDefinitionParser.java   
protected void processGroup(
        ManagedMap<String, BeanDefinition> ptpGroupsMap, Element groupElt,
        String groupName, ManagedList<BeanDefinition> grpParticipants) {

    NodeList childNodes = groupElt.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node node = childNodes.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            String localName = node.getLocalName();
            if (PARTICIPANT_ELEMENT.equals(localName)) {
                BeanDefinition ptpBeanDef = parseParticipant((Element) node);
                grpParticipants.add(ptpBeanDef);
            } else if (GROUP_ELEMENT.equals(localName)) {
                Element childGrpElt = (Element) node;
                String childGroupName = childGrpElt
                        .getAttribute(NAME_ATTRIBUTE);
                grpParticipants = registerGroup(ptpGroupsMap,
                        childGroupName);
                processGroup(ptpGroupsMap, childGrpElt, childGroupName,
                        grpParticipants);
            } else if (SUBFLOW_ELEMENT.equals(localName)) {
                Element childSubflowElt = (Element) node;
                processGroup(ptpGroupsMap, childSubflowElt, null, null);
            }
        }
    }
}
项目:class-guard    文件:SimplePortletApplicationContext.java   
@Override
public void refresh() throws BeansException {
    MutablePropertyValues pvs = new MutablePropertyValues();
    registerSingleton("controller1", TestFormController.class, pvs);

    pvs = new MutablePropertyValues();
    pvs.add("bindOnNewForm", "true");
    registerSingleton("controller2", TestFormController.class, pvs);

    pvs = new MutablePropertyValues();
    pvs.add("requireSession", "true");
    pvs.add("sessionForm", "true");
    pvs.add("bindOnNewForm", "true");
    registerSingleton("controller3", TestFormController.class, pvs);

    pvs = new MutablePropertyValues();
    pvs.add("requireSession", "true");
    pvs.add("sessionForm", "true");
    pvs.add("bindOnNewForm", "false");
    registerSingleton("controller4", TestFormController.class, pvs);

    pvs = new MutablePropertyValues();
    Map parameterMap = new ManagedMap();
    parameterMap.put("form", new RuntimeBeanReference("controller1"));
    parameterMap.put("form-bind", new RuntimeBeanReference("controller2"));
    parameterMap.put("form-session-bind", new RuntimeBeanReference("controller3"));
    parameterMap.put("form-session-nobind", new RuntimeBeanReference("controller4"));
    pvs.addPropertyValue(new PropertyValue("parameterMap", parameterMap));
    registerSingleton("handlerMapping", ParameterHandlerMapping.class, pvs);

    super.refresh();

    TestFormController controller1 = (TestFormController) getBean("controller1");
    this.renderCommandSessionAttributeName = controller1.getRenderCommandName();
    this.formSessionAttributeName = controller1.getFormSessionName();
}
项目:class-guard    文件:DefaultServletHandlerBeanDefinitionParser.java   
public BeanDefinition parse(Element element, ParserContext parserContext) {
    Object source = parserContext.extractSource(element);

    String defaultServletName = element.getAttribute("default-servlet-name");
    RootBeanDefinition defaultServletHandlerDef = new RootBeanDefinition(DefaultServletHttpRequestHandler.class);
    defaultServletHandlerDef.setSource(source);
    defaultServletHandlerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    if (StringUtils.hasText(defaultServletName)) {
        defaultServletHandlerDef.getPropertyValues().add("defaultServletName", defaultServletName);
    }
    String defaultServletHandlerName = parserContext.getReaderContext().generateBeanName(defaultServletHandlerDef);
    parserContext.getRegistry().registerBeanDefinition(defaultServletHandlerName, defaultServletHandlerDef);
    parserContext.registerComponent(new BeanComponentDefinition(defaultServletHandlerDef, defaultServletHandlerName));

    Map<String, String> urlMap = new ManagedMap<String, String>();
    urlMap.put("/**", defaultServletHandlerName);

    RootBeanDefinition handlerMappingDef = new RootBeanDefinition(SimpleUrlHandlerMapping.class);
    handlerMappingDef.setSource(source);
    handlerMappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    handlerMappingDef.getPropertyValues().add("urlMap", urlMap);

    String handlerMappingBeanName = parserContext.getReaderContext().generateBeanName(handlerMappingDef);
    parserContext.getRegistry().registerBeanDefinition(handlerMappingBeanName, handlerMappingDef);
    parserContext.registerComponent(new BeanComponentDefinition(handlerMappingDef, handlerMappingBeanName));

    // Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
    MvcNamespaceUtils.registerDefaultComponents(parserContext, source);

    return null;
}
项目:class-guard    文件:ViewControllerBeanDefinitionParser.java   
public BeanDefinition parse(Element element, ParserContext parserContext) {
    Object source = parserContext.extractSource(element);

    // Register SimpleUrlHandlerMapping for view controllers
    BeanDefinition handlerMappingDef = registerHandlerMapping(parserContext, source);

    // Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
    MvcNamespaceUtils.registerDefaultComponents(parserContext, source);

    // Create view controller bean definition
    RootBeanDefinition viewControllerDef = new RootBeanDefinition(ParameterizableViewController.class);
    viewControllerDef.setSource(source);
    if (element.hasAttribute("view-name")) {
        viewControllerDef.getPropertyValues().add("viewName", element.getAttribute("view-name"));
    }
    Map<String, BeanDefinition> urlMap;
    if (handlerMappingDef.getPropertyValues().contains("urlMap")) {
        urlMap = (Map<String, BeanDefinition>) handlerMappingDef.getPropertyValues().getPropertyValue("urlMap").getValue();
    }
    else {
        urlMap = new ManagedMap<String, BeanDefinition>();
        handlerMappingDef.getPropertyValues().add("urlMap", urlMap);
    }
    urlMap.put(element.getAttribute("path"), viewControllerDef);

    return null;
}
项目:class-guard    文件:ResourcesBeanDefinitionParser.java   
public BeanDefinition parse(Element element, ParserContext parserContext) {
    Object source = parserContext.extractSource(element);

    String resourceHandlerName = registerResourceHandler(parserContext, element, source);
    if (resourceHandlerName == null) {
        return null;
    }

    Map<String, String> urlMap = new ManagedMap<String, String>();
    String resourceRequestPath = element.getAttribute("mapping");
    if (!StringUtils.hasText(resourceRequestPath)) {
        parserContext.getReaderContext().error("The 'mapping' attribute is required.", parserContext.extractSource(element));
        return null;
    }
    urlMap.put(resourceRequestPath, resourceHandlerName);

    RootBeanDefinition handlerMappingDef = new RootBeanDefinition(SimpleUrlHandlerMapping.class);
    handlerMappingDef.setSource(source);
    handlerMappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    handlerMappingDef.getPropertyValues().add("urlMap", urlMap);

    String order = element.getAttribute("order");
    // use a default of near-lowest precedence, still allowing for even lower precedence in other mappings
    handlerMappingDef.getPropertyValues().add("order", StringUtils.hasText(order) ? order : Ordered.LOWEST_PRECEDENCE - 1);

    String beanName = parserContext.getReaderContext().generateBeanName(handlerMappingDef);
    parserContext.getRegistry().registerBeanDefinition(beanName, handlerMappingDef);
    parserContext.registerComponent(new BeanComponentDefinition(handlerMappingDef, beanName));

    // Ensure BeanNameUrlHandlerMapping (SPR-8289) and default HandlerAdapters are not "turned off"
    // Register HttpRequestHandlerAdapter
    MvcNamespaceUtils.registerDefaultComponents(parserContext, source);

    return null;
}
项目:rice    文件:UifBeanFactoryPostProcessor.java   
/**
 * Processes a top level (non nested) bean definition for expressions
 *
 * <p>
 * A bean that is non nested (or top of a collection) will hold all the expressions for the graph. A new
 * expression graph is initialized and expressions are collected as the bean and all its children are processed.
 * The expression graph is then set as a property on the top bean definition
 * </p>
 *
 * @param beanName name of the bean to process
 * @param beanDefinition bean definition to process
 * @param beanFactory factory holding all the bean definitions
 * @param processedBeanNames set of bean names that have already been processed
 */
protected void processBeanDefinition(String beanName, BeanDefinition beanDefinition,
        ConfigurableListableBeanFactory beanFactory, Set<String> processedBeanNames) {
    Class<?> beanClass = getBeanClass(beanDefinition, beanFactory);
    if ((beanClass == null) || !UifDictionaryBean.class.isAssignableFrom(beanClass) || processedBeanNames.contains(
            beanName)) {
        return;
    }

    // process bean definition and all nested definitions for expressions
    ManagedMap<String, String> expressionGraph = new ManagedMap<String, String>();
    MutablePropertyValues pvs = beanDefinition.getPropertyValues();
    if (pvs.contains(UifPropertyPaths.EXPRESSION_GRAPH)) {
        expressionGraph = (ManagedMap<String, String>) pvs.getPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH)
                .getValue();
        if (expressionGraph == null) {
            expressionGraph = new ManagedMap<String, String>();
        }
    }

    expressionGraph.setMergeEnabled(false);
    processNestedBeanDefinition(beanName, beanDefinition, "", expressionGraph, beanFactory, processedBeanNames);

    // add property for expression graph
    pvs = beanDefinition.getPropertyValues();
    pvs.addPropertyValue(UifPropertyPaths.EXPRESSION_GRAPH, expressionGraph);
}