本文整理匯總了Java中org.springframework.beans.factory.config.TypedStringValue類的典型用法代碼示例。如果您正苦於以下問題:Java TypedStringValue類的具體用法?Java TypedStringValue怎麽用?Java TypedStringValue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TypedStringValue類屬於org.springframework.beans.factory.config包,在下文中一共展示了TypedStringValue類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getInterfaces
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
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() };
}
}
示例2: convertClassesToStrings
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
/**
* 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;
}
示例3: parseValueElement
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
/**
* 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;
}
}
示例4: parsePropsElement
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
/**
* 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;
}
示例5: parseValueElement
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
/**
* 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;
}
}
示例6: parsePropsElement
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
/**
* 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;
}
示例7: addIncludePatterns
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
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);
}
}
示例8: postProcessBeanFactory
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
/** {@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);
}
示例9: getClassForPropertyValue
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
/**
* 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;
}
}
示例10: updatePropertyValue
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
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;
}
}
示例11: updatePropertyValue
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
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;
}
}
示例12: updatePropertyValue
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
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;
}
}
示例13: getStringValFromPVs
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
/**
* 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;
}
示例14: updatePropertyValue
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
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;
}
}
示例15: postProcessBeanFactory
import org.springframework.beans.factory.config.TypedStringValue; //導入依賴的package包/類
/**
* @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));
}
}
}
}