org.springframework.beans.ConfigurablePropertyAccessor Java Examples
The following examples show how to use
org.springframework.beans.ConfigurablePropertyAccessor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentCheckConstraintValidator.java From onetwo with Apache License 2.0 | 6 votes |
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (StringUtils.isBlank(value)) { return true; } List<String> sentitiveWords = getContentChecker().check(value); if (LangUtils.isEmpty(sentitiveWords)) { return true; } ConstraintValidatorContextImpl ctx = (ConstraintValidatorContextImpl)context; // 这种方法虽然可以动态显示错误信息,但是无法把错误信息放到i18n国际化资源文件里 // ctx.addExpressionVariable("invalidWords", StringUtils.join(sentitiveWords, ", ")); // ctx.buildConstraintViolationWithTemplate("${invalidWords}").addConstraintViolation(); Map<String, Object> newAttributes = Maps.newHashMap(ctx.getConstraintDescriptor().getAttributes()); newAttributes.put("invalidWords", StringUtils.join(sentitiveWords, ", ")); ConfigurablePropertyAccessor constraintDescriptor = SpringUtils.newPropertyAccessor(ctx.getConstraintDescriptor(), true); constraintDescriptor.setPropertyValue("attributes", newAttributes); return false; }
Example #2
Source File: DirectFieldBindingResult.java From spring-analysis-note with MIT License | 5 votes |
/** * Returns the DirectFieldAccessor that this instance uses. * Creates a new one if none existed before. * @see #createDirectFieldAccessor() */ @Override public final ConfigurablePropertyAccessor getPropertyAccessor() { if (this.directFieldAccessor == null) { this.directFieldAccessor = createDirectFieldAccessor(); this.directFieldAccessor.setExtractOldValueForEditor(true); this.directFieldAccessor.setAutoGrowNestedPaths(this.autoGrowNestedPaths); } return this.directFieldAccessor; }
Example #3
Source File: AuthorizationServerConfiguration.java From onetwo with Apache License 2.0 | 5 votes |
@Override public <O extends ClientCredentialsTokenEndpointFilter> O postProcess(O filter) { ConfigurablePropertyAccessor filterAccessor = SpringUtils.newPropertyAccessor(filter, true); if(oauth2ExceptionRenderer!=null){ filterAccessor.setPropertyValue("authenticationEntryPoint.exceptionRenderer", oauth2ExceptionRenderer); } /*AuthenticationManager origin = (AuthenticationManager)filterAccessor.getPropertyValue("authenticationManager"); DelegateAuthenticationManager delegate = new DelegateAuthenticationManager(origin); filter.setAuthenticationManager(delegate);*/ if(tokenEndpointFilterInterceptor!=null){ filter = Proxys.intercept(filter, tokenEndpointFilterInterceptor); } return filter; }
Example #4
Source File: PropsTargeterEnhancer.java From onetwo with Apache License 2.0 | 5 votes |
@Override public <T> T enhanceTargeter(FeignTargetContext<T> ctx) { FeignClientFactoryBean factory = ctx.getFeignClientfactory(); String serviceName = factory.getName(); if (feignProperties.getServices().containsKey(serviceName)) { ServiceProps serviceProp = feignProperties.getServices().get(serviceName); // factory.setUrl(serviceProp.getUrl()); // 这里设置太迟了 ConfigurablePropertyAccessor bw = SpringUtils.newPropertyAccessor(ctx.getHardeCodetarget(), true); // bw.setPropertyValue("url", serviceProp.getUrl()); } return ctx.createTargeter(); }
Example #5
Source File: ConfigableBeanMapper.java From onetwo with Apache License 2.0 | 5 votes |
protected void setPropertyValue(Object obj, ConfigurablePropertyAccessor bw, String propertyName, Object value){ if(!bw.isWritableProperty(propertyName)){ if(!ignoreNotFoundProperty){ throw new NoSuchElementException("no setter found for property: " + propertyName+", target: " + obj); } logger.debug("ignore property: {}={} ", propertyName, value); return ; } bw.setPropertyValue(propertyName, value); if(logger.isDebugEnabled()){ logger.debug("set property: {}={} ", propertyName, value); } }
Example #6
Source File: ConfigableBeanMapper.java From onetwo with Apache License 2.0 | 5 votes |
public void mapToObject(Object obj) { if(config==null || config.isEmpty()){ return ; } boolean hasPrefix = StringUtils.isNotBlank(prefix); ConfigurablePropertyAccessor bw = beanAccessors.createAccessor(obj); // Enumeration<?> names = config.propertyNames(); // while(names.hasMoreElements()){ for(Entry<String, Object> entry : config.entrySet()){ // String propertyName = names.nextElement().toString(); // String value = config.getProperty(propertyName); if(entry.getValue()==null){ continue; } String propertyName = entry.getKey(); String text = entry.getValue().toString(); if(StringUtils.isBlank(text) && ignoreBlankString){ continue; } if(hasPrefix){ if(propertyName.startsWith(prefix)){ propertyName = propertyName.substring(prefix.length()); setPropertyValue(obj, bw, propertyName, text); } }else{ setPropertyValue(obj, bw, propertyName, text); } } }
Example #7
Source File: BeanPropertiesMapper.java From onetwo with Apache License 2.0 | 5 votes |
protected void setPropertyValue(Object obj, ConfigurablePropertyAccessor bw, String propertyName, Object value){ if(!bw.isWritableProperty(propertyName)){ if(!ignoreNotFoundProperty){ throw new NoSuchElementException("no setter found for property: " + propertyName+", target: " + obj); } logger.debug("ignore property: {}={} ", propertyName, value); return ; } bw.setPropertyValue(propertyName, value); if(logger.isDebugEnabled()){ logger.debug("set property: {}={} ", propertyName, value); } }
Example #8
Source File: BeanPropertiesMapper.java From onetwo with Apache License 2.0 | 5 votes |
public void mapToObject(Object obj) { if(config==null || config.isEmpty()){ return ; } boolean hasPrefix = StringUtils.isNotBlank(prefix); ConfigurablePropertyAccessor bw = beanAccessors.createAccessor(obj); Enumeration<?> names = config.propertyNames(); while(names.hasMoreElements()){ String propertyName = names.nextElement().toString(); String value = config.getProperty(propertyName); if(value==null){ continue; } if(StringUtils.isBlank(value) && ignoreBlankString){ continue; } if(hasPrefix){ if(propertyName.startsWith(prefix)){ propertyName = propertyName.substring(prefix.length()); setPropertyValue(obj, bw, propertyName, value); } }else{ setPropertyValue(obj, bw, propertyName, value); } } }
Example #9
Source File: BeanPropertyBindingResult.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Returns the {@link BeanWrapper} that this instance uses. * Creates a new one if none existed before. * @see #createBeanWrapper() */ @Override public final ConfigurablePropertyAccessor getPropertyAccessor() { if (this.beanWrapper == null) { this.beanWrapper = createBeanWrapper(); this.beanWrapper.setExtractOldValueForEditor(true); this.beanWrapper.setAutoGrowNestedPaths(this.autoGrowNestedPaths); this.beanWrapper.setAutoGrowCollectionLimit(this.autoGrowCollectionLimit); } return this.beanWrapper; }
Example #10
Source File: DirectFieldBindingResult.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Returns the DirectFieldAccessor that this instance uses. * Creates a new one if none existed before. * @see #createDirectFieldAccessor() */ @Override public final ConfigurablePropertyAccessor getPropertyAccessor() { if (this.directFieldAccessor == null) { this.directFieldAccessor = createDirectFieldAccessor(); this.directFieldAccessor.setExtractOldValueForEditor(true); this.directFieldAccessor.setAutoGrowNestedPaths(this.autoGrowNestedPaths); } return this.directFieldAccessor; }
Example #11
Source File: BeanPropertyBindingResult.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Returns the {@link BeanWrapper} that this instance uses. * Creates a new one if none existed before. * @see #createBeanWrapper() */ @Override public final ConfigurablePropertyAccessor getPropertyAccessor() { if (this.beanWrapper == null) { this.beanWrapper = createBeanWrapper(); this.beanWrapper.setExtractOldValueForEditor(true); this.beanWrapper.setAutoGrowNestedPaths(this.autoGrowNestedPaths); this.beanWrapper.setAutoGrowCollectionLimit(this.autoGrowCollectionLimit); } return this.beanWrapper; }
Example #12
Source File: DirectFieldBindingResult.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Returns the DirectFieldAccessor that this instance uses. * Creates a new one if none existed before. * @see #createDirectFieldAccessor() */ @Override public final ConfigurablePropertyAccessor getPropertyAccessor() { if (this.directFieldAccessor == null) { this.directFieldAccessor = createDirectFieldAccessor(); this.directFieldAccessor.setExtractOldValueForEditor(true); this.directFieldAccessor.setAutoGrowNestedPaths(this.autoGrowNestedPaths); } return this.directFieldAccessor; }
Example #13
Source File: DirectFieldBindingResult.java From spring-analysis-note with MIT License | 5 votes |
/** * Create a new DirectFieldAccessor for the underlying target object. * @see #getTarget() */ protected ConfigurablePropertyAccessor createDirectFieldAccessor() { if (this.target == null) { throw new IllegalStateException("Cannot access fields on null target instance '" + getObjectName() + "'"); } return PropertyAccessorFactory.forDirectFieldAccess(this.target); }
Example #14
Source File: BeanPropertyBindingResult.java From java-technology-stack with MIT License | 5 votes |
/** * Returns the {@link BeanWrapper} that this instance uses. * Creates a new one if none existed before. * @see #createBeanWrapper() */ @Override public final ConfigurablePropertyAccessor getPropertyAccessor() { if (this.beanWrapper == null) { this.beanWrapper = createBeanWrapper(); this.beanWrapper.setExtractOldValueForEditor(true); this.beanWrapper.setAutoGrowNestedPaths(this.autoGrowNestedPaths); this.beanWrapper.setAutoGrowCollectionLimit(this.autoGrowCollectionLimit); } return this.beanWrapper; }
Example #15
Source File: BeanPropertyBindingResult.java From spring-analysis-note with MIT License | 5 votes |
/** * Returns the {@link BeanWrapper} that this instance uses. * Creates a new one if none existed before. * @see #createBeanWrapper() */ @Override public final ConfigurablePropertyAccessor getPropertyAccessor() { if (this.beanWrapper == null) { this.beanWrapper = createBeanWrapper(); this.beanWrapper.setExtractOldValueForEditor(true); this.beanWrapper.setAutoGrowNestedPaths(this.autoGrowNestedPaths); this.beanWrapper.setAutoGrowCollectionLimit(this.autoGrowCollectionLimit); } return this.beanWrapper; }
Example #16
Source File: DirectFieldBindingResult.java From java-technology-stack with MIT License | 5 votes |
/** * Create a new DirectFieldAccessor for the underlying target object. * @see #getTarget() */ protected ConfigurablePropertyAccessor createDirectFieldAccessor() { if (this.target == null) { throw new IllegalStateException("Cannot access fields on null target instance '" + getObjectName() + "'"); } return PropertyAccessorFactory.forDirectFieldAccess(this.target); }
Example #17
Source File: DirectFieldBindingResult.java From java-technology-stack with MIT License | 5 votes |
/** * Returns the DirectFieldAccessor that this instance uses. * Creates a new one if none existed before. * @see #createDirectFieldAccessor() */ @Override public final ConfigurablePropertyAccessor getPropertyAccessor() { if (this.directFieldAccessor == null) { this.directFieldAccessor = createDirectFieldAccessor(); this.directFieldAccessor.setExtractOldValueForEditor(true); this.directFieldAccessor.setAutoGrowNestedPaths(this.autoGrowNestedPaths); } return this.directFieldAccessor; }
Example #18
Source File: GrailsDataBinder.java From AlgoTrader with GNU General Public License v2.0 | 4 votes |
private boolean isNullAndWritableProperty(ConfigurablePropertyAccessor accessor, String propertyName) { return accessor.isWritableProperty(propertyName) && (accessor.isReadableProperty(propertyName) && accessor.getPropertyValue(propertyName) == null); }
Example #19
Source File: SpringUtils.java From onetwo with Apache License 2.0 | 4 votes |
public static ConfigurablePropertyAccessor newPropertyAccessor(Object obj, boolean directFieldAccess){ ConfigurablePropertyAccessor bw = directFieldAccess?PropertyAccessorFactory.forDirectFieldAccess(obj):PropertyAccessorFactory.forBeanPropertyAccess(obj); bw.setAutoGrowNestedPaths(true); return bw; }
Example #20
Source File: DataBinder.java From spring-analysis-note with MIT License | 4 votes |
/** * Return the underlying PropertyAccessor of this binder's BindingResult. */ protected ConfigurablePropertyAccessor getPropertyAccessor() { return getInternalBindingResult().getPropertyAccessor(); }
Example #21
Source File: ConfigableBeanMapper.java From onetwo with Apache License 2.0 | 4 votes |
@Override public ConfigurablePropertyAccessor createAccessor(Object obj) { ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(obj); accessor.setAutoGrowNestedPaths(true); return accessor; }
Example #22
Source File: ConfigableBeanMapper.java From onetwo with Apache License 2.0 | 4 votes |
@Override public ConfigurablePropertyAccessor createAccessor(Object obj) { ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forBeanPropertyAccess(obj); accessor.setAutoGrowNestedPaths(true); return accessor; }
Example #23
Source File: DataBinder.java From java-technology-stack with MIT License | 4 votes |
/** * Return the underlying PropertyAccessor of this binder's BindingResult. */ protected ConfigurablePropertyAccessor getPropertyAccessor() { return getInternalBindingResult().getPropertyAccessor(); }
Example #24
Source File: DataBinder.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Return the underlying PropertyAccessor of this binder's BindingResult. */ protected ConfigurablePropertyAccessor getPropertyAccessor() { return getInternalBindingResult().getPropertyAccessor(); }
Example #25
Source File: DirectFieldBindingResult.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Create a new DirectFieldAccessor for the underlying target object. * @see #getTarget() */ protected ConfigurablePropertyAccessor createDirectFieldAccessor() { Assert.state(this.target != null, "Cannot access fields on null target instance '" + getObjectName() + "'!"); return PropertyAccessorFactory.forDirectFieldAccess(this.target); }
Example #26
Source File: DataBinder.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Return the underlying PropertyAccessor of this binder's BindingResult. */ protected ConfigurablePropertyAccessor getPropertyAccessor() { return getInternalBindingResult().getPropertyAccessor(); }
Example #27
Source File: DirectFieldBindingResult.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Create a new DirectFieldAccessor for the underlying target object. * @see #getTarget() */ protected ConfigurablePropertyAccessor createDirectFieldAccessor() { Assert.state(this.target != null, "Cannot access fields on null target instance '" + getObjectName() + "'!"); return PropertyAccessorFactory.forDirectFieldAccess(this.target); }
Example #28
Source File: AbstractPropertyBindingResult.java From java-technology-stack with MIT License | 2 votes |
/** * Provide the PropertyAccessor to work with, according to the * concrete strategy of access. * <p>Note that a PropertyAccessor used by a BindingResult should * always have its "extractOldValueForEditor" flag set to "true" * by default, since this is typically possible without side effects * for model objects that serve as data binding target. * @see ConfigurablePropertyAccessor#setExtractOldValueForEditor */ public abstract ConfigurablePropertyAccessor getPropertyAccessor();
Example #29
Source File: AbstractPropertyBindingResult.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Provide the PropertyAccessor to work with, according to the * concrete strategy of access. * <p>Note that a PropertyAccessor used by a BindingResult should * always have its "extractOldValueForEditor" flag set to "true" * by default, since this is typically possible without side effects * for model objects that serve as data binding target. * @see ConfigurablePropertyAccessor#setExtractOldValueForEditor */ public abstract ConfigurablePropertyAccessor getPropertyAccessor();
Example #30
Source File: AbstractPropertyBindingResult.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Provide the PropertyAccessor to work with, according to the * concrete strategy of access. * <p>Note that a PropertyAccessor used by a BindingResult should * always have its "extractOldValueForEditor" flag set to "true" * by default, since this is typically possible without side effects * for model objects that serve as data binding target. * @see ConfigurablePropertyAccessor#setExtractOldValueForEditor */ public abstract ConfigurablePropertyAccessor getPropertyAccessor();