java类org.springframework.beans.factory.config.TypedStringValue的实例源码

MandatoryImporterDependencyFactory.java 文件源码 项目:gemini.blueprint 阅读 18 收藏 0 点赞 0 评论 0
private String[] getInterfaces(PropertyValue pv) {
    if (pv == null)
        return new String[0];

    Object value = pv.getValue();

    if (value instanceof Collection) {
        Collection collection = (Collection) value;
        String[] strs = new String[collection.size()];
        int index = 0;
        for (Object obj : collection) {
            if (value instanceof TypedStringValue) {
                strs[index] = ((TypedStringValue) value).getValue();
            } else {
                strs[index] = value.toString();
            }
            index++;
        }
        return strs;
    } else {
        return new String[] { value.toString() };
    }
}
ParserUtils.java 文件源码 项目:gemini.blueprint 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Utility method used for maintaining backwards compatibility by converting Class objects to String (using their
 * class names). Used by importer and exporter parsing to set the 'interfaces' property.
 * 
 * @param parsedClasses collection of parsed classes
 * @return a collection of converted (if necessary) metadata
 */
public static Set<?> convertClassesToStrings(Set<?> parsedClasses) {
    Set<Object> interfaces = new ManagedSet<Object>(parsedClasses.size());

    for (Object clazz : parsedClasses) {
        if (clazz instanceof TypedStringValue || clazz instanceof String) {
            interfaces.add(clazz);
        } else {
            // add adapter definition for bean references (which can be classes)
            interfaces.add(BeanDefinitionBuilder.genericBeanDefinition(ToStringClassAdapter.class)
                    .addConstructorArgValue(clazz).getBeanDefinition());
        }
    }

    return interfaces;
}
BlueprintParser.java 文件源码 项目:gemini.blueprint 阅读 28 收藏 0 点赞 0 评论 0
/**
 * Return a typed String value Object for the given value element.
 * 
 * @param ele element
 * @param defaultTypeName type class name
 * @return typed String value Object
 */
private Object parseValueElement(Element ele, String defaultTypeName) {
    // It's a literal value.
    String value = DomUtils.getTextValue(ele);
    String specifiedTypeName = ele.getAttribute(BeanDefinitionParserDelegate.TYPE_ATTRIBUTE);
    String typeName = specifiedTypeName;
    if (!StringUtils.hasText(typeName)) {
        typeName = defaultTypeName;
    }
    try {
        TypedStringValue typedValue = buildTypedStringValue(value, typeName);
        typedValue.setSource(extractSource(ele));
        typedValue.setSpecifiedTypeName(specifiedTypeName);
        return typedValue;
    } catch (ClassNotFoundException ex) {
        error("Type class [" + typeName + "] not found for <value> element", ele, ex);
        return value;
    }
}
BlueprintParser.java 文件源码 项目:gemini.blueprint 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
    ManagedProperties props = new OrderedManagedProperties();
    props.setSource(extractSource(propsEle));
    props.setMergeEnabled(parseMergeAttribute(propsEle));

    List propEles = DomUtils.getChildElementsByTagName(propsEle, BeanDefinitionParserDelegate.PROP_ELEMENT);
    for (Iterator it = propEles.iterator(); it.hasNext();) {
        Element propEle = (Element) it.next();
        String key = propEle.getAttribute(BeanDefinitionParserDelegate.KEY_ATTRIBUTE);
        // Trim the text value to avoid unwanted whitespace
        // caused by typical XML formatting.
        String value = DomUtils.getTextValue(propEle).trim();

        TypedStringValue keyHolder = new TypedStringValue(key);
        keyHolder.setSource(extractSource(propEle));
        TypedStringValue valueHolder = new TypedStringValue(value);
        valueHolder.setSource(extractSource(propEle));
        props.put(keyHolder, valueHolder);
    }

    return props;
}
BeanDefinitionParserDelegate.java 文件源码 项目:lams 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Return a typed String value Object for the given value element.
 */
