public class DefaultConfiguration extends java.lang.Object implements Configuration
Centralized location for defaults for all Configuration properties. This implementation does not lookup configuration information anywhere! It returns hard-coded defaults that will result in a working system without any user intervention.
Despite it's name the DefaultConfiguration is not in fact the default Configuration
implementation in Stripes! Instead it is the retainer of default configuration values. The
Configuration implementation that is used when no alternative is configured is the
RuntimeConfiguration
, which is a direct subclass of DefaultConfiguration, and when no
further configuration properties are supplied behaves identically to the DefaultConfiguration.
The DefaultConfiguration is designed to be easily extended as needed. The init() method ensures that components are initialized in the correct order (taking dependencies into account), and should generally not be overridden. It invokes a number of initXXX() methods, one per configurable component. Subclasses should override any of the initXXX() methods desirable to return a fully initialized instance of the relevant component type, or null if the default is desired.
Constructor and Description |
---|
DefaultConfiguration() |
Modifier and Type | Method and Description |
---|---|
protected void |
addInterceptor(java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> map,
Interceptor interceptor)
Adds the interceptor to the map, associating it with the
LifecycleStage s indicated
by the Intercepts annotation. |
ActionBeanContextFactory |
getActionBeanContextFactory()
Returns the configured ActionBeanContextFactory.
|
ActionBeanPropertyBinder |
getActionBeanPropertyBinder()
Returns an instance of
DefaultActionBeanPropertyBinder unless a subclass has
overridden the default. |
ActionResolver |
getActionResolver()
Returns an instance of
NameBasedActionResolver unless a subclass has
overridden the default. |
BootstrapPropertyResolver |
getBootstrapPropertyResolver()
Returns a reference to the resolver supplied at initialization time.
|
ExceptionHandler |
getExceptionHandler()
Returns an instance of an ExceptionHandler.
|
FormatterFactory |
getFormatterFactory()
Returns an instance of a FormatterFactory.
|
java.util.Collection<Interceptor> |
getInterceptors(LifecycleStage stage)
Returns a list of interceptors that should be executed around the lifecycle stage
indicated.
|
LocalePicker |
getLocalePicker()
Returns an instance of a LocalePicker.
|
LocalizationBundleFactory |
getLocalizationBundleFactory()
Returns an instance of a LocalizationBundleFactory.
|
MultipartWrapperFactory |
getMultipartWrapperFactory()
Returns an instance of MultipartWrapperFactory that can be used by Stripes to construct
MultipartWrapper instances for dealing with multipart requests (those containing file
uploads).
|
PopulationStrategy |
getPopulationStrategy()
Returns an instance of a PopulationsStrategy.
|
javax.servlet.ServletContext |
getServletContext()
Retrieves the ServletContext for the context within which the Stripes application is
executing.
|
TagErrorRendererFactory |
getTagErrorRendererFactory()
Returns an instance of a TagErrorRendererFactory.
|
TypeConverterFactory |
getTypeConverterFactory()
Returns an instance of
DefaultTypeConverterFactory unless a subclass has
overridden the default.. |
ValidationMetadataProvider |
getValidationMetadataProvider()
Returns an instance of
ValidationMetadataProvider that can be used by Stripes to
determine what validations need to be applied during
LifecycleStage.BindingAndValidation . |
void |
init()
Creates and stores instances of the objects of the type that the Configuration is
responsible for providing, except where subclasses have already provided instances.
|
protected ActionBeanContextFactory |
initActionBeanContextFactory()
Allows subclasses to initialize a non-default ActionBeanContextFactory.
|
protected ActionBeanPropertyBinder |
initActionBeanPropertyBinder()
Allows subclasses to initialize a non-default ActionBeanPropertyBinder.
|
protected ActionResolver |
initActionResolver()
Allows subclasses to initialize a non-default ActionResovler.
|
protected java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> |
initCoreInterceptors()
Instantiates the core interceptors, allowing subclasses to override the default behavior
|
protected java.lang.Boolean |
initDebugMode()
Allows subclasses to initialize a non-default debug mode value.
|
protected ExceptionHandler |
initExceptionHandler()
Allows subclasses to initialize a non-default ExceptionHandler instance to be used.
|
protected FormatterFactory |
initFormatterFactory()
Allows subclasses to initialize a non-default FormatterFactory.
|
protected java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> |
initInterceptors()
Allows subclasses to initialize a non-default Map of Interceptor instances.
|
protected LocalePicker |
initLocalePicker()
Allows subclasses to initialize a non-default LocalePicker.
|
protected LocalizationBundleFactory |
initLocalizationBundleFactory()
Allows subclasses to initialize a non-default LocalizationBundleFactory.
|
protected MultipartWrapperFactory |
initMultipartWrapperFactory()
Allows subclasses to initialize a non-default MultipartWrapperFactory.
|
protected PopulationStrategy |
initPopulationStrategy()
Allows subclasses to initialize a non-default PopulationStrategy instance to be used.
|
protected TagErrorRendererFactory |
initTagErrorRendererFactory()
Allows subclasses to initialize a non-default TagErrorRendererFactory instance to be used.
|
protected TypeConverterFactory |
initTypeConverterFactory()
Allows subclasses to initialize a non-default TypeConverterFactory.
|
protected ValidationMetadataProvider |
initValidationMetadataProvider()
Allows subclasses to initialize a non-default
ValidationMetadataProvider . |
boolean |
isDebugMode()
Returns true if the Stripes application is running in debug mode.
|
protected void |
mergeInterceptorMaps(java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> dst,
java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> src)
|
void |
setBootstrapPropertyResolver(BootstrapPropertyResolver resolver)
Gratefully accepts the BootstrapPropertyResolver handed to the Configuration.
|
void |
setDebugMode(boolean debugMode)
Enable or disable debug mode.
|
public void setBootstrapPropertyResolver(BootstrapPropertyResolver resolver)
setBootstrapPropertyResolver
in interface Configuration
resolver
- a BootStrapPropertyResolver which can be used to find any values required
by the Configuration in order to initializepublic void init()
init
in interface Configuration
public BootstrapPropertyResolver getBootstrapPropertyResolver()
getBootstrapPropertyResolver
in interface Configuration
public javax.servlet.ServletContext getServletContext()
getServletContext
in interface Configuration
public void setDebugMode(boolean debugMode)
setDebugMode
in interface Configuration
public boolean isDebugMode()
isDebugMode
in interface Configuration
protected java.lang.Boolean initDebugMode()
public ActionResolver getActionResolver()
NameBasedActionResolver
unless a subclass has
overridden the default.getActionResolver
in interface Configuration
protected ActionResolver initActionResolver()
public ActionBeanPropertyBinder getActionBeanPropertyBinder()
DefaultActionBeanPropertyBinder
unless a subclass has
overridden the default.getActionBeanPropertyBinder
in interface Configuration
protected ActionBeanPropertyBinder initActionBeanPropertyBinder()
public ActionBeanContextFactory getActionBeanContextFactory()
getActionBeanContextFactory
in interface Configuration
protected ActionBeanContextFactory initActionBeanContextFactory()
public TypeConverterFactory getTypeConverterFactory()
DefaultTypeConverterFactory
unless a subclass has
overridden the default..getTypeConverterFactory
in interface Configuration
protected TypeConverterFactory initTypeConverterFactory()
public LocalizationBundleFactory getLocalizationBundleFactory()
getLocalizationBundleFactory
in interface Configuration
protected LocalizationBundleFactory initLocalizationBundleFactory()
public LocalePicker getLocalePicker()
getLocalePicker
in interface Configuration
protected LocalePicker initLocalePicker()
public FormatterFactory getFormatterFactory()
getFormatterFactory
in interface Configuration
protected FormatterFactory initFormatterFactory()
public TagErrorRendererFactory getTagErrorRendererFactory()
getTagErrorRendererFactory
in interface Configuration
protected TagErrorRendererFactory initTagErrorRendererFactory()
public PopulationStrategy getPopulationStrategy()
DefaultPopulationStrategy
.getPopulationStrategy
in interface Configuration
protected PopulationStrategy initPopulationStrategy()
public ExceptionHandler getExceptionHandler()
DefaultExceptionHandler
.getExceptionHandler
in interface Configuration
protected ExceptionHandler initExceptionHandler()
public MultipartWrapperFactory getMultipartWrapperFactory()
getMultipartWrapperFactory
in interface Configuration
protected MultipartWrapperFactory initMultipartWrapperFactory()
public ValidationMetadataProvider getValidationMetadataProvider()
ValidationMetadataProvider
that can be used by Stripes to
determine what validations need to be applied during
LifecycleStage.BindingAndValidation
.getValidationMetadataProvider
in interface Configuration
ValidationMetadataProvider
protected ValidationMetadataProvider initValidationMetadataProvider()
ValidationMetadataProvider
.public java.util.Collection<Interceptor> getInterceptors(LifecycleStage stage)
BeforeAfterMethodInterceptor
.getInterceptors
in interface Configuration
protected void mergeInterceptorMaps(java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> dst, java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> src)
Map
s of LifecycleStage
to Collection
of
Interceptor
. A simple Map.putAll(Map)
does not work because it overwrites
the collections in the map instead of adding to them.protected void addInterceptor(java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> map, Interceptor interceptor)
LifecycleStage
s indicated
by the Intercepts
annotation. If the interceptor implements
ConfigurableComponent
, then its init() method will be called.protected java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> initCoreInterceptors()
protected java.util.Map<LifecycleStage,java.util.Collection<Interceptor>> initInterceptors()
? Copyright 2005-2006, Stripes Development Team.