Cruising with clouds

October 3 2011

for all you monitoring guys out there, here’s a bunch of new stuff which I’ve recently added to Cruise-monitor. ready? here it comes:

  • Windows support (see documentation here)
  • CruiseControl.NET support, both for RSS feed (not available by default) and HTML project report page (see documentation here)
  • Jenkins support (minor differences with Hudson)
  • Rake tasks for configuring and monitoring
  • build server on Amazon EC2 (dog-feeding anyone?!)
  • Rake task for deploying configuration on EC2 and restart services
  • wiki documentation pages under revision control as well

porting to Windows has been tricky, because (no, you can’t guess it) tests where failing! after playing with sockets library a bit, it turned out to be a “missing” loop statement (while running fine both on MacOs and Ubuntu). even more, don’t forget the obvious filesystem tmp path! then, Microsoft Speech API was good enough to be wrapped by a script, in order to emulate say command.

support for CruiseControl.NET was funny to develop, because I had to force a little bit the code to host HTML parsing as well. in the end, relying on HTML and CSS styles is a bit too fragile, because, you know, HTML is going to be drastically changed. anyway, enabling RSS publisher you can start monitoring an RSS feed.

then, all the EC2 stuff. I’ve signed for a free micro instance, which seems to be good enough for my purposes. currently, CruiseControl.rb and Jenkins are running, with an Apache frontend acting as a proxy. all configuration is under revision control, deploy is completely performed with Ruby, as a Rake task, thanks to the net-ssh client and this nice wrapper script, which sends a bash script to be executed remotely.

I’ve also registered the free domain at, configured for the EC2 instance via DNS, thanks to the free service. www domain is served by the Apache frontend as a permanent redirection to Cruise-monitor wiki pages on GitHub.

finally, all documentation is versioned as a separate git repository, and eventually tested locally with Gollum. if only I could refer images as relative URLs instead of absolute ones..

anyway, I think it’s enough to say Cruise-monitor is evolving, and to be fair I’m really having fun. I’m not a tech zealot, so my appreciation of all the Ruby/Rake/Gem ecosystem is genuine. some SSH, Ubuntu and bash magic and it’s ready to serve!


Imagine all the pictures

January 26 2011

if you’re like me addicted to drawing, you probably think pencil and paper (whiteboard optional) are the most powerful communication tools. so, here’s a tip for getting images ready for your digital media, like blog posts and presentations: simply sketch lines on paper, take a picture, then trace it.

here’s the recipe:

  1. use a digital camera for taking a picture of your sketches, and copy image to your PC/laptop
  2. convert image to grayscale, crop it and adjust contrast/brightness to sharpen dark lines on white background. any image processing tool is good (Seashore on MacOS, GIMP on Linux and Windows)
  3. convert image to .pbm, as required by next step, with ImageMagick
  4. trace image, with Potrace (also available with MacPorts on MacOS)

result is a sharp, vector image, from which you can easily create illustrations as PNG/JPG images, targeting media resolution (150/300 DPI) without quality loss and with a whiteboard/clipart taste!

original image

resulting image

finally, here’s an handy bash script to apply steps 3 and 4 in one shot, which I’m using these days for presentations. enjoy!

echo "processing $1.."
convert $1 $1.pbm
potrace $1.pbm -o $
rm $1.pbm

Video from IAD 2010

December 9 2010

just updated personal page adding links to both slides and video for the presentation I had at the last Italian Agile Day 2010. enjoy!

these last six months have been incredibly full for me, i’ve learnt so many technologies and technical stuff: RubyOnRails web application development (and a bit of S3 cloud deploying), Hippo CMS 6 and Cocoon pipelines, and now Day CQ stack, which means JCR and Jackrabbit, Sling RESTful web framework, and OSGI bundles with Felix. oh my!

yep, i’m currently working for a big TLC italian company, developing their internal portal based on CQ5. i was completely new to content-repositories and web content management, but i got it quickly: it’s a different paradigm, data are modeled around resources, not around relations (as with relational databases).

btw, what i want to show is my journey with CQ stuff, and how our development approach has grown during the last weeks (and where it’s going). beware: there’s a lot of technical stuff (maven, Day CRX, Apache Sling, Apache Felix); i won’t explain everything in detail, so i’m referring to documentation and other blog posts.

so, first of all, start reading CQ tutorial on “How to Set Up the Development Environment with Eclipse”: please, spend almost one hour following all steps, even boring ones, like grabbing jars from CRX repository and putting them manually into local maven repository. in the end, you’ll have two projects (ui and core), one page with template (manually created and edited), executing a component as JSP script (imported through VLT), which uses “domain” logic provided by a plain old Java class (from core project). that’s a lot of stuff!

