ISPN-4561 CacheManager.stop with indexing to Infinispan fails

https://issues.jboss.org/browse/ISPN-4561

As discussed, introduced a graph to store cache dependencies and enforce it at stop time, plus an API to interact with that. Query will register cache dependencies accordingly. Backporting should be straighforward.
Reminder: the Directory doesn't necessarily use the LOCKING cache, that depends on the LockFactory being setup.
I guess you're assuming we know how it's being setup, but I think this assumption isn't future proof.. 
(Not sure if this is a problem)