本文整理匯總了Java中org.springframework.beans.factory.support.ManagedMap.setSource方法的典型用法代碼示例。如果您正苦於以下問題:Java ManagedMap.setSource方法的具體用法?Java ManagedMap.setSource怎麽用?Java ManagedMap.setSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.beans.factory.support.ManagedMap
的用法示例。
在下文中一共展示了ManagedMap.setSource方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerHandlerMapping
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
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;
}
示例2: shallowCloneManagedCollections
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
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);
}
}
}
示例3: 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;
}
示例4: parseAttributeSource
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
private RootBeanDefinition parseAttributeSource(Element attrEle, ParserContext parserContext) {
List<Element> methods = DomUtils.getChildElementsByTagName(attrEle, METHOD_ELEMENT);
ManagedMap<TypedStringValue, RuleBasedTransactionAttribute> transactionAttributeMap =
new ManagedMap<TypedStringValue, RuleBasedTransactionAttribute>(methods.size());
transactionAttributeMap.setSource(parserContext.extractSource(attrEle));
for (Element methodEle : methods) {
String name = methodEle.getAttribute(METHOD_NAME_ATTRIBUTE);
TypedStringValue nameHolder = new TypedStringValue(name);
nameHolder.setSource(parserContext.extractSource(methodEle));
RuleBasedTransactionAttribute attribute = new RuleBasedTransactionAttribute();
String propagation = methodEle.getAttribute(PROPAGATION_ATTRIBUTE);
String isolation = methodEle.getAttribute(ISOLATION_ATTRIBUTE);
String timeout = methodEle.getAttribute(TIMEOUT_ATTRIBUTE);
String readOnly = methodEle.getAttribute(READ_ONLY_ATTRIBUTE);
if (StringUtils.hasText(propagation)) {
attribute.setPropagationBehaviorName(RuleBasedTransactionAttribute.PREFIX_PROPAGATION + propagation);
}
if (StringUtils.hasText(isolation)) {
attribute.setIsolationLevelName(RuleBasedTransactionAttribute.PREFIX_ISOLATION + isolation);
}
if (StringUtils.hasText(timeout)) {
try {
attribute.setTimeout(Integer.parseInt(timeout));
}
catch (NumberFormatException ex) {
parserContext.getReaderContext().error("Timeout must be an integer value: [" + timeout + "]", methodEle);
}
}
if (StringUtils.hasText(readOnly)) {
attribute.setReadOnly(Boolean.valueOf(methodEle.getAttribute(READ_ONLY_ATTRIBUTE)));
}
List<RollbackRuleAttribute> rollbackRules = new LinkedList<RollbackRuleAttribute>();
if (methodEle.hasAttribute(ROLLBACK_FOR_ATTRIBUTE)) {
String rollbackForValue = methodEle.getAttribute(ROLLBACK_FOR_ATTRIBUTE);
addRollbackRuleAttributesTo(rollbackRules,rollbackForValue);
}
if (methodEle.hasAttribute(NO_ROLLBACK_FOR_ATTRIBUTE)) {
String noRollbackForValue = methodEle.getAttribute(NO_ROLLBACK_FOR_ATTRIBUTE);
addNoRollbackRuleAttributesTo(rollbackRules,noRollbackForValue);
}
attribute.setRollbackRules(rollbackRules);
transactionAttributeMap.put(nameHolder, attribute);
}
RootBeanDefinition attributeSourceDefinition = new RootBeanDefinition(NameMatchTransactionAttributeSource.class);
attributeSourceDefinition.setSource(parserContext.extractSource(attrEle));
attributeSourceDefinition.getPropertyValues().add("nameMap", transactionAttributeMap);
return attributeSourceDefinition;
}
示例5: parse
import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
@Override
public BeanDefinition parse(Element element, ParserContext context) {
Object source = context.extractSource(element);
CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source);
context.pushContainingComponent(compDefinition);
String orderAttribute = element.getAttribute("order");
int order = orderAttribute.isEmpty() ? DEFAULT_MAPPING_ORDER : Integer.valueOf(orderAttribute);
RootBeanDefinition handlerMappingDef = new RootBeanDefinition(WebSocketHandlerMapping.class);
handlerMappingDef.setSource(source);
handlerMappingDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
handlerMappingDef.getPropertyValues().add("order", order);
String handlerMappingName = context.getReaderContext().registerWithGeneratedName(handlerMappingDef);
RuntimeBeanReference sockJsService = WebSocketNamespaceUtils.registerSockJsService(
element, SOCK_JS_SCHEDULER_NAME, context, source);
HandlerMappingStrategy strategy;
if (sockJsService != null) {
strategy = new SockJsHandlerMappingStrategy(sockJsService);
}
else {
RuntimeBeanReference handshakeHandler = WebSocketNamespaceUtils.registerHandshakeHandler(element, context, source);
Element interceptorsElement = DomUtils.getChildElementByTagName(element, "handshake-interceptors");
ManagedList<? super Object> interceptors = WebSocketNamespaceUtils.parseBeanSubElements(interceptorsElement, context);
String allowedOriginsAttribute = element.getAttribute("allowed-origins");
List<String> allowedOrigins = Arrays.asList(StringUtils.tokenizeToStringArray(allowedOriginsAttribute, ","));
interceptors.add(new OriginHandshakeInterceptor(allowedOrigins));
strategy = new WebSocketHandlerMappingStrategy(handshakeHandler, interceptors);
}
ManagedMap<String, Object> urlMap = new ManagedMap<String, Object>();
urlMap.setSource(source);
for (Element mappingElement : DomUtils.getChildElementsByTagName(element, "mapping")) {
strategy.addMapping(mappingElement, urlMap, context);
}
handlerMappingDef.getPropertyValues().add("urlMap", urlMap);
context.registerComponent(new BeanComponentDefinition(handlerMappingDef, handlerMappingName));
context.popAndRegisterContainingComponent();
return null;
}
示例6: 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;
}