public Object parseValueElement(Element ele, String defaultTypeName) {
    // It's a literal value.
    String value = DomUtils.getTextValue(ele);
    String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE);
    String typeName = specifiedTypeName;
    if (!StringUtils.hasText(typeName)) {
        typeName = defaultTypeName;
    }
    try {
        TypedStringValue typedValue = buildTypedStringValue(value, typeName);
        typedValue.setSource(extractSource(ele));
        typedValue.setSpecifiedTypeName(specifiedTypeName);
        return typedValue;
    }
    catch (ClassNotFoundException ex) {
        error("Type class [" + typeName + "] not found for <value> element", ele, ex);
        return value;
    }
}
BeanDefinitionParserDelegate.java 文件源码 项目:lams 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
    ManagedProperties props = new ManagedProperties();
    props.setSource(extractSource(propsEle));
    props.setMergeEnabled(parseMergeAttribute(propsEle));

    List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT);
    for (Element propEle : propEles) {
        String key = propEle.getAttribute(KEY_ATTRIBUTE);
        // Trim the text value to avoid unwanted whitespace
        // caused by typical XML formatting.
        String value = DomUtils.getTextValue(propEle).trim();
        TypedStringValue keyHolder = new TypedStringValue(key);
        keyHolder.setSource(extractSource(propEle));
        TypedStringValue valueHolder = new TypedStringValue(value);
        valueHolder.setSource(extractSource(propEle));
        props.put(keyHolder, valueHolder);
    }

    return props;
}
AspectJAutoProxyBeanDefinitionParser.java 文件源码 项目:lams 阅读 20 收藏 0 点赞 0 评论 0
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);
    }
}
BaseActiveStoreConfiguration.java 文件源码 项目:Lagerta 阅读 20 收藏 0 点赞 0 评论 0
/** {@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);
}
BaseActiveStoreConfiguration.java 文件源码 项目:Lagerta 阅读 18 收藏 0 点赞 0 评论 0
/** {@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);
}
AspectJAutoProxyBeanDefinitionParser.java 文件源码 项目:spring4-understanding 阅读 21 收藏 0 点赞 0 评论 0
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);
    }
}
BeanDefinitionParserDelegate.java 文件源码 项目:spring4-understanding 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Return a typed String value Object for the given value element.
 */
public Object parseValueElement(Element ele, String defaultTypeName) {
    // It's a literal value.
    String value = DomUtils.getTextValue(ele);
    String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE);
    String typeName = specifiedTypeName;
    if (!StringUtils.hasText(typeName)) {
        typeName = defaultTypeName;
    }
    try {
        TypedStringValue typedValue = buildTypedStringValue(value, typeName);
        typedValue.setSource(extractSource(ele));
        typedValue.setSpecifiedTypeName(specifiedTypeName);
        return typedValue;
    }
    catch (ClassNotFoundException ex) {
        error("Type class [" + typeName + "] not found for <value> element", ele, ex);
        return value;
    }
}
BeanDefinitionParserDelegate.java 文件源码 项目:spring4-understanding 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
    ManagedProperties props = new ManagedProperties();
    props.setSource(extractSource(propsEle));
    props.setMergeEnabled(parseMergeAttribute(propsEle));

    List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT);
    for (Element propEle : propEles) {
        String key = propEle.getAttribute(KEY_ATTRIBUTE);
        // Trim the text value to avoid unwanted whitespace
        // caused by typical XML formatting.
        String value = DomUtils.getTextValue(propEle).trim();
        TypedStringValue keyHolder = new TypedStringValue(key);
        keyHolder.setSource(extractSource(propEle));
        TypedStringValue valueHolder = new TypedStringValue(value);
        valueHolder.setSource(extractSource(propEle));
        props.put(keyHolder, valueHolder);
    }

    return props;
}
StoreInterfaceAwareBeanPostProcessor.java 文件源码 项目:spring-content 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Returns the class which is configured in the given {@link PropertyValue}. In case it is not a
 * {@link TypedStringValue} or the value contained cannot be interpreted as {@link Class} it will return null.
 * 
 * @param propertyValue
 * @param beanName
 * @return
 */
