ConfigurablePropertyResolver
来源:互联网 发布:仿淘宝手机网站模板 编辑:程序博客网 时间:2024/06/18 11:31
此接口是大多数PropertyResolver实现类的父接口,它规范了使用property的方法,并且使用户可以定制化PropertyResolver在解析和转换property时候的逻辑
public interface ConfigurablePropertyResolver extends PropertyResolver { /** * 返回在解析属性时使用的ConfigurableConversionService。此方法的返回值可被用户定制化, * 例如可以移除或者添加Converter * ConfigurableConversionService cs = env.getConversionService(); * cs.addConverter(new FooConverter()); */ ConfigurableConversionService getConversionService(); /** * 设置在涉及到属性转换操作时所使用到的ConfigurableConversionService。 * 全部替换ConfigurableConversionService的操作不常用,更常用的一种方法是使用getConversionService * * <p><strong>Note:</strong> as an alternative to fully replacing the * {@code ConversionService}, consider adding or removing individual * {@code Converter} instances by drilling into {@link #getConversionService()} * and calling methods such as {@code #addConverter}. * @see PropertyResolver#getProperty(String, Class) * @see #getConversionService() * @see org.springframework.core.convert.converter.ConverterRegistry#addConverter */ void setConversionService(ConfigurableConversionService conversionService); /** * Set the prefix that placeholders replaced by this resolver must begin with. */ void setPlaceholderPrefix(String placeholderPrefix); /** * Set the suffix that placeholders replaced by this resolver must end with. */ void setPlaceholderSuffix(String placeholderSuffix); /** * Specify the separating character between the placeholders replaced by this * resolver and their associated default value, or {@code null} if no such * special character should be processed as a value separator. */ void setValueSeparator(String valueSeparator); /** * Set whether to throw an exception when encountering an unresolvable placeholder * nested within the value of a given property. A {@code false} value indicates strict * resolution, i.e. that an exception will be thrown. A {@code true} value indicates * that unresolvable nested placeholders should be passed through in their unresolved * ${...} form. * <p>Implementations of {@link #getProperty(String)} and its variants must inspect * the value set here to determine correct behavior when property values contain * unresolvable placeholders. * @since 3.2 */ void setIgnoreUnresolvableNestedPlaceholders(boolean ignoreUnresolvableNestedPlaceholders); /** * Specify which properties must be present, to be verified by * {@link #validateRequiredProperties()}. */ void setRequiredProperties(String... requiredProperties); /** * Validate that each of the properties specified by * {@link #setRequiredProperties} is present and resolves to a * non-{@code null} value. * @throws MissingRequiredPropertiesException if any of the required * properties are not resolvable. */ void validateRequiredProperties() throws MissingRequiredPropertiesException;}