Package org.appng.api.support
Class RequestSupportImpl
- java.lang.Object
-
- org.appng.api.support.RequestSupportImpl
-
- All Implemented Interfaces:
RequestSupport
,org.springframework.beans.factory.InitializingBean
,org.springframework.core.convert.ConversionService
public class RequestSupportImpl extends Object implements RequestSupport
DefaultRequestSupport
implementation- Author:
- Matthias Müller
-
-
Field Summary
Fields Modifier and Type Field Description protected org.springframework.core.convert.ConversionService
conversionService
protected static String
CURRENT
protected Environment
environment
protected ExpressionEvaluator
expressionEvaluator
protected FieldConversionFactory
fieldConverter
protected List<FieldType>
FILE_TYPES
protected List<FieldType>
LIST_TYPES
protected org.springframework.context.MessageSource
messageSource
-
Constructor Summary
Constructors Constructor Description RequestSupportImpl()
RequestSupportImpl(org.springframework.core.convert.ConversionService conversionService, Environment environment, org.springframework.context.MessageSource messageSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addErrorMessage(FieldProcessor fp, MessageParam messageParam)
Adds an error to theFieldProcessor
usingFieldProcessor.addErrorMessage(String)
.void
addErrorMessage(FieldProcessor fp, MessageParam messageParam, String fieldBinding)
Adds an error to aFieldDef
usingFieldProcessor.addErrorMessage(org.appng.xml.platform.FieldDef, String)
.void
afterPropertiesSet()
boolean
canConvert(Class<?> sourceType, Class<?> targetType)
boolean
canConvert(org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
<T> T
convert(Object source, Class<T> target)
<T> T
convert(Object source, Class<T> target, T defaultValue)
Object
convert(Object source, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
void
fillBindObject(Object instance, FieldProcessor fp, RequestContainer container, ClassLoader classLoader)
Fills the givenbindobject
with the (converted) values provided by aRequestContainer
.Object
getBindObject(FieldProcessor fp, RequestContainer container, ClassLoader classLoader)
Creates, fills and returns a new bindobject.org.springframework.core.convert.ConversionService
getConversionService()
<T> T
getDefaultIfNull(T source, T defaultValue)
Environment
getEnvironment()
ExpressionEvaluator
getExpressionEvaluator()
FieldConverter
getFieldConverter()
String
getMessage(String key, Object... args)
Retrieves a message from the underlyingMessageSource
, using theLocale
provided byEnvironment.getLocale()
.org.springframework.context.MessageSource
getMessageSource()
void
handleException(FieldProcessor fp, Exception e)
Handles anException
.boolean
isFile(FieldType type)
boolean
isListType(FieldType type)
void
setConversionService(org.springframework.core.convert.ConversionService conversionService)
void
setEnvironment(Environment environment)
void
setExpressionEvaluator(ExpressionEvaluator expressionEvaluator)
void
setMessageSource(org.springframework.context.MessageSource messageSource)
<T> void
setPropertyValue(T source, T target, String property)
Copies the property fromsource
totarget
.<T> void
setPropertyValues(T source, T target, MetaData metaData)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.appng.api.RequestSupport
getEnvironment, getFieldConverter, getMessageSource
-
-
-
-
Field Detail
-
CURRENT
protected static final String CURRENT
- See Also:
- Constant Field Values
-
conversionService
protected org.springframework.core.convert.ConversionService conversionService
-
messageSource
protected org.springframework.context.MessageSource messageSource
-
environment
protected Environment environment
-
expressionEvaluator
protected ExpressionEvaluator expressionEvaluator
-
fieldConverter
protected FieldConversionFactory fieldConverter
-
-
Constructor Detail
-
RequestSupportImpl
public RequestSupportImpl()
-
RequestSupportImpl
public RequestSupportImpl(org.springframework.core.convert.ConversionService conversionService, Environment environment, org.springframework.context.MessageSource messageSource)
-
-
Method Detail
-
fillBindObject
public final void fillBindObject(Object instance, FieldProcessor fp, RequestContainer container, ClassLoader classLoader) throws BusinessException
Description copied from interface:RequestSupport
Fills the givenbindobject
with the (converted) values provided by aRequestContainer
. The type of thebindobject
must matchfp.getMetaData().getBindClass()
. TheMetaData
'sFieldDef
initions are responsible for which fields are getting filled.- Specified by:
fillBindObject
in interfaceRequestSupport
- Parameters:
instance
- the bindobject to fillfp
- the currentFieldProcessor
container
- theRequestContainer
used to retrieve the values for filling the bindobjectclassLoader
- theClassLoader
used to load the bindclass- Throws:
BusinessException
-- if the type of the
bindobject
is not assignable from the type returned byfp.getMetaData().getBindClass()
- if the type returned by
fp.getMetaData().getBindClass()
can not be instanciated
- if the type of the
-
getBindObject
public final Object getBindObject(FieldProcessor fp, RequestContainer container, ClassLoader classLoader) throws BusinessException
Description copied from interface:RequestSupport
Creates, fills and returns a new bindobject. The type of the returned object is obtained fromfp.getMetaData().getBindClass()
. TheMetaData
'sFieldDef
initions are responsible for which fields are getting filled.- Specified by:
getBindObject
in interfaceRequestSupport
- Parameters:
fp
- the currentFieldProcessor
container
- theRequestContainer
used to retrieve the values for filling the bindobjectclassLoader
- theClassLoader
used to load the bindclass- Returns:
- a new bindobject
- Throws:
BusinessException
- if the bindclass could not be loaded, instantiated or initialized, or if an error occurred during filling the bindobject- See Also:
RequestSupport.fillBindObject(Object, FieldProcessor, RequestContainer, ClassLoader)
-
getDefaultIfNull
public <T> T getDefaultIfNull(T source, T defaultValue)
-
getMessage
public String getMessage(String key, Object... args)
Description copied from interface:RequestSupport
Retrieves a message from the underlyingMessageSource
, using theLocale
provided byEnvironment.getLocale()
.- Specified by:
getMessage
in interfaceRequestSupport
- Parameters:
key
- the message keyargs
- the message arguments
-
addErrorMessage
public void addErrorMessage(FieldProcessor fp, MessageParam messageParam)
Description copied from interface:RequestSupport
Adds an error to theFieldProcessor
usingFieldProcessor.addErrorMessage(String)
.MessageParam.getMessageKey()
is used for the message key,MessageParam.getMessageArgs()
for the message arguments.- Specified by:
addErrorMessage
in interfaceRequestSupport
- Parameters:
fp
- aFieldProcessor
messageParam
- aMessageParam
- See Also:
MessageParam
-
addErrorMessage
public void addErrorMessage(FieldProcessor fp, MessageParam messageParam, String fieldBinding)
Description copied from interface:RequestSupport
Adds an error to aFieldDef
usingFieldProcessor.addErrorMessage(org.appng.xml.platform.FieldDef, String)
.MessageParam.getMessageKey()
is used for the message key,MessageParam.getMessageArgs()
for the message arguments.- Specified by:
addErrorMessage
in interfaceRequestSupport
- Parameters:
fp
- aFieldProcessor
messageParam
- aMessageParam
fieldBinding
- the binding of theFieldDef
to add the error to- See Also:
MessageParam
-
handleException
public void handleException(FieldProcessor fp, Exception e) throws BusinessException
Description copied from interface:RequestSupport
Handles anException
. If the given Exception is aBusinessException
, the very sameBusinessException
is being re-thrown. Otherwise, theException
is being wrapped into a newBusinessException
which is then being thrown.
If the givenException
is aMessageParam
,RequestSupport.addErrorMessage(FieldProcessor, MessageParam)
is being called.- Specified by:
handleException
in interfaceRequestSupport
- Parameters:
fp
- aFieldProcessor
e
- anException
- Throws:
BusinessException
- See Also:
MessageParam
,RequestSupport.addErrorMessage(FieldProcessor, MessageParam)
-
setPropertyValues
public <T> void setPropertyValues(T source, T target, MetaData metaData)
Description copied from interface:RequestSupport
- Specified by:
setPropertyValues
in interfaceRequestSupport
- Parameters:
source
- the source object to read the fields fromtarget
- the target object to write the fields tometaData
- theMetaData
-
setPropertyValue
public <T> void setPropertyValue(T source, T target, String property)
Description copied from interface:RequestSupport
Copies the property fromsource
totarget
.- Specified by:
setPropertyValue
in interfaceRequestSupport
- Parameters:
source
- the source object to read the property fromtarget
- the target object to write the property toproperty
- the name of the property to set
-
canConvert
public boolean canConvert(Class<?> sourceType, Class<?> targetType)
- Specified by:
canConvert
in interfaceorg.springframework.core.convert.ConversionService
-
canConvert
public boolean canConvert(org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
- Specified by:
canConvert
in interfaceorg.springframework.core.convert.ConversionService
-
convert
public Object convert(Object source, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)
- Specified by:
convert
in interfaceorg.springframework.core.convert.ConversionService
-
convert
public <T> T convert(Object source, Class<T> target)
- Specified by:
convert
in interfaceorg.springframework.core.convert.ConversionService
-
getConversionService
public org.springframework.core.convert.ConversionService getConversionService()
-
setConversionService
public void setConversionService(org.springframework.core.convert.ConversionService conversionService)
-
getMessageSource
public org.springframework.context.MessageSource getMessageSource()
-
setMessageSource
public void setMessageSource(org.springframework.context.MessageSource messageSource)
-
getEnvironment
public Environment getEnvironment()
-
setEnvironment
public void setEnvironment(Environment environment)
-
getExpressionEvaluator
public ExpressionEvaluator getExpressionEvaluator()
-
setExpressionEvaluator
public void setExpressionEvaluator(ExpressionEvaluator expressionEvaluator)
-
isFile
public final boolean isFile(FieldType type)
-
isListType
public final boolean isListType(FieldType type)
-
getFieldConverter
public FieldConverter getFieldConverter()
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
-