Close hooks is an internal feature of Vert.x useful for creating components that are notified when a
Vertx instance is closed. It can be used for implementing automatic clean-up in verticles
feature, like for a Vert.x http server.
The contract for receving a close notification is defined by the
io.vertx.core.Closeable interface and
close(Handler<AsyncResult<Void>> completionHandler) method:
Closeable instance can be registered to receive a close hook with the method
Context#addCloseHook registers a
Closeable instance to be notified when the context closes:
This is only valid for Verticles, when a Verticle is undeployed, its associated context is closed and the shutdown hooks are processed.
The component should still expose a
close in its API to allow the user to close explicitly the resource, this
method should call
Context#removeCloseHook to remove the hook.
VertxInternal provides the same operation to receive notifications when a
Vertx instance is closed.