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.
|
byte[] |
getRawResult()
Returns the
result as an byte -array. |
com.softwareag.mobile.runtime.comms.Response |
getResponse() |
java.lang.String |
getResult()
Returns the
result as a String . |
java.lang.String |
getResult(java.lang.String encoding)
Returns the
result as a String with s specific
encoding. |
int |
getResultCode()
Returns the
resultCode as an int -value. |
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 final int getResultCode()
IOperation
resultCode
as an int
-value.getResultCode
in interface IOperation
public void execute()
IOperation
execute
in interface IOperation
public void setCacheHandler(IOperationCacheHandler cacheHandler)
IOperationCacheHandler
that should be used for this
operation.public final java.lang.String getResult()
IOperation
result
as a String
. byte
-result from IOperation.getRawResult()
into
a String
by using UTF-8 as encoding. Call
IOperation.getResult(String)
under the hood.getResult
in interface IOperation
IOperation.getResult(String)
public final java.lang.String getResult(java.lang.String encoding) throws java.io.UnsupportedEncodingException
IOperation
result
as a String
with s specific
encoding.getResult
in interface IOperation
java.io.UnsupportedEncodingException
public byte[] getRawResult()
IOperation
result
as an byte
-array.getRawResult
in interface IOperation
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()
getResponse
in interface IOperation
Response
object for this operationpublic void setResponse(com.softwareag.mobile.runtime.comms.Response resp)