org.springframework.boot.bind
Class PropertiesConfigurationFactory<T>

java.lang.Object
  extended by org.springframework.boot.bind.PropertiesConfigurationFactory<T>
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.InitializingBean, org.springframework.context.MessageSourceAware

public class PropertiesConfigurationFactory<T>
extends Object
implements org.springframework.beans.factory.FactoryBean<T>, org.springframework.context.MessageSourceAware, org.springframework.beans.factory.InitializingBean

Validate some Properties (or optionally PropertySources) by binding them to an object of a specified type and then optionally running a Validator over it.

Author:
Dave Syer

Constructor Summary
PropertiesConfigurationFactory(Class<?> type)
          Create a new factory for an object of the given type.
PropertiesConfigurationFactory(T target)
           
 
Method Summary
 void afterPropertiesSet()
           
 void bindPropertiesToTarget()
           
protected  void customizeBinder(org.springframework.validation.DataBinder dataBinder)
           
 T getObject()
           
 Class<?> getObjectType()
           
 boolean isSingleton()
           
 void setConversionService(org.springframework.core.convert.ConversionService conversionService)
           
 void setExceptionIfInvalid(boolean exceptionIfInvalid)
           
 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 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)
           
 void setProperties(Properties properties)
           
 void setPropertySources(org.springframework.core.env.PropertySources propertySources)
           
 void setTargetName(String targetName)
           
 void setValidator(org.springframework.validation.Validator validator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesConfigurationFactory

public PropertiesConfigurationFactory(T target)
Parameters:
target - the target object to bind too
See Also:
PropertiesConfigurationFactory(Class)

PropertiesConfigurationFactory

public PropertiesConfigurationFactory(Class<?> type)
Create a new factory for an object of the given type.

See Also:
PropertiesConfigurationFactory(Class)
Method Detail

setIgnoreUnknownFields

public 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.

Default is "true". Turn this off to enforce that all bind parameters must have a matching field in the target object.

Parameters:
ignoreUnknownFields - if unknown fields should be ignored

setIgnoreInvalidFields

public 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).

Default is "false". Turn this on to ignore bind parameters for nested objects in non-existing parts of the target object graph.

Parameters:
ignoreInvalidFields - if invalid fields should be ignored

setTargetName

public void setTargetName(String targetName)
Parameters:
targetName - the target name to set

setMessageSource

public void setMessageSource(org.springframework.context.MessageSource messageSource)
Specified by:
setMessageSource in interface org.springframework.context.MessageSourceAware
Parameters:
messageSource - the messageSource to set

setProperties

public void setProperties(Properties properties)
Parameters:
properties - the properties to set

setPropertySources

public void setPropertySources(org.springframework.core.env.PropertySources propertySources)
Parameters:
propertySources - the propertySources to set

setConversionService

public void setConversionService(org.springframework.core.convert.ConversionService conversionService)
Parameters:
conversionService - the conversionService to set

setValidator

public void setValidator(org.springframework.validation.Validator validator)
Parameters:
validator - the validator to set

setExceptionIfInvalid

public void setExceptionIfInvalid(boolean exceptionIfInvalid)

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

getObjectType

public Class<?> getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<T>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<T>

getObject

public T getObject()
            throws Exception
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<T>
Throws:
Exception

bindPropertiesToTarget

public void bindPropertiesToTarget()
                            throws org.springframework.validation.BindException
Throws:
org.springframework.validation.BindException

customizeBinder

protected void customizeBinder(org.springframework.validation.DataBinder dataBinder)
Parameters:
dataBinder - the data binder that will be used to bind and validate


Copyright © 2013. All Rights Reserved.