public abstract class AbstractSynchronizableOperation extends java.lang.Object implements IOperation
AbstractSynchronizableOperation
implements all necessary
members from it's super class IOperation
and provides the possibility
to notify all registered listeners in a thread-safe manner.
All delegates will be called from the thread, which creates this operation.
So the execution itself can run asynchronously. To reach this goal, the
operation holds an internally created nUIObject
and fires events by
using nUIController.eventListenerQueue(nUIObject, int)
.
The execute()
method can be influenced by the usage of an
IOperationCacheHandler
which provides methods to hook into the
execution. Furthermore the IOperationCacheHandler
is an
IOperationDelegate
and it is called as the first delegate in
notifyOperationFailed()
and notifyOperationFinished()
.
Subclasses must call fireEvent(int)
to synchronized notify all
delegates. Possible arguments are OperationNotifier.FINISHED
and
OperationNotifier.FAILED
correspondent to the methods described by
IOperationDelegate
.
Subclasses must override internalExecute()
.
Modifier and Type | Field and Description |
---|---|
static int |
OPERATION_FAILED |
static int |
OPERATION_SUCCESSFUL |
Constructor and Description |
---|
AbstractSynchronizableOperation() |
Modifier and Type | Method and Description |
---|---|
void |
addOperationDelegate(IOperationDelegate delegate)
Adds the delivered
IOperationDelegate . |
void |
execute()
Executes this operation.
|
java.util.Enumeration |
getOperationDelegates()
Returns all registered operation delegates.
|
com.softwareag.mobile.runtime.comms.Response |
getResponse()
Returns the operation's response, containing information about the result
code and transferred data.
|
void |
removeOperationDelegate(IOperationDelegate delegate)
Removes the delivered
IOperationDelegate . |
void |
setCacheHandler(IOperationCacheHandler cacheHandler)
Sets the
IOperationCacheHandler that should be used for this
operation. |
void |
setResponse(com.softwareag.mobile.runtime.comms.Response resp) |
public static final int OPERATION_SUCCESSFUL
public static final int OPERATION_FAILED
public void execute()
IOperation
execute
in interface IOperation
public void setCacheHandler(IOperationCacheHandler cacheHandler)
IOperationCacheHandler
that should be used for this
operation.public void addOperationDelegate(IOperationDelegate delegate)
IOperation
IOperationDelegate
. If the same
IOperationDelegate
is already added, it will not be added again.addOperationDelegate
in interface IOperation
public void removeOperationDelegate(IOperationDelegate delegate)
IOperation
IOperationDelegate
.removeOperationDelegate
in interface IOperation
public com.softwareag.mobile.runtime.comms.Response getResponse()
IOperation
getResponse
in interface IOperation
Response
object for this operationpublic void setResponse(com.softwareag.mobile.runtime.comms.Response resp)
public java.util.Enumeration getOperationDelegates()