Wraps application behavior in a Runnable and a try/catch
that will redirect the exception to the registered
UncaughtExceptionListener
s
and to DOF.Log at level .
Wherever you might write code to guard a user callback like this:
ERROR
Do this instead:threadpool.submit(new Runnable() { public void run() { try { userCallback(); } catch (Exception t) { //Handle uncaught exception } } });
Of course, you can always use it synchronously like this:threadpool.submit(new DOFListenerInvoker(core, "MyListenerInterface.userCallback") { public void invoke() { userCallback(); } });
See tryCallbackThrow() and tryCallbackErrorException() for additional usages.new DOFListenerInvoker(core, "MyListenerInterface.userCallback") { public void invoke() { userCallback(); } }.run();
Inheritance Hierarchy
AsyncRunnable
org.opendof.core.oalDOFListenerInvoker
Namespace: org.opendof.core.oal
Assembly: dof-oal (in dof-oal.dll) Version: 7.0.1.2
Syntax
C#
public abstract class DOFListenerInvoker : AsyncRunnable
The DOFListenerInvoker type exposes the following members.
Constructors
Name | Description | |
---|---|---|
![]() | DOFListenerInvoker | Create a DOFListenerInvoker. |
Methods
Name | Description | |
---|---|---|
![]() | Equals | (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | getName | (Overrides AsyncRunnable.getName.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | invoke | Implement the call to the application behavior in this method. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | Run |
Calls
invoke()
, wrapping it in a try/catch. Any exception caught here will be redirected to the
UncaughtExceptionListener
.
(Overrides AsyncRunnable.Run.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | tryCallbackErrorException |
Calls
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
UncaughtExceptionListener
.
If it's a DOFException, the exception will be rethrown. All
|
![]() | tryCallbackThrow |
Calls
invoke()
, wrapping it in a try/catch. Any exception caught here will be redirected to the
UncaughtExceptionListener
.
If it's an exception (not an error), the exception will be rethrown after handling.
|
See Also