private Class<?> getClassForPropertyValue(PropertyValue propertyValue, String beanName) {

    Object value = propertyValue.getValue();
    String className = null;

    if (value instanceof TypedStringValue) {
        className = ((TypedStringValue) value).getValue();
    } else if (value instanceof String) {
        className = (String) value;
    } else if (value instanceof Class<?>) {
        return (Class<?>) value;
    } else {
        return Void.class;
    }

    try {
        return ClassUtils.resolveClassName(className, context.getBeanClassLoader());
    } catch (IllegalArgumentException ex) {
        LOGGER.warn(String.format("Couldn't load class %s referenced as repository interface in bean %s!", className,
                beanName));
        return Void.class;
    }
}
ZebraMapperScannerConfigurer.java 文件源码 项目:zebra 阅读 17 收藏 0 点赞 0 评论 0
private String updatePropertyValue(String propertyName, PropertyValues values) {
    PropertyValue property = values.getPropertyValue(propertyName);

    if (property == null) {
        return null;
    }

    Object value = property.getValue();

    if (value == null) {
        return null;
    } else if (value instanceof String) {
        return value.toString();
    } else if (value instanceof TypedStringValue) {
        return ((TypedStringValue) value).getValue();
    } else {
        return null;
    }
}
BeanDefinitionParserDelegate.java 文件源码 项目:spring 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Return a typed String value Object for the given value element.
 */
public Object parseValueElement(Element ele, String defaultTypeName) {
    // It's a literal value.
    String value = DomUtils.getTextValue(ele);
    String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE);
    String typeName = specifiedTypeName;
    if (!StringUtils.hasText(typeName)) {
        typeName = defaultTypeName;
    }
    try {
        TypedStringValue typedValue = buildTypedStringValue(value, typeName);
        typedValue.setSource(extractSource(ele));
        typedValue.setSpecifiedTypeName(specifiedTypeName);
        return typedValue;
    }
    catch (ClassNotFoundException ex) {
        error("Type class [" + typeName + "] not found for <value> element", ele, ex);
        return value;
    }
}
BeanDefinitionParserDelegate.java 文件源码 项目:spring 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
    ManagedProperties props = new ManagedProperties();
    props.setSource(extractSource(propsEle));
    props.setMergeEnabled(parseMergeAttribute(propsEle));

    List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT);
    for (Element propEle : propEles) {
        String key = propEle.getAttribute(KEY_ATTRIBUTE);
        // Trim the text value to avoid unwanted whitespace
        // caused by typical XML formatting.
        String value = DomUtils.getTextValue(propEle).trim();
        TypedStringValue keyHolder = new TypedStringValue(key);
        keyHolder.setSource(extractSource(propEle));
        TypedStringValue valueHolder = new TypedStringValue(value);
        valueHolder.setSource(extractSource(propEle));
        props.put(keyHolder, valueHolder);
    }

    return props;
}
AspectJAutoProxyBeanDefinitionParser.java 文件源码 项目:spring 阅读 26 收藏 0 点赞 0 评论 0
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);
    }
}
MapperScannerConfigurer.java 文件源码 项目:rabbitframework 阅读 22 收藏 0 点赞 0 评论 0
private String updatePropertyValue(String propertyName,
        PropertyValues values) {
    PropertyValue property = values.getPropertyValue(propertyName);

    if (property == null) {
        return null;
    }

    Object value = property.getValue();

    if (value == null) {
        return null;
    } else if (value instanceof String) {
        return value.toString();
    } else if (value instanceof TypedStringValue) {
        return ((TypedStringValue) value).getValue();
    } else {
        return null;
    }
}
MapperScannerConfigurer.java 文件源码 项目:mybatis-spring-1.2.2 阅读 32 收藏 0 点赞 0 评论 0
private String updatePropertyValue(String propertyName, PropertyValues values) {
  PropertyValue property = values.getPropertyValue(propertyName);

  if (property == null) {
    return null;
  }

  Object value = property.getValue();

  if (value == null) {
    return null;
  } else if (value instanceof String) {
    return value.toString();
  } else if (value instanceof TypedStringValue) {
    return ((TypedStringValue) value).getValue();
  } else {
    return null;
  }
}
ViewModelUtils.java 文件源码 项目:kc-rice 阅读 22 收藏 0 点赞 0 评论 0
/**
 * Helper method for getting the string value of a property from a {@link PropertyValues}
 *
 * @param propertyValues property values instance to pull from
 * @param propertyName name of property whose value should be retrieved
 * @return String value for property or null if property was not found
 */
