sgougi/play21-jackrabbit-plugin — pull request #1 by tjdett (2013-03-19 07:02:09+00:00)
Title: Adding graceful shutdown of the repository with the application

Without a `onStop` hook, the repository was reliant on the JVM terminating to shutdown.

Unfortunately, that's not the way SBT (and Play on top of it) performs tests - it reuses the same classloader, leading to warnings like "[The repository home ... appears to be in use since the file named .lock is already locked by the current process](http://wiki.apache.org/jackrabbit/RepositoryLock)".

The implemented `onStop`:

* Uses reflection to find a `shutdown` command for the repository, and invokes it if found.
* Sets `DIRECTOR` to `null` again so that it is reinitialized by the next `Application`.