then, let’s enter the magical world of CQDE, a customized (old version of) Eclipse, which provide access to remote content (via webdav) from within an IDE, so that you can edit, compile and debug code as it was stored locally (but it isn’t). at first, it seems a lot better than VLT-ing from commandline; but soon you’ll miss it: versioning, and sharing code with others. even if it’s not clear in the tutorial, ignoring VLT specific files let Subversion version also content stored in src/main/content/jcr_root. that’s not always funny, like manually merging conflicts on XML files, but it’s really a lot better than blindly edit code with CQDE, with no way back! also, sometimes i’ve found much more easier editing pages as XML files than using WCM editor (CQ authoring tool).

ok, relax, take a deep breath, and think about what you’ve done so far. do you like it? are you comfortable with this? well, i wasn’t; i missed my IDE-based development, checking-in and out code, running automatic tests all the time. the good news is we can do better than this, the bad news is we’ll still miss something (so far, red/green bars for UI). to recap, we can choose from:

  1. remote coding and debugging, with CQDE: no “native” versioning, VLT can be use as a “bridge” to Subversion
  2. local coding, with any IDE (eg Eclipse): still can’t compile JSP files, VLT used to deploy UI code

next step is (well, i’m a bit afraid, but time has come)… deploy an OSGI bundle with maven, with both UI code and initial content to put on repository.

step one: compiling JSP files locally. ingredients: JARs as local maven dependencies and sling maven jspc plugin.

i could not find any public Day maven repository (and it makes sense, from a business point of view), but as the tutorial shows, everything we need is already available from CRX. so, it takes long, but referring to the /libs/xyz/install convention and doing searches via CRX explorer you can come up with something like this:


function grabDependency(){

  wget --user=admin --password=admin $JAR_URL
  mkdir -p $REPOSITORY_DIR

cd /tmp; rm -rf deps; mkdir deps; cd deps

grabDependency \
  http://localhost:4502/crx/repository/crx.default/libs/commons/install/day-commons-jstl-1.1.2.jar \
  com/day/commons/day-commons-jstl/1.1.2 \

# ... grab other jar files

then, let’s add JSPC plugin to the maven build chain, and CQ and Sling dependencies (see attached file with sample code). this is a simple example; you’ll probably need to override plugin’s sling jar dependencies with versions used by application code!


moving JSP code into src/main/scripts (under apps/myApp subfolder) should be enough to have maven build (mvn clean compile). just remember to grab global.jsp from CRX and put it under src/main/scripts/libs/wcm folder. Eclipse also will compile (regenerate project files with mvn eclipse:eclipse), but it needs another copy of global.jsp into /libs/wcm (i know, it’s silly; i’ll check this next time).

step two: packaging an OSGI bundle with UI code and content nodes. ingredients: Felix maven bundle plugin.

the key concept for me was understanding what to put into the bundle. i was used to have JSP files on CRX under /apps node, editing nodes properties such as jcr:primaryType (cq:Component, cq:Template and the like) and jcr:content. deploying application as OSGI bundle it’s slightly different: code is available as bundle resources (from the bundle itself), while only property nodes are copied from bundle to CRX repository, as initial content. this separation was not clear to me in the beginning, but it now makes sense (even if less duplication would be nice, for example in content structure).

so, we should create a bundle with:

  • included resources: all required resources (maven resources and src/main/scripts folder) to be later referred
  • bundle resources: .class and JSP files
  • initial content: node properties, as JSON files (i decided to put them into src/main/resources, under CQ-INF/initial-content subfolder)

more details are available on the Sling website and on this blog post.

so, let’s add Felix bundle plugin to maven (remember to declare project bundle packaging with <packaging>bundle</packaging>):


          included resources folders (to be later referred):
          maven resources and JSP files

          resources available from within bundle
          (not available as CRX nodes):
          compiled .class files and JSP files.

          content initially copied into CRX nodes:
          properties as JSON descriptors
        CQ-INF/initial-content/apps/myApp/; overwrite:=true; path:=/apps/myApp,
        CQ-INF/initial-content/content/sample/; overwrite:=true; path:=/content/sample

this should be enough to create a package with mvn clean pakage. we’re almost done..

step three: installing the bundle. ingredients: maven sling plugin.

with CQ there are two ways to install a bundle: put it under /apps/myApp/install folder or using the Felix console. i choose the latter, which turns out to be a plain POST request to the console URL. anyway, we can hook the maven build chain with the Sling plugin, this way:


just type mvn install and we’re done.

that’s it. a lot of setups, expecially if, like me, you’re new to maven and OSGI. anyway, i’ve written this mainly for later reference and to share thoughts with colleagues. i’ve shown three approaches to develop with CQ, tested in my daily work on the last month. in my view, deploying OSGI bundles is the best one, so far; it’s a trade-off between ease of use while debugging (yep, no UI automatic tests yet) and development lifecycle (versioning, building, packaging). i hope to gather much more info next year, and probably something will be easier! next step will be setting up automatic tests for JSP files, using Koskela’s JspTest tool.

sample code is here: please, follow README and have fun.

well, happy new year to everyone!