net.sourceforge.stripes.config
Class DefaultConfiguration

java.lang.Object
  extended by net.sourceforge.stripes.config.DefaultConfiguration
All Implemented Interfaces:
Configuration
Direct Known Subclasses:
RuntimeConfiguration

public class DefaultConfiguration
extends 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.

Author:
Tim Fennell

Constructor Summary
DefaultConfiguration()
           
 
Method Summary
protected  void addInterceptor(Map<LifecycleStage,Collection<Interceptor>> map, Interceptor interceptor)
          Adds the interceptor to the map, associating it with the LifecycleStages 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.
 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.
 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  Map<LifecycleStage,Collection<Interceptor>> initCoreInterceptors()
          Instantiates the core interceptors, allowing subclasses to override the default behavior
protected  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  Map<LifecycleStage,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(Map<LifecycleStage,Collection<Interceptor>> dst, Map<LifecycleStage,Collection<Interceptor>> src)
          Merges the two Maps of LifecycleStage to Collection of Interceptor.
 void setBootstrapPropertyResolver(BootstrapPropertyResolver resolver)
          Gratefully accepts the BootstrapPropertyResolver handed to the Configuration.
 void setDebugMode(boolean debugMode)
          Enable or disable debug mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultConfiguration

public DefaultConfiguration()
Method Detail

setBootstrapPropertyResolver

public void setBootstrapPropertyResolver(BootstrapPropertyResolver resolver)
Gratefully accepts the BootstrapPropertyResolver handed to the Configuration.

Specified by:
setBootstrapPropertyResolver in interface Configuration
Parameters:
resolver - a BootStrapPropertyResolver which can be used to find any values required by the Configuration in order to initialize

init

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

Specified by:
init in interface Configuration

getBootstrapPropertyResolver

public BootstrapPropertyResolver getBootstrapPropertyResolver()
Returns a reference to the resolver supplied at initialization time.

Specified by:
getBootstrapPropertyResolver in interface Configuration
Returns:
BootstrapPropertyResolver the instance passed to the init() method

getServletContext

public ServletContext getServletContext()
Retrieves the ServletContext for the context within which the Stripes application is executing.

Specified by:
getServletContext in interface Configuration
Returns:
the ServletContext in which the application is running

setDebugMode

public void setDebugMode(boolean debugMode)
Enable or disable debug mode.

Specified by:
setDebugMode in interface Configuration

isDebugMode

public boolean isDebugMode()
Returns true if the Stripes application is running in debug mode.

Specified by:
isDebugMode in interface Configuration

initDebugMode

protected Boolean initDebugMode()
Allows subclasses to initialize a non-default debug mode value.


getActionResolver

public ActionResolver getActionResolver()
Returns an instance of NameBasedActionResolver unless a subclass has overridden the default.

Specified by:
getActionResolver in interface Configuration
Returns:
ActionResolver an instance of the configured resolver

initActionResolver

protected ActionResolver initActionResolver()
Allows subclasses to initialize a non-default ActionResovler.


getActionBeanPropertyBinder

public ActionBeanPropertyBinder getActionBeanPropertyBinder()
Returns an instance of DefaultActionBeanPropertyBinder unless a subclass has overridden the default.

Specified by:
getActionBeanPropertyBinder in interface Configuration
Returns:
ActionBeanPropertyBinder an instance of the configured binder

initActionBeanPropertyBinder

protected ActionBeanPropertyBinder initActionBeanPropertyBinder()
Allows subclasses to initialize a non-default ActionBeanPropertyBinder.


getActionBeanContextFactory

public ActionBeanContextFactory getActionBeanContextFactory()
Returns the configured ActionBeanContextFactory. Unless a subclass has configured a custom one, the instance will be a DefaultActionBeanContextFactory.

Specified by:
getActionBeanContextFactory in interface Configuration
Returns:
ActionBeanContextFactory an instance of a factory for creating ActionBeanContexts

initActionBeanContextFactory

protected ActionBeanContextFactory initActionBeanContextFactory()
Allows subclasses to initialize a non-default ActionBeanContextFactory.


getTypeConverterFactory

public TypeConverterFactory getTypeConverterFactory()
Returns an instance of DefaultTypeConverterFactory unless a subclass has overridden the default..

Specified by:
getTypeConverterFactory in interface Configuration
Returns:
TypeConverterFactory an instance of the configured factory.

initTypeConverterFactory

protected TypeConverterFactory initTypeConverterFactory()
Allows subclasses to initialize a non-default TypeConverterFactory.


getLocalizationBundleFactory

public LocalizationBundleFactory getLocalizationBundleFactory()
Returns an instance of a LocalizationBundleFactory. By default this will be an instance of DefaultLocalizationBundleFactory unless another type has been configured.

