55 Minutes

Welcome to the 55 Minutes blog.
55 Minutes is a web development consultancy in San Francisco building apps for design-led businesses and startups. On this blog we discuss the technology tools of our trade: Ruby on Rails, Django, Sass, OS X, and more.

Introducing SimpleCDN Part of the New fiftyfive‑wicket 3.2

Today I’m happy to announce the release of fiftyfive-wicket 3.2. The major feature added in this release is SimpleCDN, a simple way to enable static resources of your Wicket application to be proxied by a CDN, for example by Amazon Cloudfront. Here’s how it works.

First, some quick background: fiftyfive-wicket is our open source project where we maintain useful tools and suggest practical design patterns for the popular Apache Wicket Java web framework. We also bundle these tools and patterns as a nice Maven archetype that can be used to kickstart new projects. We released version 3.2 on Wednesday, January 25, 2012. Quick start instructions and Maven dependency syntax can be found in the fiftyfive-wicket README.

SimpleCDN uses Wicket 1.5’s request mapping system

The new SimpleCDN class in fiftyfive-wicket 3.2 is built on top of Wicket 1.5’s request mapper system, which (to oversimplify a bit) is how Wicket generates URIs and routes browser requests. In 1.5, an application or library developer can easily plug into this system to build enhancements that would have been prohibitively difficult in previous Wicket versions. If you aren’t familar with 1.5 request mapping, I suggest you take a look at the SimpleCDN source code to see exactly how this style of plugin is accomplished.

In a nutshell, SimpleCDN rewrites URIs that point to sytlesheets, scripts, and other static files that are normally served by Wicket. If you are familiar with Rails, it is very similar to the Rails action_controller.asset_host feature. Combine this with a reverse proxy cache like Amazon Cloudfront, and you’ll be up and running very quickly.

An example

Normally a CSS resource reference is rendered by Wicket like this:

/wicket/resource/com.mycompany.WicketApplication/test.css

With SimpleCDN installed, that resource reference URL is transformed into something like this:

http://age39p8hg23.cloudfront.net/wicket/resource/com.mycompany.WicketApplication/test.css

Installation is just a matter of adding a few lines to your Application#init.

public class MyApplication extends WebApplication
{
    @Override
    protected void init()
    {
        super.init();
        // Enable CDN when in deployment mode
        if(usesDeploymentConfig())
        {
            new SimpleCDN("//age39p8hg23.cloudfront.net").install(this);
        }
    }
}
gistfile1.java – View Gist

For more details, refer to the SimpleCDN Javadoc.

Other fiftyfive-wicket 3.2 changes

Along with SimpleCDN, fiftyfive-wicket 3.2 has been updated with Wicket 1.5.4, Spring 3.1.0, and Apache Shiro 1.2.0. You can refer to the full release notes. Visit our GitHub project to fork, report issues, or browse the source. You can also get in touch with us at opensource@55minutes.com if you have questions.

Learn more

comments powered by Disqus