本文整理匯總了Java中org.springframework.beans.factory.support.ManagedMap.setMergeEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java ManagedMap.setMergeEnabled方法的具體用法?Java ManagedMap.setMergeEnabled怎麽用?Java ManagedMap.setMergeEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.beans.factory.support.ManagedMap
的用法示例。
在下文中一共展示了ManagedMap.setMergeEnabled方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseMap
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
/**
* 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;
}
示例2: parseMap
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
/**
* 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;
}
示例3: processBeanDefinition
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
/**
* 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);
}
示例4: visitMap
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
/**
* 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);
}
示例5: processBeanDefinition
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
/**
* 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);
}
示例6: createInjectionsMap
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
/**
* Creates a <code>Map</code> which contains all the defined injections. The
* map is a <code>ManagedMap</code>, so that the references will be
* resolved.
*
* @param element
* the parent element which contains all the injections
* @param parserContext
* the <code>ParserContext</code>
*
* @return the <code>Map</code> containing the beans to be injected
*
* @see ParserContext
* @see ManagedMap
*/
protected Map<?, ?> createInjectionsMap(final Element element,
final ParserContext parserContext) {
final List<Element> injEls = DomUtils.getChildElementsByTagName(
element, XML_ELEMENT_INJECT);
// create the map
final ManagedMap<Object, Object> map = new ManagedMap<Object, Object>(
injEls.size());
map.setSource(parserContext.extractSource(element));
map.setKeyTypeName(String.class.getName());
map.setValueTypeName(Object.class.getName());
map.setMergeEnabled(false);
// insert the values
for (final Element injEl : injEls) {
final String innerId = injEl.getAttribute(XML_ATTRIBUTE_INNERID);
final String outerId = injEl.getAttribute(XML_ATTRIBUTE_OUTERID);
// generate the reference
final RuntimeBeanReference ref = new RuntimeBeanReference(outerId);
ref.setSource(parserContext.extractSource(injEl));
// add it
map.put(innerId, ref);
}
return map;
}
示例7: handleMapValues
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
protected Object handleMapValues(final PropertyValue configuredValue)
{
final Object value;
LOGGER.debug("[{}] Map of values / bean reference names has been configured - treating property {} of {} as <map>", this.beanName,
this.propertyName, this.targetBeanName);
final ManagedMap<Object, Object> map = new ManagedMap<>();
if (this.merge && configuredValue != null)
{
final Object configuredValueDefinition = configuredValue.getValue();
if (configuredValueDefinition instanceof ManagedMap<?, ?>)
{
final ManagedMap<?, ?> oldMap = (ManagedMap<?, ?>) configuredValueDefinition;
map.setKeyTypeName(oldMap.getKeyTypeName());
map.setValueTypeName(oldMap.getValueTypeName());
map.setMergeEnabled(oldMap.isMergeEnabled());
map.setSource(oldMap.getSource());
map.putAll(oldMap);
LOGGER.debug("[{}] Merged existing map values: {}", this.beanName, oldMap);
}
}
Map<Object, Object> valuesToMap;
if (this.valueMap != null)
{
LOGGER.debug("[{}] Map of configured values for {} of {}: ", this.beanName, this.propertyName, this.targetBeanName,
this.valueMap);
valuesToMap = this.valueMap;
}
else
{
LOGGER.debug("[{}] Map of configured bean reference names for {} of {}: ", this.beanName, this.propertyName,
this.targetBeanName, this.beanReferenceNameMap);
valuesToMap = new HashMap<>();
for (final Entry<Object, String> beanReferenceEntry : this.beanReferenceNameMap.entrySet())
{
valuesToMap.put(beanReferenceEntry.getKey(), new RuntimeBeanReference(beanReferenceEntry.getValue()));
}
}
LOGGER.debug("[{}] Putting new entries into map for {} of {}", this.beanName, this.propertyName, this.targetBeanName);
map.putAll(valuesToMap);
if (!map.isMergeEnabled() && this.mergeParent)
{
LOGGER.debug("[{}] Enabling \"merge\" for <map> on {} of {}", this.beanName, this.propertyName, this.targetBeanName);
}
map.setMergeEnabled(map.isMergeEnabled() || this.mergeParent);
value = map;
return value;
}
示例8: visitMap
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected void visitMap(String propertyName, Map<String, String> parentExpressionGraph,
Map<String, String> expressionGraph, Map<?, ?> mapVal, ConfigurableListableBeanFactory beanFactory,
Set<String> processedBeanNames) {
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();
String keyStr = getStringValue(key);
String elemPropertyName = propertyName + "['" + keyStr + "']";
if (hasExpression(val)) {
String strValue = getStringValue(val);
expressionGraph.put(elemPropertyName, strValue);
} else {
// process map value bean definition as a top level bean
if ((val instanceof BeanDefinition) || (val instanceof BeanDefinitionHolder)) {
String beanName = null;
BeanDefinition beanDefinition;
if (val instanceof BeanDefinition) {
beanDefinition = (BeanDefinition) val;
} else {
beanDefinition = ((BeanDefinitionHolder) val).getBeanDefinition();
beanName = ((BeanDefinitionHolder) val).getBeanName();
}
processBeanDefinition(beanName, beanDefinition, beanFactory, processedBeanNames);
}
newMap.put(key, val);
}
if (isMergeEnabled && parentExpressionGraph.containsKey(elemPropertyName)) {
parentExpressionGraph.remove(elemPropertyName);
}
}
if (!isMergeEnabled) {
// clear any expressions that match the property minus key
Map<String, String> adjustedParentExpressionGraph = new HashMap<String, String>();
for (Map.Entry<String, String> parentExpression : parentExpressionGraph.entrySet()) {
if (!parentExpression.getKey().startsWith(propertyName + "[")) {
adjustedParentExpressionGraph.put(parentExpression.getKey(), parentExpression.getValue());
}
}
parentExpressionGraph.clear();
parentExpressionGraph.putAll(adjustedParentExpressionGraph);
}
mapVal.clear();
mapVal.putAll(newMap);
}
示例9: parseStaticOptions
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
protected AbstractBeanDefinition parseStaticOptions(ParserContext parserContext, BeanDefinitionRegistry beanDefRegistry, Element elem, String elemNsPrefix,
String elemNsUri, String elemLocalName, AbstractBeanDefinition beanDef) throws Exception {
super.parseDefinition(parserContext, beanDefRegistry, elem, elemNsPrefix, elemNsUri, elemLocalName, beanDef);
MutablePropertyValues staticOptsPropValues = beanDef.getPropertyValues();
List<Element> staticFuncElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_FUNC_ELEM_LOCAL_NAME);
if (!staticFuncElems.isEmpty()) {
ManagedList<Object> staticFuncs = new ManagedList<>(staticFuncElems.size());
staticFuncs.setMergeEnabled(true);
staticFuncs.setElementTypeName(ExtensionFunctionDefinition.class.getName());
staticFuncElems
.forEach(staticFuncElem -> staticFuncs.add(new RuntimeBeanReference(staticFuncElem.getAttribute(BeanDefinitionParserDelegate.REF_ATTRIBUTE))));
staticOptsPropValues.addPropertyValue(FUNCS_PROP_NAME, staticFuncs);
}
List<Element> staticNsElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_NS_ELEM_LOCAL_NAME);
if (!staticNsElems.isEmpty()) {
ManagedMap<String, String> staticNamespaces = new ManagedMap<>(staticNsElems.size());
staticNamespaces.setMergeEnabled(true);
for (Element staticNsElem : staticNsElems) {
staticNamespaces.put(staticNsElem.getAttribute(PREFIX_ATTR_NAME), DomUtils.getTextValue(staticNsElem).trim());
}
staticOptsPropValues.addPropertyValue(NAMESPACES_PROP_NAME, staticNamespaces);
}
List<Element> staticVarElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_VAR_ELEM_LOCAL_NAME);
if (!staticVarElems.isEmpty()) {
ManagedMap<QName, Object> staticVars = new ManagedMap<>(staticVarElems.size());
staticVars.setMergeEnabled(true);
staticVars.setValueTypeName(XdmValue.class.getName());
for (Element staticVarElem : staticVarElems) {
staticVars.put(new QName(staticVarElem.getAttribute(NAME_ATTRIBUTE)), DomUtils.getTextValue(staticVarElem).trim());
}
staticOptsPropValues.addPropertyValue(VARS_PROP_NAME, staticVars);
}
List<Element> staticPooledDocElems = SdcctDomUtils.findChildElements(elem, elemNsUri, STATIC_POOLED_DOC_ELEM_LOCAL_NAME);
if (!staticPooledDocElems.isEmpty()) {
XdmDocumentBeanDefinitionParser docBeanDefParser =
((XdmDocumentBeanDefinitionParser) this.nsHandler.getBeanDefinitionParsers().get(XdmDocumentBeanDefinitionParser.DOC_ELEM_LOCAL_NAME));
ManagedList<Object> staticPooledDocs = new ManagedList<>(staticPooledDocElems.size());
staticPooledDocs.setMergeEnabled(true);
staticPooledDocs.setElementTypeName(XdmDocument.class.getName());
for (Element staticPooledDocElem : staticPooledDocElems) {
staticPooledDocs.add(
docBeanDefParser.parse(staticPooledDocElem, new ParserContext(parserContext.getReaderContext(), parserContext.getDelegate(), beanDef)));
}
staticOptsPropValues.addPropertyValue(POOLED_DOCS_PROP_NAME, staticPooledDocs);
}
return beanDef;
}