DOFListenerInvoker ClassOpenDOF Object Access Library
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
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.

Inheritance Hierarchy

SystemObject
  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

  NameDescription
Protected methodDOFListenerInvoker
Create a DOFListenerInvoker.
Top
Methods

  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodgetName (Overrides AsyncRunnable.getName.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodinvoke
Implement the call to the application behavior in this method.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRun
Calls invoke() , wrapping it in a try/catch. Any exception caught here will be redirected to the UncaughtExceptionListener .
(Overrides AsyncRunnable.Run.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodtryCallbackErrorException
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

Public methodtryCallbackThrow
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.

Top
See Also

Reference