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.
@Sanne The problem with the counter is that we don't want to block `cacheManager.stop()` until the user/modules release their caches. So you have to compromise, and potentially break the ordering.

We could add a `userWantsItStopped` flag on each node in the dependency graph, and on each `cache.stop()` try to stop any other cache that has the flag and no longer has any dependents. But I agree it's overkill - all we wanted was to define a stopping order during `cacheManager.stop()` so we could keep the behaviour of `cache.stop()` as it is.