Stripes

Make StripesFilter more subclass-friendly

Details

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.

Activity

Hide
Ben Gunter added a comment - 02/Dec/11 3:07 PM

We have already added a more general solution to this problem for Stripes 1.6 in the form of ObjectFactory. In 1.6, everything is instantiated through the ObjectFactory, which applies ObjectPostProcessors to every new instance. ObjectPostProcessors are discovered at runtime like other extensions.

I will do what you've suggested for 1.5.7 and 1.6.

Show
Ben Gunter added a comment - 02/Dec/11 3:07 PM We have already added a more general solution to this problem for Stripes 1.6 in the form of ObjectFactory. In 1.6, everything is instantiated through the ObjectFactory, which applies ObjectPostProcessors to every new instance. ObjectPostProcessors are discovered at runtime like other extensions. I will do what you've suggested for 1.5.7 and 1.6.
Hide
Ben Gunter added a comment - 02/Dec/11 3:13 PM

Fixed for 1.5.7 and 1.6

Show
Ben Gunter added a comment - 02/Dec/11 3:13 PM Fixed for 1.5.7 and 1.6

People

Vote (0)
Watch (0)

Dates

  • Created:
    13/Feb/11 4:34 PM
    Updated:
    02/Dec/11 3:13 PM
    Resolved:
    02/Dec/11 3:13 PM