本文整理汇总了Java中org.springframework.beans.MutablePropertyValues.getPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:Java MutablePropertyValues.getPropertyValue方法的具体用法?Java MutablePropertyValues.getPropertyValue怎么用?Java MutablePropertyValues.getPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.MutablePropertyValues
的用法示例。
在下文中一共展示了MutablePropertyValues.getPropertyValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postProcessBeanFactory
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的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);
}
示例2: modifyProperties
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的package包/类
/**
* Modify the property values so that period separated property paths are valid for
* map keys. Also creates new maps for properties of map type that are null (assuming
* all maps are potentially nested). The standard bracket {@code[...]} dereferencing
* is also accepted.
* @param propertyValues the property values
* @param target the target object
* @return modified property values
*/
private MutablePropertyValues modifyProperties(MutablePropertyValues propertyValues,
Object target) {
propertyValues = getPropertyValuesForNamePrefix(propertyValues);
if (target instanceof MapHolder) {
propertyValues = addMapPrefix(propertyValues);
}
BeanWrapper wrapper = new BeanWrapperImpl(target);
wrapper.setConversionService(
new RelaxedConversionService(getConversionService()));
wrapper.setAutoGrowNestedPaths(true);
List<PropertyValue> sortedValues = new ArrayList<PropertyValue>();
Set<String> modifiedNames = new HashSet<String>();
List<String> sortedNames = getSortedPropertyNames(propertyValues);
for (String name : sortedNames) {
PropertyValue propertyValue = propertyValues.getPropertyValue(name);
PropertyValue modifiedProperty = modifyProperty(wrapper, propertyValue);
if (modifiedNames.add(modifiedProperty.getName())) {
sortedValues.add(modifiedProperty);
}
}
return new MutablePropertyValues(sortedValues);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:32,代码来源:RelaxedDataBinder.java
示例3: postProcessBeanFactory
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的package包/类
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
String[] beanNameArray = beanFactory.getBeanDefinitionNames();
for (int i = 0; i < beanNameArray.length; i++) {
BeanDefinition beanDef = beanFactory.getBeanDefinition(beanNameArray[i]);
String beanClassName = beanDef.getBeanClassName();
if (FEIGN_FACTORY_CLASS.equals(beanClassName) == false) {
continue;
}
MutablePropertyValues mpv = beanDef.getPropertyValues();
PropertyValue pv = mpv.getPropertyValue("name");
String client = String.valueOf(pv.getValue() == null ? "" : pv.getValue());
if (StringUtils.isNotBlank(client)) {
this.transientClientSet.add(client);
}
}
this.fireAfterPropertiesSet();
}
示例4: testPropertyInline
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的package包/类
public void testPropertyInline() throws Exception {
AbstractBeanDefinition def = (AbstractBeanDefinition) context.getBeanDefinition("propertyValueInline");
assertEquals(Socket.class.getName(), def.getBeanClassName());
MutablePropertyValues propertyValues = def.getPropertyValues();
PropertyValue propertyValue = propertyValues.getPropertyValue("keepAlive");
assertNotNull(propertyValue);
assertTrue(propertyValue.getValue() instanceof BeanMetadataElement);
}
示例5: postProcessBeanFactory
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的package包/类
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
String[] beanNameArray = beanFactory.getBeanDefinitionNames();
for (int i = 0; i < beanNameArray.length; i++) {
String beanName = beanNameArray[i];
BeanDefinition beanDef = beanFactory.getBeanDefinition(beanName);
String beanClassName = beanDef.getBeanClassName();
if (org.springframework.transaction.interceptor.TransactionProxyFactoryBean.class.getName().equals(beanClassName)) {
throw new FatalBeanException(String.format(
"Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).",
beanName));
}
if (org.springframework.transaction.interceptor.TransactionInterceptor.class.getName().equals(beanClassName)) {
boolean errorExists = true;
MutablePropertyValues mpv = beanDef.getPropertyValues();
PropertyValue pv = mpv.getPropertyValue("transactionAttributeSource");
Object value = pv == null ? null : pv.getValue();
if (value != null && RuntimeBeanReference.class.isInstance(value)) {
RuntimeBeanReference reference = (RuntimeBeanReference) value;
BeanDefinition refBeanDef = beanFactory.getBeanDefinition(reference.getBeanName());
String refBeanClassName = refBeanDef.getBeanClassName();
errorExists = AnnotationTransactionAttributeSource.class.getName().equals(refBeanClassName) == false;
}
if (errorExists) {
throw new FatalBeanException(String.format(
"Declaring transactions by configuration is not supported yet, please use annotations to declare transactions(beanId= %s).",
beanName));
}
}
}
}
示例6: validate
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的package包/类
public void validate() throws BeansException {
MutablePropertyValues mpv = this.beanDefinition.getPropertyValues();
PropertyValue retries = mpv.getPropertyValue("retries");
PropertyValue loadbalance = mpv.getPropertyValue("loadbalance");
PropertyValue cluster = mpv.getPropertyValue("cluster");
PropertyValue filter = mpv.getPropertyValue("filter");
PropertyValue group = mpv.getPropertyValue("group");
if (retries == null || retries.getValue() == null || "0".equals(retries.getValue()) == false) {
throw new FatalBeanException(
String.format("The value of attr 'retries'(beanId= %s) should be '0'.", this.beanName));
} else if (loadbalance == null || loadbalance.getValue() == null
|| "compensable".equals(loadbalance.getValue()) == false) {
throw new FatalBeanException(
String.format("The value of attr 'loadbalance'(beanId= %s) should be 'compensable'.", this.beanName));
} else if (cluster == null || cluster.getValue() == null || "failfast".equals(cluster.getValue()) == false) {
throw new FatalBeanException(
String.format("The value of attribute 'cluster' (beanId= %s) must be 'failfast'.", this.beanName));
} else if (filter == null || filter.getValue() == null || "compensable".equals(filter.getValue()) == false) {
throw new FatalBeanException(
String.format("The value of attr 'filter'(beanId= %s) should be 'compensable'.", this.beanName));
} else if (group == null || group.getValue() == null //
|| ("org-bytesoft-bytetcc".equals(group.getValue())
|| String.valueOf(group.getValue()).startsWith("org-bytesoft-bytetcc-")) == false) {
throw new FatalBeanException(String.format(
"The value of attr 'group'(beanId= %s) should be 'org.bytesoft.bytetcc' or starts with 'org.bytesoft.bytetcc-'.",
this.beanName));
}
}
示例7: validate
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的package包/类
public void validate() throws BeansException {
MutablePropertyValues mpv = this.beanDefinition.getPropertyValues();
PropertyValue pv = mpv.getPropertyValue("port");
Object value = pv == null ? null : pv.getValue();
if (pv == null || value == null) {
throw new FatalBeanException(
"The value of the attribute 'port' (<dubbo:protocol port='...' />) must be explicitly specified.");
} else if ("-1".equals(value)) {
throw new FatalBeanException(
"The value of the attribute 'port' (<dubbo:protocol port='...' />) must be explicitly specified and not equal to -1.");
}
}
示例8: processLocations
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的package包/类
/**
* Given a bean name (assumed to implement {@link org.springframework.core.io.support.PropertiesLoaderSupport})
* checks whether it already references the <code>global-properties</code> bean. If not, 'upgrades' the bean by
* appending all additional resources it mentions in its <code>locations</code> property to
* <code>globalPropertyLocations</code>, except for those resources mentioned in <code>newLocations</code>. A
* reference to <code>global-properties</code> will then be added and the resource list in
* <code>newLocations<code> will then become the new <code>locations</code> list for the bean.
*
* @param beanFactory
* the bean factory
* @param globalPropertyLocations
* the list of global property locations to be appended to
* @param beanName
* the bean name
* @param newLocations
* the new locations to be set on the bean
* @return the mutable property values
*/
@SuppressWarnings("unchecked")
private MutablePropertyValues processLocations(ConfigurableListableBeanFactory beanFactory,
Collection<Object> globalPropertyLocations, String beanName, String[] newLocations)
{
// Get the bean an check its existing properties value
MutablePropertyValues beanProperties = beanFactory.getBeanDefinition(beanName).getPropertyValues();
PropertyValue pv = beanProperties.getPropertyValue(LegacyConfigPostProcessor.PROPERTY_PROPERTIES);
Object value;
// If the properties value already references the global-properties bean, we have nothing else to do. Otherwise,
// we have to 'upgrade' the bean definition.
if (pv == null || (value = pv.getValue()) == null || !(value instanceof BeanReference)
|| ((BeanReference) value).getBeanName().equals(LegacyConfigPostProcessor.BEAN_NAME_GLOBAL_PROPERTIES))
{
// Convert the array of new locations to a managed list of type string values, so that it is
// compatible with a bean definition
Collection<Object> newLocationList = new ManagedList(newLocations.length);
if (newLocations != null && newLocations.length > 0)
{
for (String preserveLocation : newLocations)
{
newLocationList.add(new TypedStringValue(preserveLocation));
}
}
// If there is currently a locations list, process it
pv = beanProperties.getPropertyValue(LegacyConfigPostProcessor.PROPERTY_LOCATIONS);
if (pv != null && (value = pv.getValue()) != null && value instanceof Collection)
{
Collection<Object> locations = (Collection<Object>) value;
// Compute the set of locations that need to be added to globalPropertyLocations (preserving order) and
// warn about each
Set<Object> addedLocations = new LinkedHashSet<Object>(locations);
addedLocations.removeAll(globalPropertyLocations);
addedLocations.removeAll(newLocationList);
for (Object location : addedLocations)
{
LegacyConfigPostProcessor.logger.warn("Legacy configuration detected: adding "
+ (location instanceof TypedStringValue ? ((TypedStringValue) location).getValue()
: location.toString()) + " to global-properties definition");
globalPropertyLocations.add(location);
}
}
// Ensure the bean now references global-properties
beanProperties.addPropertyValue(LegacyConfigPostProcessor.PROPERTY_PROPERTIES, new RuntimeBeanReference(
LegacyConfigPostProcessor.BEAN_NAME_GLOBAL_PROPERTIES));
// Ensure the new location list is now set on the bean
if (newLocationList.size() > 0)
{
beanProperties.addPropertyValue(LegacyConfigPostProcessor.PROPERTY_LOCATIONS, newLocationList);
}
else
{
beanProperties.removePropertyValue(LegacyConfigPostProcessor.PROPERTY_LOCATIONS);
}
}
return beanProperties;
}
示例9: validate
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的package包/类
public void validate() throws BeansException {
MutablePropertyValues mpv = this.beanDefinition.getPropertyValues();
PropertyValue group = mpv.getPropertyValue("group");
PropertyValue retries = mpv.getPropertyValue("retries");
PropertyValue loadbalance = mpv.getPropertyValue("loadbalance");
PropertyValue cluster = mpv.getPropertyValue("cluster");
PropertyValue filter = mpv.getPropertyValue("filter");
if (group == null || group.getValue() == null //
|| ("org-bytesoft-bytetcc".equals(group.getValue())
|| String.valueOf(group.getValue()).startsWith("org-bytesoft-bytetcc-")) == false) {
throw new FatalBeanException(String.format(
"The value of attr 'group'(beanId= %s) should be 'org-bytesoft-bytetcc' or starts with 'org-bytesoft-bytetcc-'.",
this.beanName));
} else if (retries == null || retries.getValue() == null || "0".equals(retries.getValue()) == false) {
throw new FatalBeanException(
String.format("The value of attr 'retries'(beanId= %s) should be '0'.", this.beanName));
} else if (loadbalance == null || loadbalance.getValue() == null
|| "compensable".equals(loadbalance.getValue()) == false) {
throw new FatalBeanException(
String.format("The value of attr 'loadbalance'(beanId= %s) should be 'compensable'.", this.beanName));
} else if (cluster == null || cluster.getValue() == null || "failfast".equals(cluster.getValue()) == false) {
throw new FatalBeanException(
String.format("The value of attribute 'cluster' (beanId= %s) must be 'failfast'.", this.beanName));
} else if (filter == null || filter.getValue() == null || "compensable".equals(filter.getValue()) == false) {
throw new FatalBeanException(
String.format("The value of attr 'filter'(beanId= %s) should be 'compensable'.", this.beanName));
}
PropertyValue pv = mpv.getPropertyValue("interface");
String clazzName = String.valueOf(pv.getValue());
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class<?> clazz = null;
try {
clazz = cl.loadClass(clazzName);
} catch (Exception ex) {
throw new FatalBeanException(String.format("Cannot load class %s.", clazzName));
}
Method[] methodArray = clazz.getMethods();
for (int i = 0; i < methodArray.length; i++) {
Method method = methodArray[i];
boolean declared = false;
Class<?>[] exceptionTypeArray = method.getExceptionTypes();
for (int j = 0; j < exceptionTypeArray.length; j++) {
Class<?> exceptionType = exceptionTypeArray[j];
if (RemotingException.class.isAssignableFrom(exceptionType)) {
declared = true;
break;
}
}
if (declared == false) {
// throw new FatalBeanException(String.format(
// "The remote call method(%s) must be declared to throw a remote exception:
// org.bytesoft.compensable.RemotingException!",
// method));
logger.warn("The remote call method({}) should be declared to throw a remote exception: {}!", method,
RemotingException.class.getName());
}
}
}