public abstract class DOFListenerInvoker
extends org.opendof.core.internal.util.AsyncRunnable
DOF.UncaughtExceptionListeners
and to DOF.Log at level ERROR.
Wherever you might write code to guard a user callback like this:
threadpool.submit(new Runnable() {
public void run() {
try {
userCallback();
} catch (Exception t) {
//Handle uncaught exception
}
}
});
Do this instead:
threadpool.submit(new DOFListenerInvoker(core, "MyListenerInterface.userCallback") {
public void invoke() {
userCallback();
}
});
Of course, you can always use it synchronously like this:
new DOFListenerInvoker(core, "MyListenerInterface.userCallback") {
public void invoke() {
userCallback();
}
}.run();
See tryCallbackThrow() and tryCallbackErrorException() for additional usages.| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getName()
Get the name of the Runnable.
|
abstract void |
invoke()
Implement the call to the application behavior in this method.
|
void |
run()
Calls
invoke(), wrapping it in a try/catch. |
void |
tryCallbackErrorException()
Calls
invoke(), wrapping it in a try/catch. |
void |
tryCallbackThrow()
Calls
invoke(), wrapping it in a try/catch. |
public final void run()
invoke(), wrapping it in a try/catch. Any exception caught here will be redirected to the
DOF.UncaughtExceptionListener.public void tryCallbackThrow()
throws java.lang.Exception
invoke(), wrapping it in a try/catch. Any exception caught here will be redirected to the
DOF.UncaughtExceptionListener.
If it's an exception (not an error), the exception will be rethrown after handling.java.lang.Exception - The caught exception is rethrown.public void tryCallbackErrorException()
throws DOFErrorException
invoke(), wrapping it in a try/catch. DOFErrorException is allowed and will be rethrown.
Any other exception is caught here and will be redirected to the
DOF.UncaughtExceptionListener.
If it's a DOFException, the exception will be rethrown. All ***************************DOFErrorException - The caught exception is rethrown.public final java.lang.String getName()
org.opendof.core.internal.util.NameableRunnablepublic abstract void invoke()
throws java.lang.Exception
java.lang.Exception - Any exception is allowed by implementation of this method.