T
- the target typepublic class PropertiesConfigurationFactory<T> extends Object implements org.springframework.beans.factory.FactoryBean<T>, org.springframework.context.ApplicationContextAware, org.springframework.context.MessageSourceAware, org.springframework.beans.factory.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
PropertiesConfigurationFactory instance. |
PropertiesConfigurationFactory(T target)
Create a new
PropertiesConfigurationFactory instance. |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
bindPropertiesToTarget() |
protected void |
customizeBinder(org.springframework.validation.DataBinder dataBinder)
Customize the data binder.
|
T |
getObject() |
Class<?> |
getObjectType() |
boolean |
isSingleton() |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setConversionService(org.springframework.core.convert.ConversionService conversionService)
Set the conversion service.
|
void |
setExceptionIfInvalid(boolean exceptionIfInvalid)
Deprecated.
as of 1.5, do not specify a
Validator if validation should not
occur |
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(org.springframework.context.MessageSource messageSource)
Set the message source.
|
void |
setPropertySources(org.springframework.core.env.PropertySources propertySources)
Set the property sources.
|
void |
setResolvePlaceholders(boolean resolvePlaceholders)
Flag to indicate that placeholders should be replaced during binding.
|
void |
setTargetName(String targetName)
Set the target name.
|
void |
setValidator(org.springframework.validation.Validator validator)
Set the validator.
|
public PropertiesConfigurationFactory(T target)
PropertiesConfigurationFactory
instance.target
- the target object to bind tooPropertiesConfigurationFactory(Class)
public PropertiesConfigurationFactory(Class<?> type)
PropertiesConfigurationFactory
instance.type
- the target typePropertiesConfigurationFactory(Class)
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 namepublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
public void setMessageSource(org.springframework.context.MessageSource messageSource)
setMessageSource
in interface org.springframework.context.MessageSourceAware
messageSource
- the message sourcepublic void setPropertySources(org.springframework.core.env.PropertySources propertySources)
propertySources
- the property sourcespublic void setConversionService(org.springframework.core.convert.ConversionService conversionService)
conversionService
- the conversion servicepublic void setValidator(org.springframework.validation.Validator validator)
validator
- the validator@Deprecated public void setExceptionIfInvalid(boolean exceptionIfInvalid)
Validator
if validation should not
occurexceptionIfInvalid
- the flag to setpublic void setResolvePlaceholders(boolean resolvePlaceholders)
resolvePlaceholders
- flag valuepublic void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public Class<?> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<T>
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<T>
public void bindPropertiesToTarget() throws org.springframework.validation.BindException
org.springframework.validation.BindException
protected void customizeBinder(org.springframework.validation.DataBinder dataBinder)
dataBinder
- the data binder that will be used to bind and validateCopyright © 2018 Pivotal Software, Inc.. All rights reserved.