Oftentimes languages such as Java are called “high ceremony” languages compared to languages like Ruby or Python. This refers to the fact that there’s generally a bit more plumbing involved in firing up a Java application – particularly a web application – than there is with the scripting languages.
Of course, Java is compiled (to byte-code at least), so it’s not quite a 1 to 1 comparison with a more interpreted language such as Ruby, but still, even in a “high ceremony” language it’s important not to get too high a “cycle time” for developers, IMO.
By “cycle time” I mean the time between making a change and seeing it working – either in a test, or, ideally, in a running application. Most modern IDEs made the cycle time for tests pretty darn low (and great tools like Inifinitest can take all the manual work out of it, no less), but to see a running application and be able to excercise your changes deployed in a container is a bit more of a grind.
That’s where a tool like Jetty can come in handy. Jetty is a lightweight web app container that can be easily added to your development cycle in place of a heavier-weight solution to allow you a faster cycle time, and, often, greater productivity and interactivity.
Especially in combination with it’s integration with Maven, Jetty can get your app deployed far faster than with other solutions. For most webapps, it’s just a matter of saying:
And you’ve got a container up and running with your app in it within a few seconds.
Jetty can even do a certain amount of “hot update”: modify a JSP (or even some code – although there are limits) and the running webapp is updated, and you’re able to test, edit… cycle away without the painful wait for a deployment any more often than necessary.
You can pass required system properties to your app via maven’s -D mechanism, and they’ll be available to your app:
mvn -Dsome.property=someValue jetty:run
And even control the port your application binds to on the fly (or via the handy jetty.xml file if you want to set it more permanently).
Jetty and maven also give you the ability to script, for example, if you need to run a test utility on your running webapp to ping a series of REST calls, for example, you can:
mvn clean package # Build the webapp<br />
mvn jetty:run & # start jetty, spawning it in the background<br />
java -jar mytestutility.jar # Run my test jar, which pings the URLs for all my rest services, maybe does performance checks, etc<br />
mvn jetty:stop # Stop the jetty instance we fired up in the background
Lightweight containers such as Jetty are just one way to help crank down the “cycle time” for developers, of course. Some other possibilities I’ll leave for a later entry.