A tutorial on how to embed Neo4j in a java application recommends registering a shutdown hook like so:
Runtime.getRuntime().addShutdownHook( new Thread() {
// do shutdown work here
});
I'm wondering where the best place to put this code - or in fact any code that needs to run once when Spring starts. Is it simply a case of registering a bean with an init method and putting the code in that?
I'd be interested to know this and more specifically how others have registered a shutdown hook when using an embedded Neo4j in their Spring application.