Hi All, I've got a project using both Stripes (1.5.5) and Guice. While stripes does provide the "RuntimeConfiguration.ACTION_RESOLVER" config param to the StripesFilter class, this isn't an entirely satisfactory way to integrate the two. In particular, it requires that the property point to a class that has a static reference to a Guice injector.
I'm using the above approach at the moment, but I'd prefer to instead
subclass StripesFilter to use a custom Guice-created Configuration
instance. Unfortunately, StripesFilter.init() is written in a way that
makes this impossible:
* it uses clazz.newInstance() to instantiate the configuration object;
* it then stores it in private fields this.configuration and
StripesFilter.configurations, ie fields inaccessable to subclasses.
Simply factoring out the code to create the Configuration object from
the init method into a separate protected method would make
StripesFilter.java more subclass-friendly; the createConfiguration
method can be overridden while allowing "this.configuration" and
"StripesFilter.configurations" to remain private:
public void init(FilterConfig filterConfig) throws ServletException {
BootstrapPropertyResolver bootstrap = new
BootstrapPropertyResolver(filterConfig);
this.configuration = createConfiguration(filterConfig, bootstrap);
.. 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.
See attached files for full code and patch. Sorry I haven't provided a
"svn diff" patch, but I'm behind a firewall that blocks svn :-(.
I'd appreciate you considering this for v1.5.6....
Regards,
Simon
Good planets are hard to find - please think of the environment before you
print this email.
____________________________________________________________________
CAUTION - This message may contain privileged and confidential
information intended only for the use of the addressee named above.
If you are not the intended recipient of this message you are hereby
notified that any use, dissemination, distribution or reproduction
of this message is prohibited. If you have received this message in
error please notify Air New Zealand immediately. Any views expressed
in this message are those of the individual sender and may not
necessarily reflect the views of Air New Zealand.
_____________________________________________________________________
For more information on the Air New Zealand Group, visit us online
at http://www.airnewzealand.com
_____________________________________________________________________
<<winmail.dat>>
------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________ Stripes-development mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-development