public static String getStringValFromPVs(PropertyValues propertyValues, String propertyName) {
    String propertyValue = null;

    if ((propertyValues != null) && propertyValues.contains(propertyName)) {
        Object pvValue = propertyValues.getPropertyValue(propertyName).getValue();
        if (pvValue instanceof TypedStringValue) {
            TypedStringValue typedStringValue = (TypedStringValue) pvValue;
            propertyValue = typedStringValue.getValue();
        } else if (pvValue instanceof String) {
            propertyValue = (String) pvValue;
        }
    }

    return propertyValue;
}
ScannerConfigurer.java 文件源码 项目:mybatis-spring-support 阅读 17 收藏 0 点赞 0 评论 0
private String updatePropertyValue(String propertyName, PropertyValues values) {
  PropertyValue property = values.getPropertyValue(propertyName);

  if (property == null) {
    return null;
  }

  Object value = property.getValue();

  if (value == null) {
    return null;
  } else if (value instanceof String) {
    return value.toString();
  } else if (value instanceof TypedStringValue) {
    return ((TypedStringValue) value).getValue();
  } else {
    return null;
  }
}
SpringRestClientScannerConfigurer.java 文件源码 项目:spring-rest-client 阅读 17 收藏 0 点赞 0 评论 0
private String updatePropertyValue(String propertyName, PropertyValues values) {
    PropertyValue property = values.getPropertyValue(propertyName);

    if (property == null) {
        return null;
    }

    Object value = property.getValue();

    if (value == null) {
        return null;
    } else if (value instanceof String) {
        return value.toString();
    } else if (value instanceof TypedStringValue) {
        return ((TypedStringValue) value).getValue();
    } else {
        return null;
    }
}
RMMethodSecurityPostProcessor.java 文件源码 项目:records-management-old 阅读 19 收藏 0 点赞 0 评论 0
/**
 * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)
 */
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
{
    for (String bean : getSecurityBeanNames(beanFactory))
    {
        if (beanFactory.containsBeanDefinition(bean))
        {
            if (logger.isDebugEnabled())
            {
                logger.debug("Adding RM method security definitions for " + bean);
            }

            BeanDefinition beanDef = beanFactory.getBeanDefinition(bean);
            PropertyValue beanValue = beanDef.getPropertyValues().getPropertyValue(PROP_OBJECT_DEFINITION_SOURCE);
            if (beanValue != null)
            {
                String beanStringValue = (String)((TypedStringValue)beanValue.getValue()).getValue();
                String mergedStringValue = merge(beanStringValue);
                beanDef.getPropertyValues().addPropertyValue(PROP_OBJECT_DEFINITION_SOURCE, new TypedStringValue(mergedStringValue));
            }
        }
    }
}
AspectJAutoProxyBeanDefinitionParser.java 文件源码 项目:class-guard 阅读 19 收藏 0 点赞 0 评论 0
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);
    }
}
BeanDefinitionParserDelegate.java 文件源码 项目:class-guard 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Return a typed String value Object for the given value element.
 */
public Object parseValueElement(Element ele, String defaultTypeName) {
    // It's a literal value.
    String value = DomUtils.getTextValue(ele);
    String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE);
    String typeName = specifiedTypeName;
    if (!StringUtils.hasText(typeName)) {
        typeName = defaultTypeName;
    }
    try {
        TypedStringValue typedValue = buildTypedStringValue(value, typeName);
        typedValue.setSource(extractSource(ele));
        typedValue.setSpecifiedTypeName(specifiedTypeName);
        return typedValue;
    }
    catch (ClassNotFoundException ex) {
        error("Type class [" + typeName + "] not found for <value> element", ele, ex);
        return value;
    }
}
BeanDefinitionParserDelegate.java 文件源码 项目:class-guard 阅读 29 收藏 0 点赞 0 评论 0
/**
 * Parse a props element.
 */
