Make StripesFilter more subclass-friendly

Description

Class StripesFilter has private members "configuration" and "configurations" which have no corresponding getters/setters. It is therefore currently impossible for a subclass of StripesFilter to access these fields.

Being able to customise the configuration instance is very useful - particularly when using a dependency-injection framework that can be used to instantiate and configure a custom Configuration instance.

Property "RuntimeConfiguration.ACTION_RESOLVER" can be used to specify which class to use for the Configuration member, but the object will be created via newInstance(), not via any dependency-injection framework.

Suggestion: In method StripesFilter.init(FilterConfig), factor out the code that creates the configuration instance into a separate protected-scope method:

public void init(FilterConfig filterConfig) throws ServletException {
BootstrapPropertyResolver bootstrap = new BootstrapPropertyResolver(filterConfig);

this.configuration = createConfiguration(filterConfig, bootstrap);
.. rest of method as before ..
}

/**

  • Create an instance of the Configuration interface which this

  • filter instance will use.
    */
    protected Configuration createConfiguration(
    FilterConfig filterConfig, BootstrapPropertyResolver bootstrap)
    throws StripesServletException {
    .. code factored out from init method
    }


I've provided the createConfiguration method with the filterConfig param
because some customisations of this method might want to use data from
this object to select or configure the created Configuration object.

Environment

None

Status

Assignee

BenB

Reporter

Simon Kitching

Labels

None

Tester

None

Components

Fix versions

Affects versions

Release 1.5.5

Priority

Major
Configure