Developer
Spring Surf meets Clojure
May 23rd

For those who missed it, some time ago the Alfresco guys donated their Surf Platform to SpringSource, giving birth to the now-called SpringSurf, which is thereby described as:
a view composition framework for Spring MVC that plugs into your existing Spring applications. It provides a scriptable and content-centric approach to building web applications.
I’m not going to introduce you how to use this yet-another MVC framework, but Michael Uzquiano provided an awesome blogpost, in case you were interested into learning more about it.
Part of the job of this Spring Surf framework is to provide an easy to use web scripting framework, REST like, that enables you to easily put together a View and, optionally, a Controller to implement a web API, provide them in the classpath together with a small XML descriptor, and your REST API is deployed right away. In the SpringSurf parlance, this is called called WebScript. Again, technical insights about the framework are better explained elsewhere, so no repetitions here. What I think is cool about Spring Surf, and I’m here with you to discuss, is it’s multi-language focus: web script Controllers can be written in Javascript, PHP or Groovy right out of the box, allowing you to choose whichever language you prefer. Moreover, if you just peek at Spring Surf source code, plugging in support for new languages doesn’t look so hard, so I decided to challenge myself and write support for Clojure backed webscripts. You can find the result of my efforts on github, with a sample webscript that proves the concept.
Following the webscript framework praxis, a model map object is passed around that acts as a container for whichever result your computation will produce, that will at the end handed over to a view rendition engine, Freemarker in our case, to build the resulting document. Webscripts are intended to support a number of different output formats, from JSON to XML to plain text, so being generic here is not an option.
Anyway, the first thing you usually do is to populate the model map with a number of objects that will be needed by the rendering engine to build the response. To support this use case, this first implementation of the Clojure backend for Spring Surf webscripts expects your Clojure “script” to yield a map, in Clojure sense. This map will be then forwarded to a Freemarker template and used to build a webpage or whatever the user asked for, i.e. this controller:
(ns web.script.test)
{:foo "bar"}
and this freemarker template:
foo: ${foo}
will provide “foo: bar” back to the client.
This is just an experiment at the moment, and far from being production-quality stuff. Still, it has been instructing to build a Java-to-Clojure integration, and nonetheless it might come in handy when I’ll be trying to put more Clojure in my working life.
(bye)
Handling Microsoft Windows NTP sync
Apr 23rd

This post should raise some eyebrows around, as I’m advocating Linux since ages and I’m not at all into Microsoft stuff for the 99.99% of my time. This story comes out of that (usually negligible) 0.01%.
Why bother with NTP on MS Windows?
The Alfresco implementation I’m working on has to integrate with a fully MS-powered environment, with a Domain Controller pulling the strings of network entities such as users and hosts. As the customer has strict security requirements, no remote access can be granted to their intranet, and since their offices are a bit far away from mine, we decided to replicate their environment locally, providing the minimum set of components such as
- a domain controller (WinServer 2k8)
- a domain host (WinXP Pro SP2)
- the Alfresco server (RHELv5.4)
I was able to build up the whole replicated environment, with a relative limited effort, using virtual machines to host all the different operating system on my laptop. I was so happy that everything worked almost at the first shot that I almost died when it all went wrong after the first reboot of the VMs: I couldn’t log anymore on the WinXP box!
It turned out that all clocks drifted away, making Kerberos auth checks fail because of replication attacks protection. Looked like it was time to strengthen my Win-fu and configure NTP in a proper way. This is what I learned.
WinServer2k8 and clock management
If there’s one thing I enjoyed out of all the time spent on these tasks, the prize goes definitely to w32tm: I had to deal with Windows, and there were no windows involved! As usual, whenever I’m typing into a command line, I feel at home. I’m actually writing this whole blog post to take note of the tricks I learned around w32tm and NTP clock sync. Here we go:
- Configure NTP servers
w32tm /config /manualpeerlist:europe.pool.ntp.org /syncfromflags:manual /reliable:no /update
- Query NTP servers
w32tm /stripchart /computer:europe.pool.ntp.org /samples:5 /dataonly
- Resync clock
w32tm /resync /rediscover
- Allow resync in case of huge drifts
If your clock drifted too far away Windows will refuse to sync. In order to disable such check you have to import the following changes (write them in a reg-keys.reg file and double click it):Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config] "MaxNegPhaseCorrection"=dword:ffffffff "MaxPosPhaseCorrection"=dword:ffffffff
That’s it for now. I hope this will come in handy to somebody else, since I’ll try to avoid any more contact with the Microsoft stacks as long as possible, since without grep, find, awk, sed, vim I feel as uncomfortable as this.
Amsterdam Clojurians meeting #4 – Dojo style
Apr 14th

Today the fourth meeting of the Amsterdam Clojure user group was held at the now usual Sourcesense offices venue in Amsterdam.
It has been probably the most successful one until now: thanks to some newcomers we had the most participated event ever with 10 nerdy, awesome geeks sitting together to discuss about nerdy, awesome stuff with lots of parenthesis.
As previously proposed by Jeff Rose, we started thinking about improvements we could provide to the standard Clojure REPL, deciding for colorful messages for the doc function. Sam Aaron proposed then to follow a dojo-like approach, with a single laptop connected to a projector where everybody has the chance to step in and do some coding while everybody else discuss possible approaches and alternatives.
The resulting code from this session is available on github. It does just a simple thing, it provides a way to override the default doc behavior in order to make use of our custom, colorful implementation of print-doc. And even if it doesn’t look like rocket science, I can guarantee that being there and looking at how we came up with that, from some impressive vim-fu showed by Michiel de Mare to the clever and clean code provided by Remco van ‘t Veer, was indeed a lot of fun!
If all this sounds interesting to you, go and checkout the group mailing list or just show up at the next meeting, second Wednesday of each month at the Sourcesense office.












