context.getUtils.getUserExecutor.isShutdown ||
context.getUtils.getIoExecutor.isShutdown
As far as I know (and I'd be interested to hear corrections from
everyone else on the list), there is certainly no *contract* that
would guarantee that this expression is true iff the context is closed.
What happens when a context is closed depends on which elements are
added to its Closer, and that can depend on the specific
implementation of the context (which is why I earlier asked about the
provider).
I can imagine, though (I haven't tested this) that some providers will
indeed shut down the user and/or IO executors when the context is
closed; a quick experiment, or looking at the contents of the
"methodsToClose" list [1] in your context's closer [2] should allow
you to verify this.
In that case, your suggestion should probably work well enough in your
case as an initial workaround. Until 1.7, at least, when the
userExecutor/ioExecutor helper methods will be removed.
You could also add a "flag" object of your own to the closer (after
getting the closer from ctx.utils().injector()), with a "close()"
implementation that sets the flag. You could then check the status of
the flag to determine if the context has been closed.
You're of course also highly encouraged to create a JIRA issue and
submit a PR for a more general feature to support this!
Hope this helps!
ap
[1]
https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/lifecycle/Closer.java#L36
[2]
https://github.com/jclouds/jclouds/blob/master/core/src/main/java/org/jclouds/internal/ContextImpl.java#L63