… tips on Apache JackRabbit configuration for Test Driven Development.
As AJ mentioned, we are currently working with Apache JackRabbit for an internal project. It has been an interesting voyage of discovery, with some very interesting stops along the way. One of the first steps was to build some tests around the JCR. I started with some simple exploratory tests around the API. These helped build my understanding of the JCR and how it works.
The next step was to begin really working out our persistence API with TDD. As a part of this, I wanted to be able to have a predominantly memory based repository to work with. This is possible to do, as per the attached memoryRepository.xml file.
The key is to use a org.apache.jackrabbit.core.fs.mem. MemoryFileSystem for all file system elements, and a org.apache.jackrabbit.core.persistence.mem. InMemPersistenceManager for all persistence manager elements. Unfortunately, with the attached config the file system is still used to store Lucene search indexes. This means that the file system is still used, and needs to be cleaned up in the tests.
The attached JcrRepositoryTestBase.java file has the setup and teardown code that handles the cleanup of the search index directories. This combination of code combines to allow the 35 JCR tests that we have run in about 10 seconds, and gives 100% coverage of all non exception handling code.
The first rule of Enterprise Java Development is:
any unexpected behaviour is caused by a classpath problem
Todays instance of this rule is a particularly fun one, given the line of code that exposed the problem.
I am using Apache Jackrabbit as an embedded JCR repository, mostly following the Jackrabbit embedded mode instructions. I saw mostly because the Jackrabbit website doesn't actually match the 1.3 released version of JackRabbit (this is most annoying when following the "First Hops", but that is a digression).
So I've got a nice little webapp with an embedded repository that is accessed via JNDI. The repository is responsible for shutting itself down which it does via a shutdown hook (BindableRepositories do this). Unfortunately the shutdown hook gets called after the web app class loader has started unloading, and things are beginning to cleanup. The first symptom of this problem is a null pointer exception when logging a message. After isolating that the log message (in org.apache.jackrabbit.core.RepositoryImpl.doShutdown) really was causing a NPE, I commented out he line of code, redeployed and confirmed the nasty problems, getting the following exception:
INFO: Illegal access: this web application instance has been stopped already. Could not load org.apache.commons. collections.map.AbstractReferenceMap$ReferenceValuesIterator. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
So while I am not yet in a position to report a fix this problem, I have been able to isolate it, and identify yet another instance of the first rule of enterprise development.
[update – as per the comments – in recent 10.6 releases the best way to remove things from the sidebar is to click drag the folder away then push the cmd key before letting go of the mouse]
[update 2 – fixed typo]
The OSX Finder Sidebar is pretty cool. It lets you have a list of favorite folders that you can easily navigate to. From time to time one wants to update the list to reflect the current things being worked on. In a recent cleanup of my sidebar, I had more pain that I wanted to face, but was able to sort out where the preferences are maintained, and wanted to make it easy to work out in the future.
It’s actually pretty straightforward…
~/Library/Preferences is where user preferences are kept. So open up a terminal and type cd ~/Libary/Preferences to get to the preferences directory
Then type find . -name *sidebar* in directory, to search for sidebar preferences. You should see the plist: com.apple.sidebarlists.plist.
Finally type open com.apple.sidebarlists.plist to open up the property list editor, which makes it is easy to then navigate through the tree and remove items. Finder only loads the properties when it is first started, so you will need to reboot to see the changes take effect.
Open Source projects are known for dodgy websites, and rubbish documentation. I was overjoyed to see a project that got it right (URL Rewrite Filter). There are a number of things that I really appreciated with this site, and in the hope that people might take notice, I’m going to list the good bits here.
The landing home page has a nice concise description of what the project is all about. When I get to the front page, I can read the overview of the project, and get an understanding of what problems it was created for, and the goals of it. The front page told me enough to want to see more, but didn’t overwhelm me. I got a good feeling from the front page.
The other nice thing about the front page is the navigation structure. The side navigation bar provides the links which I am most interested in. One click to get to a download link (which has a direct link to the files). One click to the source code page (with instructions on svn access via http and the commandline). One click to the documentation. One click to get to the community support.
The documentation is excellent, and provides a good baseline for what documentation of a project this size should look like.
There are good examples of what the configuration file looks like, annotated in a way that makes it easy to understand what the code is there for.
The documentation provides a good reference for how to do the configuration.
It is a great site and provides a good example of what most open source project websites should look like.
Making the browser location work like a command prompt is a good goal for any web application, and is possible for any J2EE web framework, even Struts 1.
To do this, having Rails style friendly urls is required. Traditionally J2EE frameworks and applications have not done a good job of providing friendly urls. It is easy to wander around the net and guess at what framework people used by the urls (e.g. anything .do is probably struts, .action’s are probably webwork etc.)
Of course one doesn’t have to be tied to this world. Pretty much anything is possible with Apache and mod-rewrite. This is handy when you are behind Apache, but that isn’t always the case. From time-to-time you may want to dot his completely within your J2EE application, making it independant of where you are running. The Servlet spec is powerful enough to make this possible, but for the lazy (like me) it is nice to know that someone has already done the hard work. The URL Rewrite library provides a filter which does the heavy lifting for you. There is a simple XML configuration file, which provides a rich language for customising your redirects using the Java Regex library, or a familiar directory traversal wildcard style syntax.
The library makes it possible to easily map urls like: products/1 to products.do?productId=1 or from: /australia/queensland/brisbane to: worldMap.jspa?country=australia&state=queensland&city=brisbane. There is a rich syntax for specifying the url rewrite conditions, as described in the comprehensive manual, and shown in the samples.
First I apolagise to all the hard core technical and Java people for making you read the title of this post. I know that church related things are pretty off topic for this blog, but I just found a really awesome SAAS web-based application that I had to talk about.
Almost all churches use CCLI (Christian Copyright Licensing International) to handle their copyright requirements. It is a pretty good service that centralises the management of copyright for music. I was looking at some software to help make the data projector at church run better (EasiSlides looks promising), when I went across to the CCLI site. They have released the coolest addition to the standard CCLI offering, SongSelect. Song Select is a great resource that provides online access to the CCLI songs including all the features you would hope for (like chord charts, lyrics, a music player and automatic transposition of songs). I was initially just looking for something to help me get the words into a form suitable for data projection, but this looks like a product which will be much more useful.
Technologywise, SongSelect is running as a Flash App. and is just all round cool. It is stuff like this that gets me excited. It's really IT that helps makes peoples lives work better. Even if I wasn't a committed Christian (and I am), this would be cool, because it does everything that a bunch of people need it to do, and makes peoples lives better and more fun.
I have been working hard at developing an understanding of what it means to be a product manager how to do this. A part of the role has been to step in as an XP customer. Recently I had a great IM conversation with Dan North about what the role is all about, and how to best do the job. Dan was my XP coach when I was working on a project in London, is the father of BDD, one of the lead developers behind JBehave, and RBehave and an all round great guy.
Here are some of the highlights of what Dan had to say:
Focus on your outcomes.
Work out what it is you want to achieve, and how much you think that's worth.
Everything else is detail. If the project goes "over budget", it just means you didn't predict the future. As long as you're within your comfort zone for the benefit you're going to get then you're still ok.
Likewise the feature list is just detail as long as you and the development team are on the same page
The most useful thing you can do is inspire the developers with your vision. Ideally find a way of sharing any success, so they feel vested in the outcome
Try to stay focused on the "what". As a techie, you will be really tempted to get involved in the "how",but you have to trust the team to do the right thing. Once you let go of the technical detail you can really get into "character" as a product manager!
A thought for World Environment Day.
One of the side effects of having a Dad who is a professor is that he comes up with some pretty profound thoughts from time to time.
Recently he made the prediction that the next generation (my sons generation) will be called Generation P, as concern for the planet will be the biggest issue for the generation.
Warning: if you are looking for an angry rant you won't find it here, instead this is a article about a truly good manager.
Like most people who have been in IT for as long as me, I’ve worked with some pretty dodgy management over the years. There have been times where I was sure Scott Adams was sitting in my cube farm, stealing ideas for dilbert.
I came to Ephox knowing that this wouldn’t be the case. I came knowing that I was going to be working for a good manager, Brett. Brett takes management, leadership and people seriously, as you can see in his recent blog post about a leadership course he is attending. Here he talks about what he has been learning about management and leadership, and how much he already understands and implements. You may read it, and think that he is perhaps self-deluded, but as someone who has been working for Brett, I can vouch for the fact that this isn't the case. Brett really does get people management. He understands the importance of putting people over process, and it makes a huge difference. It is his valuing of people that played a key part of my wanting to come to Ephox in the first place, and makes being a part of his team great.
Another thing that Brett does well is keeping commitments. In a recent InfoQ article on agile, there was the quote: ”…one of the quickest ways to take the wind out of a person’s sails is to break a commitment…”
I can’t think of a single commitment that Brett hasn't worked really hard to keep. He does well at making the right commitments, and sticking by them. One real instance of this that really sticks out in my mind was when I was nearing the end of my time in support. I could see that there might be value in me holding off transitioning (and I was willing to do so), but Brett stuck with his word, and made sure that I was able to transfer to development. It was great that Brett put in the work to ensure that this happened, and this commitment help keep my motivation high.
Brett spent time working on his management skills, and I really think this investment has paid off. Brett does really well at leading his team of developers, and creating an environment where we want to be. Having a good engineering manager is going to be a key part of helping Ephox to grow, enabling us to hire and keep good engineers.