本文整理汇总了Java中org.springframework.beans.MutablePropertyValues.removePropertyValue方法的典型用法代码示例。如果您正苦于以下问题:Java MutablePropertyValues.removePropertyValue方法的具体用法?Java MutablePropertyValues.removePropertyValue怎么用?Java MutablePropertyValues.removePropertyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.beans.MutablePropertyValues
的用法示例。
在下文中一共展示了MutablePropertyValues.removePropertyValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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(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);
}
}
return job;
}
示例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: checkAllowedFields
import org.springframework.beans.MutablePropertyValues; //导入方法依赖的package包/类
/**
* Check the given property values against the allowed fields,
* removing values for fields that are not allowed.
* @param mpvs the property values to be bound (can be modified)
* @see #getAllowedFields
* @see #isAllowed(String)
*/
protected void checkAllowedFields(MutablePropertyValues mpvs) {
PropertyValue[] pvs = mpvs.getPropertyValues();
for (PropertyValue pv : pvs) {
String field = PropertyAccessorUtils.canonicalPropertyName(pv.getName());
if (!isAllowed(field)) {
mpvs.removePropertyValue(pv);
getBindingResult().recordSuppressedField(field);
if (logger.isDebugEnabled()) {
logger.debug("Field [" + field + "] has been removed from PropertyValues " +
"and will not be bound, because it has not been found in the list of allowed fields");
}
}
}
}
示例7: 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;
}