當前位置: 首頁>>代碼示例>>Java>>正文


Java ManagedMap.containsKey方法代碼示例

本文整理匯總了Java中org.springframework.beans.factory.support.ManagedMap.containsKey方法的典型用法代碼示例。如果您正苦於以下問題:Java ManagedMap.containsKey方法的具體用法?Java ManagedMap.containsKey怎麽用?Java ManagedMap.containsKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.beans.factory.support.ManagedMap的用法示例。


在下文中一共展示了ManagedMap.containsKey方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSecurityMetadataSource

import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
public static BeanDefinition createSecurityMetadataSource(Element element, ParserContext pc) {
  List<Element> filterPatterns = DomUtils.getChildElementsByTagName(element, "url");

  if (filterPatterns.isEmpty()) {
    return null;
  }

  // TODO : add support for lowercase-comparisons
  String patternType = element.getAttribute("path-type");
  if (!StringUtils.hasText(patternType)) {
    patternType = "ant";
  }

  MatcherType matcherType = MatcherType.valueOf(patternType);

  ManagedMap<BeanDefinition, BeanDefinition> invocationDefinitionMap = new ManagedMap<BeanDefinition, BeanDefinition>();

  for (Element filterPattern : filterPatterns) {
    String path = filterPattern.getAttribute("pattern");
    if (!StringUtils.hasText(path)) {
      pc.getReaderContext().error("pattern attribute cannot be empty or null", filterPattern);
    }

    String method = filterPattern.getAttribute("httpMethod");
    if (!StringUtils.hasText(method)) {
      method = null;
    }

    String access = filterPattern.getAttribute("resources");

    if (StringUtils.hasText(access)) {
      BeanDefinition matcher = matcherType.createMatcher(path, method);
      if (access.equals("none")) {
        invocationDefinitionMap.put(matcher, BeanDefinitionBuilder.rootBeanDefinition(Collections.class).setFactoryMethod("emptyList").getBeanDefinition());
      }
      else {
        BeanDefinitionBuilder attributeBuilder = BeanDefinitionBuilder.rootBeanDefinition(SecurityConfig.class);
        attributeBuilder.addConstructorArgValue(access);
        attributeBuilder.setFactoryMethod("createListFromCommaDelimitedString");

        if (invocationDefinitionMap.containsKey(matcher)) {
          pc.getReaderContext().warning("Duplicate URL defined: " + path
                                          + ". The original attribute values will be overwritten", pc.extractSource(filterPattern));
        }

        invocationDefinitionMap.put(matcher, attributeBuilder.getBeanDefinition());
      }
    }
  }

  BeanDefinitionBuilder fidsBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultFilterInvocationSecurityMetadataSource.class);
  fidsBuilder.addConstructorArgValue(invocationDefinitionMap);
  fidsBuilder.getRawBeanDefinition().setSource(pc.extractSource(element));

  return fidsBuilder.getBeanDefinition();
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:57,代碼來源:ConfigUtils.java

示例2: createSecurityMetadataSource

import org.springframework.beans.factory.support.ManagedMap; //導入方法依賴的package包/類
public static BeanDefinition createSecurityMetadataSource(Element element, ParserContext pc) {
  List<Element> filterPatterns = DomUtils.getChildElementsByTagName(element, "url");

  if (filterPatterns.isEmpty()) {
    return null;
  }

  String patternType = element.getAttribute("path-type");
  if (!StringUtils.hasText(patternType)) {
    patternType = "ant";
  }

  MatcherType matcherType = MatcherType.valueOf(patternType);

  ManagedMap<BeanDefinition, BeanDefinition> invocationDefinitionMap = new ManagedMap<BeanDefinition, BeanDefinition>();

  for (Element filterPattern : filterPatterns) {
    String path = filterPattern.getAttribute("pattern");
    if (!StringUtils.hasText(path)) {
      pc.getReaderContext().error("pattern attribute cannot be empty or null", filterPattern);
    }

    String method = filterPattern.getAttribute("httpMethod");
    if (!StringUtils.hasText(method)) {
      method = null;
    }

    String access = filterPattern.getAttribute("resources");

    if (StringUtils.hasText(access)) {
      BeanDefinition matcher = matcherType.createMatcher(path, method);
      if (access.equals("none")) {
        invocationDefinitionMap.put(matcher, BeanDefinitionBuilder.rootBeanDefinition(Collections.class).setFactoryMethod("emptyList").getBeanDefinition());
      }
      else {
        BeanDefinitionBuilder attributeBuilder = BeanDefinitionBuilder.rootBeanDefinition(SecurityConfig.class);
        attributeBuilder.addConstructorArgValue(access);
        attributeBuilder.setFactoryMethod("createListFromCommaDelimitedString");

        if (invocationDefinitionMap.containsKey(matcher)) {
          pc.getReaderContext().warning("Duplicate URL defined: " + path
                                          + ". The original attribute values will be overwritten", pc.extractSource(filterPattern));
        }

        invocationDefinitionMap.put(matcher, attributeBuilder.getBeanDefinition());
      }
    }
  }

  BeanDefinitionBuilder fidsBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultFilterInvocationSecurityMetadataSource.class);
  fidsBuilder.addConstructorArgValue(invocationDefinitionMap);
  fidsBuilder.getRawBeanDefinition().setSource(pc.extractSource(element));

  return fidsBuilder.getBeanDefinition();
}
 
開發者ID:jungyang,項目名稱:oauth-client-master,代碼行數:56,代碼來源:ConfigUtils.java


注:本文中的org.springframework.beans.factory.support.ManagedMap.containsKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。