public Properties parsePropsElement(Element propsEle) {
    ManagedProperties props = new ManagedProperties();
    props.setSource(extractSource(propsEle));
    props.setMergeEnabled(parseMergeAttribute(propsEle));

    List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT);
    for (Element propEle : propEles) {
        String key = propEle.getAttribute(KEY_ATTRIBUTE);
        // Trim the text value to avoid unwanted whitespace
        // caused by typical XML formatting.
        String value = DomUtils.getTextValue(propEle).trim();
        TypedStringValue keyHolder = new TypedStringValue(key);
        keyHolder.setSource(extractSource(propEle));
        TypedStringValue valueHolder = new TypedStringValue(value);
        valueHolder.setSource(extractSource(propEle));
        props.put(keyHolder, valueHolder);
    }

    return props;
}
MessageSourceBeanFactoryPostProcessor.java 文件源码 项目:TechnologyReadinessTool 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    Map<String, ResourceBundleNameProvider> beans = beanFactory.getBeansOfType(ResourceBundleNameProvider.class);
    if (beans != null) {
        BeanDefinition messageSourceDef = beanFactory.getBeanDefinition("messageSource");

        ManagedList<TypedStringValue> bundleNames = new ManagedList<>();
        bundleNames.setMergeEnabled(true);

        Collection<ResourceBundleNameProvider> nameProviders = beans.values();
        for (ResourceBundleNameProvider resourceBundleNameProvider : nameProviders) {
            for (String bundleName : resourceBundleNameProvider.getBundleNames()) {
                bundleNames.add(new TypedStringValue(bundleName));
            }
        }

        messageSourceDef.getPropertyValues().add("basenames", bundleNames);
    }
}
MapperScannerConfigurer.java 文件源码 项目:mybatis-spring 阅读 26 收藏 0 点赞 0 评论 0
private String updatePropertyValue(String propertyName, PropertyValues values) {
  PropertyValue property = values.getPropertyValue(propertyName);

  if (property == null) {
    return null;
  }

  Object value = property.getValue();

  if (value == null) {
    return null;
  } else if (value instanceof String) {
    return value.toString();
  } else if (value instanceof TypedStringValue) {
    return ((TypedStringValue) value).getValue();
  } else {
    return null;
  }
}
ViewModelUtils.java 文件源码 项目:rice 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Helper method for getting the string value of a property from a {@link PropertyValues}
 *
 * @param propertyValues property values instance to pull from
 * @param propertyName name of property whose value should be retrieved
 * @return String value for property or null if property was not found
 */
public static String getStringValFromPVs(PropertyValues propertyValues, String propertyName) {
    String propertyValue = null;

    if ((propertyValues != null) && propertyValues.contains(propertyName)) {
        Object pvValue = propertyValues.getPropertyValue(propertyName).getValue();
        if (pvValue instanceof TypedStringValue) {
            TypedStringValue typedStringValue = (TypedStringValue) pvValue;
            propertyValue = typedStringValue.getValue();
        } else if (pvValue instanceof String) {
            propertyValue = (String) pvValue;
        }
    }

    return propertyValue;
}
RestComponentScanner.java 文件源码 项目:fastser-web 阅读 33 收藏 0 点赞 0 评论 0
private String updatePropertyValue(String propertyName, PropertyValues values) {
  PropertyValue property = values.getPropertyValue(propertyName);

  if (property == null) {
    return null;
  }

  Object value = property.getValue();

  if (value == null) {
    return null;
  } else if (value instanceof String) {
    return value.toString();
  } else if (value instanceof TypedStringValue) {
    return ((TypedStringValue) value).getValue();
  } else {
    return null;
  }
}


问题


面经


文章

微信
公众号

扫码关注公众号