public class PropertiesConfigurationFactory<T> extends Object implements FactoryBean<T>, MessageSourceAware, InitializingBean
Properties
(or optionally PropertySources
) by binding
them to an object of a specified type and then optionally running a Validator
over it.Constructor and Description |
---|
PropertiesConfigurationFactory(Class<?> type)
Create a new factory for an object of the given type.
|
PropertiesConfigurationFactory(T target) |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
bindPropertiesToTarget() |
protected void |
customizeBinder(DataBinder dataBinder) |
T |
getObject() |
Class<?> |
getObjectType() |
boolean |
isSingleton() |
void |
setConversionService(ConversionService conversionService) |
void |
setExceptionIfInvalid(boolean exceptionIfInvalid)
Flag to indicate that an exception should be raised if a Validator is available and
validation fails.
|
void |
setIgnoreInvalidFields(boolean ignoreInvalidFields)
Set whether to ignore invalid fields, that is, whether to ignore bind parameters
that have corresponding fields in the target object which are not accessible (for
example because of null values in the nested path).
|
void |
setIgnoreNestedProperties(boolean ignoreNestedProperties)
Flag to disable binding of nested properties (i.e.
|
void |
setIgnoreUnknownFields(boolean ignoreUnknownFields)
Set whether to ignore unknown fields, that is, whether to ignore bind parameters
that do not have corresponding fields in the target object.
|
void |
setMessageSource(MessageSource messageSource) |
void |
setProperties(Properties properties) |
void |
setPropertySources(PropertySources propertySources) |
void |
setTargetName(String targetName) |
void |
setValidator(Validator validator) |
public PropertiesConfigurationFactory(T target)
target
- the target object to bind tooPropertiesConfigurationFactory(Class)
public PropertiesConfigurationFactory(Class<?> type)
public void setIgnoreNestedProperties(boolean ignoreNestedProperties)
ignoreNestedProperties
- the flag to set (default false)public void setIgnoreUnknownFields(boolean ignoreUnknownFields)
Default is "true". Turn this off to enforce that all bind parameters must have a matching field in the target object.
ignoreUnknownFields
- if unknown fields should be ignoredpublic void setIgnoreInvalidFields(boolean ignoreInvalidFields)
Default is "false". Turn this on to ignore bind parameters for nested objects in non-existing parts of the target object graph.
ignoreInvalidFields
- if invalid fields should be ignoredpublic void setTargetName(String targetName)
targetName
- the target name to setpublic void setMessageSource(MessageSource messageSource)
setMessageSource
in interface MessageSourceAware
messageSource
- the messageSource to setpublic void setProperties(Properties properties)
properties
- the properties to setpublic void setPropertySources(PropertySources propertySources)
propertySources
- the propertySources to setpublic void setConversionService(ConversionService conversionService)
conversionService
- the conversionService to setpublic void setValidator(Validator validator)
validator
- the validator to setpublic void setExceptionIfInvalid(boolean exceptionIfInvalid)
exceptionIfInvalid
- the flag to setpublic void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
public Class<?> getObjectType()
getObjectType
in interface FactoryBean<T>
public boolean isSingleton()
isSingleton
in interface FactoryBean<T>
public T getObject() throws Exception
getObject
in interface FactoryBean<T>
Exception
public void bindPropertiesToTarget() throws BindException
BindException
protected void customizeBinder(DataBinder dataBinder)
dataBinder
- the data binder that will be used to bind and validateCopyright © 2015 Pivotal Software, Inc.. All rights reserved.