public class ShutdownTracker extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ShutdownTracker.ShutdownException |
| Constructor and Description |
|---|
ShutdownTracker() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
attemptRetain()
Attempts to retain the the resources.
|
StandardMBean |
mbeanProxy(Object target) |
Object |
proxy(Object target)
Creates a dynamic proxy that implements all the interfaces of the target object
and which retains/releases this ShutdownTracker before/after method invocations
against the proxy.
|
void |
release()
This method should be called after a resource is no longer used.
|
void |
retain()
This method should be called before the resource is used.
|
void |
shutdown(Runnable onStopCallback)
Marks the resource as being in a shutdown state.
|
void |
stop()
Calls
shutdown but waits for the shutdown to complete before
this method returns. |
<T> T |
use(Callable<T> callable)
This is a helper method which calls
retain/release before and after
a callable is called. |
public void retain()
ShutdownTracker.ShutdownException - once shutdown has been called.public boolean attemptRetain()
public void release()
IllegalStateException - if an unbalanced number of release() calls are done in respect to retain() calls.public <T> T use(Callable<T> callable) throws Exception
retain/release before and after
a callable is called.T - callable - Exceptionpublic void shutdown(Runnable onStopCallback) throws ShutdownTracker.ShutdownException
onStopCallback will
be run possibly after this method returns.onStopCallback - if not null will be run onceShutdownTracker.ShutdownException - if shutdown has been previously called.public void stop()
throws ShutdownTracker.ShutdownException,
InterruptedException
shutdown but waits for the shutdown to complete before
this method returns.ShutdownTracker.ShutdownException - if preciously shutdown.InterruptedException - if this thread is interrupted before the shutdown completes.public Object proxy(Object target)
target - public StandardMBean mbeanProxy(Object target) throws NotCompliantMBeanException
NotCompliantMBeanExceptionCopyright © 2011–2014 Red Hat. All rights reserved.