Stripes-Reload

Frederic Daoud
23 September 2008

NEWS

Quick Links

References

1. What is Stripes-Reload?

Stripes-Reload is a set of Stripes extensions that reload some of your Stripes-associated classes without having to restart the server so that you see your changes immediately. Stripes-Reload detects changes and reloads the following:

For Action Beans, Type Converters, and Formatters, Stripes-Reload also detects new classes. For example, while your server is already running, you can add a new Action Bean, make a request to its URL binding, and Stripes-Reload will discover and load the newly added Action Bean.

For new classes to be discovered, they must be in a package that you have configured in web.xml with ActionResolver.Packages for Action Beans, and Extension.Packages for Type Converters and Formatters.

For resource bundles (StripesResources.properties by default), you will see your changes for Stripes-managed localization, such as labels for form input fields, submit buttons, error message text, and so on.

JSTL-managed localization such as text rendered with the <fmt:message> tag will also be reloaded, as long as you configure the resource bundle in web.xml as follows:

  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>StripesResources</param-value>
    <!-- (you can use a different name instead of StripesResources if you wish.) -->
  </context-param>

2. What isn't Stripes-Reload?

IMPORTANT: Stripes-Reload is NOT meant for use in production. It is NOT optimized for performance, memory usage, and so on. Stripes-Reload is meant to be used in your local development environment for you to see some of your code changes immediately without having to restart your server.

3. How do I set it up in my own project?

IMPORTANT:

Stripes-Reload is very easy to set up: just add the stripes-reload.jar file in the WEB-INF/lib directory of your web application, and add org.stripesbook.reload.extensions to the Extension.Packages initialization parameter for the Stripes Filter in web.xml:

web_default.xml
<filter>
  <filter-name>StripesFilter</filter-name>
  <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
  <init-param>
    <param-name>ActionResolver.Packages</param-name>
    <param-value>...</param-value>
  </init-param>
  <init-param>
    <param-name>Extension.Packages</param-name>
    <param-value>org.stripesbook.reload.extensions</param-value>
  </init-param>
</filter>

Once you have that set up, start the server to run your application. Make sure that when you make changes, the modified files are placed in the directories from which the server is running the application (typically files under the WEB-INF/classes directory). You should see your changes by refreshing the request in your browser.

You can also use some parts of Stripes-Reload and not others. For example, you could just use the extension that reloads Action Beans. In this case, do not add org.stripesbook.reload.extensions to the Extension.Packages initialization parameter. Instead, configure each extension that you want to use separately. For example:

web_partial.xml
<filter>
  <filter-name>StripesFilter</filter-name>
  <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
  <init-param>
    <param-name>ActionResolver.Packages</param-name>
    <param-value>org.stripesbook.reload.example.action</param-value>
  </init-param>
  <init-param>
    <param-name>ActionResolver.Class</param-name>
    <param-value>org.stripesbook.reload.extensions.ReloadActionResolver</param-value>
  </init-param>
</filter>

4. Um, how about something easier, just to try it out?

You can easily take Stripes-Reload out for a spin if you have Apache Ant installed.

5. How does it work?

Stripes-Reload is a set of Stripes extensions that augment the default factories for Action Beans, Type Converters, Formatters, and Resource Bundles. An Interceptor handles reloading the JSTL resource bundle.

IMPORTANT: Stripes-Reload includes a custom ActionResolver, TypeConverterFactory, FormatterFactory, and LocalizationBundleFactory. Therefore, if you already have your own custom implementation of any of those factories, you will not be able to use the Stripes-Reload version unless you temporarily make your custom implementation extend the Stripes-Reload implementation. In that case, do not add org.stripesbook.reload.extensions to Extension.Packages; have your custom implementation be loaded instead.

6. Jetty, fine, but what about Tomcat?

There are several ways to set up a web application with Tomcat. One way that works well with Stripes-Reload is to set up a context file in $CATALINA_HOME/conf/Catalina/localhost/your-web-app.xml. For example:

stripes-reload-example.xml
<!-- Put this file in
$CATALINA_HOME/conf/Catalina/localhost/stripes-reload-example.xml -->
<Context docBase="/path/to/stripes-reload-example/web">
</Context>

7. License?

Apache License, Version 2.0

8. What next?

Please send your comments to Frederic Daoud: xf2697 @_AT_@ fastmail %_DOT_% fm