本文整理汇总了Java中org.springframework.beans.MutablePropertyValues类的典型用法代码示例。如果您正苦于以下问题:Java MutablePropertyValues类的具体用法?Java MutablePropertyValues怎么用?Java MutablePropertyValues使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MutablePropertyValues类属于org.springframework.beans包,在下文中一共展示了MutablePropertyValues类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initJob
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
protected void initJob(TriggerFiredBundle bundle, Object job) {
// The following code is copied from SpringBeanJobFactory in spring-context-support-4.2.5.RELEASE
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job);
if (isEligibleForPropertyPopulation(bw.getWrappedInstance())) {
MutablePropertyValues pvs = new MutablePropertyValues();
if (schedulerContext != null) {
pvs.addPropertyValues(this.schedulerContext);
}
pvs.addPropertyValues(bundle.getJobDetail().getJobDataMap());
pvs.addPropertyValues(bundle.getTrigger().getJobDataMap());
if (this.ignoredUnknownProperties != null) {
for (String propName : this.ignoredUnknownProperties) {
if (pvs.contains(propName) && !bw.isWritableProperty(propName)) {
pvs.removePropertyValue(propName);
}
}
bw.setPropertyValues(pvs);
}
else {
bw.setPropertyValues(pvs, true);
}
}
}
示例2: execute
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
/**
* This implementation applies the passed-in job data map as bean property
* values, and delegates to {@code executeInternal} afterwards.
* @see #executeInternal
*/
@Override
public final void execute(JobExecutionContext context) throws JobExecutionException {
try {
// Reflectively adapting to differences between Quartz 1.x and Quartz 2.0...
Scheduler scheduler = (Scheduler) ReflectionUtils.invokeMethod(getSchedulerMethod, context);
Map<?, ?> mergedJobDataMap = (Map<?, ?>) ReflectionUtils.invokeMethod(getMergedJobDataMapMethod, context);
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.addPropertyValues(scheduler.getContext());
pvs.addPropertyValues(mergedJobDataMap);
bw.setPropertyValues(pvs, true);
}
catch (SchedulerException ex) {
throw new JobExecutionException(ex);
}
executeInternal(context);
}
示例3: createJobInstance
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
/**
* Create the job instance, populating it with property values taken
* from the scheduler context, job data map and trigger data map.
*/
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Object job = super.createJobInstance(bundle);
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(job);
if (isEligibleForPropertyPopulation(bw.getWrappedInstance())) {
MutablePropertyValues pvs = new MutablePropertyValues();
if (this.schedulerContext != null) {
pvs.addPropertyValues(this.schedulerContext);
}
pvs.addPropertyValues(getJobDetailDataMap(bundle));
pvs.addPropertyValues(getTriggerDataMap(bundle));
if (this.ignoredUnknownProperties != null) {
for (String propName : this.ignoredUnknownProperties) {
if (pvs.contains(propName) && !bw.isWritableProperty(propName)) {
pvs.removePropertyValue(propName);
}
}
bw.setPropertyValues(pvs);
}
else {
bw.setPropertyValues(pvs, true);
}
}
return job;
}
示例4: checkFieldDefaults
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
/**
* Check the given property values for field defaults,
* i.e. for fields that start with the field default prefix.
* <p>The existence of a field defaults indicates that the specified
* value should be used if the field is otherwise not present.
* @param mpvs the property values to be bound (can be modified)
* @see #getFieldDefaultPrefix
*/
protected void checkFieldDefaults(MutablePropertyValues mpvs) {
if (getFieldDefaultPrefix() != null) {
String fieldDefaultPrefix = getFieldDefaultPrefix();
PropertyValue[] pvArray = mpvs.getPropertyValues();
for (PropertyValue pv : pvArray) {
if (pv.getName().startsWith(fieldDefaultPrefix)) {
String field = pv.getName().substring(fieldDefaultPrefix.length());
if (getPropertyAccessor().isWritableProperty(field) && !mpvs.contains(field)) {
mpvs.add(field, pv.getValue());
}
mpvs.removePropertyValue(pv);
}
}
}
}
示例5: checkFieldMarkers
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
/**
* Check the given property values for field markers,
* i.e. for fields that start with the field marker prefix.
* <p>The existence of a field marker indicates that the specified
* field existed in the form. If the property values do not contain
* a corresponding field value, the field will be considered as empty
* and will be reset appropriately.
* @param mpvs the property values to be bound (can be modified)
* @see #getFieldMarkerPrefix
* @see #getEmptyValue(String, Class)
*/
protected void checkFieldMarkers(MutablePropertyValues mpvs) {
if (getFieldMarkerPrefix() != null) {
String fieldMarkerPrefix = getFieldMarkerPrefix();
PropertyValue[] pvArray = mpvs.getPropertyValues();
for (PropertyValue pv : pvArray) {
if (pv.getName().startsWith(fieldMarkerPrefix)) {
String field = pv.getName().substring(fieldMarkerPrefix.length());
if (getPropertyAccessor().isWritableProperty(field) && !mpvs.contains(field)) {
Class<?> fieldType = getPropertyAccessor().getPropertyType(field);
mpvs.add(field, getEmptyValue(field, fieldType));
}
mpvs.removePropertyValue(pv);
}
}
}
}
示例6: bindMultipart
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
/**
* Bind all multipart files contained in the given request, if any
* (in case of a multipart request).
* <p>Multipart files will only be added to the property values if they
* are not empty or if we're configured to bind empty multipart files too.
* @param multipartFiles Map of field name String to MultipartFile object
* @param mpvs the property values to be bound (can be modified)
* @see org.springframework.web.multipart.MultipartFile
* @see #setBindEmptyMultipartFiles
*/
protected void bindMultipart(Map<String, List<MultipartFile>> multipartFiles, MutablePropertyValues mpvs) {
for (Map.Entry<String, List<MultipartFile>> entry : multipartFiles.entrySet()) {
String key = entry.getKey();
List<MultipartFile> values = entry.getValue();
if (values.size() == 1) {
MultipartFile value = values.get(0);
if (isBindEmptyMultipartFiles() || !value.isEmpty()) {
mpvs.add(key, value);
}
}
else {
mpvs.add(key, values);
}
}
}
示例7: autowireByName
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
/**
* Fill in any missing property values with references to
* other beans in this factory if autowire is set to "byName".
* @param beanName the name of the bean we're wiring up.
* Useful for debugging messages; not used functionally.
* @param mbd bean definition to update through autowiring
* @param bw BeanWrapper from which we can obtain information about the bean
* @param pvs the PropertyValues to register wired objects with
*/
protected void autowireByName(
String beanName, AbstractBeanDefinition mbd, BeanWrapper bw, MutablePropertyValues pvs) {
String[] propertyNames = unsatisfiedNonSimpleProperties(mbd, bw);
for (String propertyName : propertyNames) {
if (containsBean(propertyName)) {
Object bean = getBean(propertyName);
pvs.add(propertyName, bean);
registerDependentBean(propertyName, beanName);
if (logger.isDebugEnabled()) {
logger.debug("Added autowiring by name from bean name '" + beanName +
"' via property '" + propertyName + "' to bean named '" + propertyName + "'");
}
}
else {
if (logger.isTraceEnabled()) {
logger.trace("Not autowiring property '" + propertyName + "' of bean '" + beanName +
"' by name: no matching bean found");
}
}
}
}
示例8: decorate
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
if (node instanceof Attr) {
Attr attr = (Attr) node;
String propertyName = parserContext.getDelegate().getLocalName(attr);
String propertyValue = attr.getValue();
MutablePropertyValues pvs = definition.getBeanDefinition().getPropertyValues();
if (pvs.contains(propertyName)) {
parserContext.getReaderContext().error("Property '" + propertyName + "' is already defined using " +
"both <property> and inline syntax. Only one approach may be used per property.", attr);
}
if (propertyName.endsWith(REF_SUFFIX)) {
propertyName = propertyName.substring(0, propertyName.length() - REF_SUFFIX.length());
pvs.add(Conventions.attributeNameToPropertyName(propertyName), new RuntimeBeanReference(propertyValue));
}
else {
pvs.add(Conventions.attributeNameToPropertyName(propertyName), propertyValue);
}
}
return definition;
}
示例9: unwrapDefinitions
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
private void unwrapDefinitions(BeanDefinition advisorDefinition, BeanDefinition pointcutDefinition) {
MutablePropertyValues pvs = advisorDefinition.getPropertyValues();
BeanReference adviceReference = (BeanReference) pvs.getPropertyValue("adviceBeanName").getValue();
if (pointcutDefinition != null) {
this.beanReferences = new BeanReference[] {adviceReference};
this.beanDefinitions = new BeanDefinition[] {advisorDefinition, pointcutDefinition};
this.description = buildDescription(adviceReference, pointcutDefinition);
}
else {
BeanReference pointcutReference = (BeanReference) pvs.getPropertyValue("pointcut").getValue();
this.beanReferences = new BeanReference[] {adviceReference, pointcutReference};
this.beanDefinitions = new BeanDefinition[] {advisorDefinition};
this.description = buildDescription(adviceReference, pointcutReference);
}
}
示例10: registerBeanDefinitions
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {
AnnotationAttributes enableMenu = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(EnableMenu.class
.getName(),
false));
if (enableMenu != null) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(DefaultMenuPlugin.class);
AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
MutablePropertyValues mutablePropertyValues = new MutablePropertyValues();
mutablePropertyValues.add("extensionPointId", enableMenu.getString("extensionPointId"));
mutablePropertyValues.add("pluginId", enableMenu.getString("pluginId"));
mutablePropertyValues.add("menu", toMenu(enableMenu.getAnnotationArray("menu")));
beanDefinition.setPropertyValues(mutablePropertyValues);
registry.registerBeanDefinition("menuPlugin:" + enableMenu.getString("pluginId"), beanDefinition);
}
}
示例11: 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);
}
示例12: autowireByName
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
/**
* Fill in any missing property values with references to
* other beans in this factory if autowire is set to "byName".
* @param beanName the name of the bean we're wiring up.
* Useful for debugging messages; not used functionally.
* @param mbd bean definition to update through autowiring
* @param bw BeanWrapper from which we can obtain information about the bean
* @param pvs the PropertyValues to register wired objects with
*/
protected void autowireByName(
String beanName, AbstractBeanDefinition mbd, BeanWrapper bw, MutablePropertyValues pvs) {
//��ȡ��ǰbean��������
String[] propertyNames = unsatisfiedNonSimpleProperties(mbd, bw);
for (String propertyName : propertyNames) {
if (containsBean(propertyName)) {
Object bean = getBean(propertyName);
pvs.add(propertyName, bean);
registerDependentBean(propertyName, beanName);
if (logger.isDebugEnabled()) {
logger.debug("Added autowiring by name from bean name '" + beanName +
"' via property '" + propertyName + "' to bean named '" + propertyName + "'");
}
}
else {
if (logger.isTraceEnabled()) {
logger.trace("Not autowiring property '" + propertyName + "' of bean '" + beanName +
"' by name: no matching bean found");
}
}
}
}
示例13: testServletContextParameterFactoryBeanWithAttributeNotFound
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
@Test
public void testServletContextParameterFactoryBeanWithAttributeNotFound() {
MockServletContext sc = new MockServletContext();
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.setServletContext(sc);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("initParamName", "myParam");
wac.registerSingleton("importedParam", ServletContextParameterFactoryBean.class, pvs);
try {
wac.refresh();
fail("Should have thrown BeanCreationException");
}
catch (BeanCreationException ex) {
// expected
assertTrue(ex.getCause() instanceof IllegalStateException);
assertTrue(ex.getCause().getMessage().contains("myParam"));
}
}
示例14: getPropertyValuesForNamePrefix
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
private MutablePropertyValues getPropertyValuesForNamePrefix(
MutablePropertyValues propertyValues) {
if (!StringUtils.hasText(this.namePrefix) && !this.ignoreNestedProperties) {
return propertyValues;
}
MutablePropertyValues rtn = new MutablePropertyValues();
for (PropertyValue value : propertyValues.getPropertyValues()) {
String name = value.getName();
for (String prefix : new RelaxedNames(stripLastDot(this.namePrefix))) {
for (String separator : new String[] { ".", "_" }) {
String candidate = (StringUtils.hasLength(prefix) ? prefix + separator
: prefix);
if (name.startsWith(candidate)) {
name = name.substring(candidate.length());
if (!(this.ignoreNestedProperties && name.contains("."))) {
PropertyOrigin propertyOrigin = OriginCapablePropertyValue
.getOrigin(value);
rtn.addPropertyValue(new OriginCapablePropertyValue(name,
value.getValue(), propertyOrigin));
}
}
}
}
}
return rtn;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:27,代码来源:RelaxedDataBinder.java
示例15: testBindingErrorWithFormatter
import org.springframework.beans.MutablePropertyValues; //导入依赖的package包/类
@Test
public void testBindingErrorWithFormatter() {
TestBean tb = new TestBean();
DataBinder binder = new DataBinder(tb);
FormattingConversionService conversionService = new FormattingConversionService();
DefaultConversionService.addDefaultConverters(conversionService);
conversionService.addFormatterForFieldType(Float.class, new NumberStyleFormatter());
binder.setConversionService(conversionService);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("myFloat", "1x2");
LocaleContextHolder.setLocale(Locale.GERMAN);
try {
binder.bind(pvs);
assertEquals(new Float(0.0), tb.getMyFloat());
assertEquals("1x2", binder.getBindingResult().getFieldValue("myFloat"));
assertTrue(binder.getBindingResult().hasFieldErrors("myFloat"));
}
finally {
LocaleContextHolder.resetLocaleContext();
}
}