Specified by:
getLocalizationBundleFactory in interface Configuration
Returns:
LocalizationBundleFactory an instance of a LocalizationBundleFactory implementation

initLocalizationBundleFactory

protected LocalizationBundleFactory initLocalizationBundleFactory()
Allows subclasses to initialize a non-default LocalizationBundleFactory.


getLocalePicker

public LocalePicker getLocalePicker()
Returns an instance of a LocalePicker. Unless a subclass has picked another implementation will return an instance of DefaultLocalePicker.

Specified by:
getLocalePicker in interface Configuration
Returns:
LocalePicker an instance of a LocalePicker implementation

initLocalePicker

protected LocalePicker initLocalePicker()
Allows subclasses to initialize a non-default LocalePicker.


getFormatterFactory

public FormatterFactory getFormatterFactory()
Returns an instance of a FormatterFactory. Unless a subclass has picked another implementation will return an instance of DefaultFormatterFactory.

Specified by:
getFormatterFactory in interface Configuration
Returns:
LocalePicker an instance of a LocalePicker implementation

initFormatterFactory

protected FormatterFactory initFormatterFactory()
Allows subclasses to initialize a non-default FormatterFactory.


getTagErrorRendererFactory

public TagErrorRendererFactory getTagErrorRendererFactory()
Returns an instance of a TagErrorRendererFactory. Unless a subclass has picked another implementation, will return an instance of DefaultTagErrorRendererFactory.

Specified by:
getTagErrorRendererFactory in interface Configuration
Returns:
TagErrorRendererFactory an instance of TagErrorRendererFactory

initTagErrorRendererFactory

protected TagErrorRendererFactory initTagErrorRendererFactory()
Allows subclasses to initialize a non-default TagErrorRendererFactory instance to be used.


getPopulationStrategy

public PopulationStrategy getPopulationStrategy()
Returns an instance of a PopulationsStrategy. Unless a subclass has picked another implementation, will return an instance of DefaultPopulationStrategy.

Specified by:
getPopulationStrategy in interface Configuration
Returns:
PopulationStrategy an instance of PopulationStrategy

initPopulationStrategy

protected PopulationStrategy initPopulationStrategy()
Allows subclasses to initialize a non-default PopulationStrategy instance to be used.


getExceptionHandler

public ExceptionHandler getExceptionHandler()
Returns an instance of an ExceptionHandler. Unless a subclass has picked another implementation, will return an instance of DefaultExceptionHandler.

Specified by:
getExceptionHandler in interface Configuration
Returns:
ExceptionHandler an instance of ExceptionHandler

initExceptionHandler

protected ExceptionHandler initExceptionHandler()
Allows subclasses to initialize a non-default ExceptionHandler instance to be used.


getMultipartWrapperFactory

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

Specified by:
getMultipartWrapperFactory in interface Configuration
Returns:
MultipartWrapperFactory an instance of the wrapper factory

initMultipartWrapperFactory

protected MultipartWrapperFactory initMultipartWrapperFactory()
Allows subclasses to initialize a non-default MultipartWrapperFactory.


getValidationMetadataProvider

public ValidationMetadataProvider getValidationMetadataProvider()
Returns an instance of ValidationMetadataProvider that can be used by Stripes to determine what validations need to be applied during LifecycleStage.BindingAndValidation.

Specified by:
getValidationMetadataProvider in interface Configuration
Returns:
an instance of ValidationMetadataProvider

initValidationMetadataProvider

protected ValidationMetadataProvider initValidationMetadataProvider()
Allows subclasses to initialize a non-default ValidationMetadataProvider.


getInterceptors

public Collection<Interceptor> getInterceptors(LifecycleStage stage)
Returns a list of interceptors that should be executed around the lifecycle stage indicated. By default returns a single element list containing the BeforeAfterMethodInterceptor.

Specified by:
getInterceptors in interface Configuration
Returns:
Collection an ordered collection of interceptors to be executed around the given lifecycle stage.

mergeInterceptorMaps

protected void mergeInterceptorMaps(Map<LifecycleStage,Collection<Interceptor>> dst,
                                    Map<LifecycleStage,Collection<Interceptor>> src)
Merges the two Maps 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.


addInterceptor

protected void addInterceptor(Map<LifecycleStage,Collection<Interceptor>> map,
                              Interceptor interceptor)
Adds the interceptor to the map, associating it with the LifecycleStages indicated by the Intercepts annotation. If the interceptor implements ConfigurableComponent, then its init() method will be called.


initCoreInterceptors

protected Map<LifecycleStage,Collection<Interceptor>> initCoreInterceptors()
Instantiates the core interceptors, allowing subclasses to override the default behavior


initInterceptors

protected Map<LifecycleStage,Collection<Interceptor>> initInterceptors()
Allows subclasses to initialize a non-default Map of Interceptor instances.



? Copyright 2005-2006, Stripes Development Team.