public class AsyncRequestImpl extends HandleChain implements AsyncRequest, java.lang.Runnable
As some the mutable fields of this class can be modified by more than one thread, they are
marked as volatile
.
Modifier and Type | Field and Description |
---|---|
private java.lang.Object[] |
args
The procedure's arguments.
|
private boolean |
cancelled
Flag indicating that the async call has been cancelled.
|
private boolean |
complete
Flag indicating that the async call has completed (will be
false if the call was
cancelled. |
private boolean |
error
Flag indicating that the call was terminated with an ERROR condition.
|
private character |
eventProcedure
The name of the EVENT-PROCEDURE.
|
private handle |
eventProcedureContext
The context of the EVENT-PROCEDURE.
|
private java.util.List<AsyncRequestListener> |
listeners
List of listeners which need to receive notifications when the call is started or finished.
|
private java.lang.String |
modes
The modes for the procedure's arguments.
|
private handle |
persistentProcedure
The proxy procedure, if the remote call is for an internal procedure.
|
private character |
procedureName
The name of the target procedure.
|
private boolean |
quit
Flag indicating that the call was terminated with a QUIT condition.
|
private java.lang.Runnable |
request
A worker indicating what will be invoked.
|
private int |
requestId
The ID of the remote request being executed.
|
private RemoteInvocationResult |
result
The result from the remote call.
|
private handle |
server
A handle to the SERVER resource.
|
private boolean |
stop
Flag indicating that the call was terminated with a STOP condition.
|
private boolean |
valid
Flag indicating if the resource is valid.
|
name, nextSibling, prevSibling
instProc
Constructor and Description |
---|
AsyncRequestImpl(handle server,
java.lang.Runnable request,
character eventProcedure,
handle eventProcedureContext,
character procedureName,
handle persistentProcedure,
java.lang.String modes,
java.lang.Object... args)
Create a new async request resource, by specifying the attributes related to the async
call definition.
|
Modifier and Type | Method and Description |
---|---|
boolean |
_isCancelled()
Get the
CANCELLED attribute of this async request, as a Java boolean. |
boolean |
_isComplete()
Get the
COMPLETE attribute of this async request, as a Java boolean. |
(package private) void |
cancelled()
Called when the async call was cancelled by the user.
|
(package private) void |
complete()
Called when the async call has finished normally (not with a cancel).
|
(package private) void |
execute(boolean event)
Execute the async request.
|
java.lang.Object[] |
getArgs()
Get the arguments for this async requests.
|
character |
getEventProcedure()
Get the
EVENT-PROCEDURE attribute of this async request. |
handle |
getEventProcedureContext()
Get the
EVENT-PROCEDURE-CONTEXT attribute of this async request. |
java.lang.String |
getModes()
Get the parameter modes for this async request.
|
handle |
getPersistentProcedure()
Get the
PERSISTENT-PROCEDURE attribute of this async request. |
character |
getProcedureName()
Get the
PROCEDURE-NAME attribute of this async request. |
handle |
getServerHandle()
Returns a handle to the app server in which the procedure is ran.
|
protected boolean |
hasNameReadOnly()
As this resource supports the name attribute in R/W mode, return
false |
logical |
isCancelled()
Get the
CANCELLED attribute of this async request. |
logical |
isComplete()
Get the
COMPLETE attribute of this async request. |
logical |
isError()
Returns the state of the ERROR attribute
|
logical |
isQuit()
Get the
QUIT attribute of this async request. |
logical |
isStop()
Get the
STOP attribute of this async request. |
private void |
notifyListeners(boolean start)
Notify the listeners about the invocation request state (start or finish).
|
(package private) void |
notifyStart()
Notify all listeners that the async call is about to start.
|
(package private) void |
registerListener(AsyncRequestListener listener)
Register a new listener for notifications about the state of the async call.
|
protected boolean |
resourceDelete()
The async resource can be deleted only if it has been completed or cancelled.
|
void |
run()
Invoke the event procedure for this async request, if used.
|
(package private) void |
setError()
Mark this async call as having ended with a ERROR condition.
|
void |
setError(boolean value)
Setter for ERROR attribute.
|
void |
setError(logical value)
Setter for ERROR attribute.
|
(package private) void |
setQuit()
Mark this async call as having ended with a QUIT condition.
|
(package private) void |
setRequestId(int reqId)
Set the ID of this remote request.
|
(package private) void |
setResult(RemoteInvocationResult result)
Set the result from the
request execution. |
(package private) void |
setStop()
Mark this async call as having ended with a STOP condition.
|
(package private) void |
stop()
Stop this async request by sending the STOP condition to the remote side.
|
boolean |
valid()
Reports if this object is valid for use (has not been deleted).
|
delete, firstResource, firstResource, getHead, getNextSibling, getNextSibling, getPrevSibling, getPrevSibling, getPrivateData, getTail, hasName, hasNextSibling, hasParent, hasPrevSibling, hasPrivateData, interlink, isChained, lastResource, lastResource, moveInChain, name, name, name, readOnlyError, setHead, setNextSibling, setNextSibling, setPrevSibling, setPrevSibling, setPrivateData, setPrivateData, setPrivateData
getResourceType, id, id, implicitDeletion, instantiatingProcedure, invalidAttribute, setInstantiatingProcedure, type, unknown
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getNextSibling, getPrevSibling, getPrivateData, setPrivateData, setPrivateData
getResourceType, readOnlyError
id, id, unknown
private final handle server
private final character eventProcedure
private final handle eventProcedureContext
private final handle persistentProcedure
private final character procedureName
private final java.lang.Object[] args
private java.lang.String modes
private RemoteInvocationResult result
private volatile boolean complete
false
if the call was
cancelled.private volatile boolean cancelled
private volatile boolean quit
private volatile boolean stop
private volatile boolean error
private volatile boolean valid
private volatile int requestId
private java.util.List<AsyncRequestListener> listeners
private java.lang.Runnable request
public AsyncRequestImpl(handle server, java.lang.Runnable request, character eventProcedure, handle eventProcedureContext, character procedureName, handle persistentProcedure, java.lang.String modes, java.lang.Object... args)
server
- The server used to invoke the remote call. May be a SERVER
or the
SESSION
resource.request
- The request which will execute the procedure call.eventProcedure
- The event procedure name.eventProcedureContext
- The context of the event procedure.procedureName
- The name of the procedure to be invoked.persistentProcedure
- The handle to the proxy procedure to which the target procedure belongs. Will
be unknown if this is not a remote call.modes
- The modes for the procedure's arguments.args
- The procedure's arguments.public java.lang.String getModes()
public java.lang.Object[] getArgs()
public logical isError()
public void setError(boolean value)
public void setError(logical value)
public boolean valid()
valid
in interface WrappedResource
true
if we are valid (can be used).public handle getServerHandle()
getServerHandle
in interface Remotable
public logical isCancelled()
CANCELLED
attribute of this async request.isCancelled
in interface AsyncRequest
public boolean _isCancelled()
CANCELLED
attribute of this async request, as a Java boolean.public logical isComplete()
COMPLETE
attribute of this async request.isComplete
in interface AsyncRequest
public boolean _isComplete()
COMPLETE
attribute of this async request, as a Java boolean.public character getEventProcedure()
EVENT-PROCEDURE
attribute of this async request.getEventProcedure
in interface AsyncRequest
public handle getEventProcedureContext()
EVENT-PROCEDURE-CONTEXT
attribute of this async request.getEventProcedureContext
in interface AsyncRequest
public handle getPersistentProcedure()
PERSISTENT-PROCEDURE
attribute of this async request.getPersistentProcedure
in interface AsyncRequest
public character getProcedureName()
PROCEDURE-NAME
attribute of this async request.getProcedureName
in interface AsyncRequest
public logical isQuit()
QUIT
attribute of this async request.isQuit
in interface AsyncRequest
public logical isStop()
STOP
attribute of this async request.isStop
in interface AsyncRequest
public void run()
run
in interface java.lang.Runnable
void setRequestId(int reqId)
reqId
- The ID of the request.void complete()
void cancelled()
void setStop()
void setQuit()
void setError()
void stop()
void setResult(RemoteInvocationResult result)
request
execution.result
- The result.void registerListener(AsyncRequestListener listener)
listener
- A listener instance.void notifyStart()
void execute(boolean event)
event
- Flag indicating if the PROCEDURE-COMPLETE event will be raised.protected boolean resourceDelete()
resourceDelete
in class HandleChain
true
if the resource was deleted.protected boolean hasNameReadOnly()
false
hasNameReadOnly
in class HandleChain
false
private void notifyListeners(boolean start)
start
- true
to indicate invocation start, false
to notify for
invocation finish.