QUEUE
- is the generic type of the queue
. The queue implementation
must extend AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue
.CALL
- is the generic type of the remote invocation call. For command style this is just the
RemoteInvocationCommand
itself, for RPC style this is
GenericRemoteInvocationRpcCall
.TX_CALLS
- is the generic type of the transfer object that wraps a <CALL>-array with the
calls to perform in a single transaction.REQUEST
- is the generic type of the GenericRemoteInvocationRequest
to build and send to the
server.public abstract class AbstractRemoteInvocationCaller<QUEUE extends RemoteInvocationQueue,CALL extends RemoteInvocationCall,TX_CALLS extends GenericRemoteInvocationTransactionalCalls<CALL>,REQUEST extends GenericRemoteInvocationRequest<CALL,TX_CALLS>> extends AbstractLoggableComponent implements RemoteInvocationCaller<QUEUE>, AttributeWriteTransactionMode, AttributeWriteDefaultFailureCallback
RemoteInvocationCaller
.Modifier and Type | Class and Description |
---|---|
protected class |
AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue
This is the abstract base implementation of
RemoteInvocationQueue . |
protected class |
AbstractRemoteInvocationCaller.RequestBuilder
This class is a builder for
GenericRemoteInvocationRequest s. |
protected class |
AbstractRemoteInvocationCaller.TransactionalCallBuilder
This inner calls is a builder for
GenericRemoteInvocationTransactionalCalls . |
Modifier and Type | Field and Description |
---|---|
private QUEUE |
currentQueue
The current
queue or null for none. |
private Consumer<Throwable> |
defaultFailureCallback |
private int |
requestCount |
private TransactionMode |
transactionMode |
private CsrfToken |
xsrfToken |
Constructor and Description |
---|
AbstractRemoteInvocationCaller()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
protected QUEUE |
createQueue(RemoteInvocationQueueSettings settings)
This method creates a new
AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue . |
protected abstract QUEUE |
createQueue(RemoteInvocationQueueSettings settings,
AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue parentQueue) |
protected abstract TX_CALLS |
createRemoteInvocationTransactionalCalls(List<CALL> calls) |
protected abstract REQUEST |
createRequest(int requestId,
CsrfToken token,
List<TX_CALLS> transactionalCalls)
Creates a new
GenericRemoteInvocationRequest instance. |
QUEUE |
getCurrentQueue()
This method gets the current
queue . |
Consumer<Throwable> |
getDefaultFailureCallback()
This method gets the default callback to
handle failures that occurred on
service invocations. |
TransactionMode |
getTransactionMode()
This method gets the
TransactionMode . |
CsrfToken |
getXsrfToken() |
protected void |
handleFailure(REQUEST request,
AbstractRemoteInvocationCaller.RequestBuilder builder,
Throwable failure)
This method should be called from
performRequest(GenericRemoteInvocationRequest, RequestBuilder)
if a general failure occurred on the client side (in case of a network error or the
like). |
protected void |
handleResponse(REQUEST request,
AbstractRemoteInvocationCaller.RequestBuilder builder,
GenericRemoteInvocationResponse response)
This method should be called from
performRequest(GenericRemoteInvocationRequest, RequestBuilder)
if a GenericRemoteInvocationResponse has been received. |
QUEUE |
newQueue()
This method opens a
queue that collects remote invocations to send
to the server. |
QUEUE |
newQueue(RemoteInvocationQueueSettings settings)
This method opens a
queue that collects remote invocations to send
to the server. |
QUEUE |
newQueue(String id)
This method opens a
queue that collects remote invocations to send
to the server. |
protected QUEUE |
newQueueForAutoCommit() |
protected int |
nextRequestId() |
protected void |
performRequest(AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue queue)
This method finally performs a request with the invocations collected by the given
queue . |
protected abstract void |
performRequest(REQUEST request,
AbstractRemoteInvocationCaller.RequestBuilder builder)
Actually performs the given
request by sending it to the server and handling the response
asynchronously. |
protected QUEUE |
requireCurrentQueue() |
void |
setDefaultFailureCallback(Consumer<Throwable> failureCallback)
This method sets the
default failure callback . |
void |
setTransactionMode(TransactionMode transactionMode) |
createLogger, doInitialize, getLogger
doInitialized, getInitializationState, initialize
private int requestCount
nextRequestId()
private QUEUE extends RemoteInvocationQueue currentQueue
queue
or null
for none.private TransactionMode transactionMode
getTransactionMode()
private Consumer<Throwable> defaultFailureCallback
getDefaultFailureCallback()
private CsrfToken xsrfToken
getXsrfToken()
public AbstractRemoteInvocationCaller()
public TransactionMode getTransactionMode()
TransactionMode
.getTransactionMode
in interface AttributeWriteTransactionMode
TransactionMode
.public void setTransactionMode(TransactionMode transactionMode)
setTransactionMode
in interface AttributeWriteTransactionMode
transactionMode
- is the new value of AttributeWriteTransactionMode.getTransactionMode()
.public Consumer<Throwable> getDefaultFailureCallback()
handle
failures that occurred on
service invocations.getDefaultFailureCallback
in interface AttributeReadDefaultFailureCallback
null
if no default is configured.public void setDefaultFailureCallback(Consumer<Throwable> failureCallback)
default failure callback
.setDefaultFailureCallback
in interface AttributeWriteDefaultFailureCallback
failureCallback
- is the new value of AttributeReadDefaultFailureCallback.getDefaultFailureCallback()
.public QUEUE newQueue()
queue
that collects remote invocations to send
to the server.newQueue
in interface RemoteInvocationCaller<QUEUE extends RemoteInvocationQueue>
RemoteInvocationCaller.newQueue(RemoteInvocationQueueSettings)
public QUEUE newQueue(String id)
queue
that collects remote invocations to send
to the server.newQueue
in interface RemoteInvocationCaller<QUEUE extends RemoteInvocationQueue>
id
- is the identifier
of the new
queue
.RemoteInvocationCaller.newQueue(RemoteInvocationQueueSettings)
public QUEUE newQueue(RemoteInvocationQueueSettings settings)
queue
that collects remote invocations to send
to the server. If a queue
is currently
open
this method will create a child-queue of that queue.newQueue
in interface RemoteInvocationCaller<QUEUE extends RemoteInvocationQueue>
settings
- are the RemoteInvocationQueueSettings
.queue
.protected QUEUE newQueueForAutoCommit()
auto-commit
.protected QUEUE createQueue(RemoteInvocationQueueSettings settings)
AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue
. If a current
queue
is present, the new queue has to use it as parent
.settings
- are the RemoteInvocationQueueSettings
for the new queue.AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue
.protected abstract QUEUE createQueue(RemoteInvocationQueueSettings settings, AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue parentQueue)
settings
- are the RemoteInvocationQueueSettings
.parentQueue
- is the parent queue.createQueue(RemoteInvocationQueueSettings)
public QUEUE getCurrentQueue()
queue
. This is the last queue that has
been created
and is still open
. RemoteInvocationCaller.newQueue()
instead, to
retrieve a queue and perform service invocations.getCurrentQueue
in interface RemoteInvocationCaller<QUEUE extends RemoteInvocationQueue>
queue
or null
if no queue is open.protected int nextRequestId()
request ID
.protected QUEUE requireCurrentQueue()
AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue
.public CsrfToken getXsrfToken()
CsrfToken
or null
if not available.protected void performRequest(AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue queue)
queue
.queue
- is the AbstractRemoteInvocationCaller.AbstractRemoteInvocationQueue
.protected abstract void performRequest(REQUEST request, AbstractRemoteInvocationCaller.RequestBuilder builder)
request
by sending it to the server and handling the response
asynchronously.request
- is the GenericRemoteInvocationRequest
to perform.builder
- is the AbstractRemoteInvocationCaller.RequestBuilder
that created the request and is to be used for handling the
results (dispatching to the asynchronous callback functions).protected void handleResponse(REQUEST request, AbstractRemoteInvocationCaller.RequestBuilder builder, GenericRemoteInvocationResponse response)
performRequest(GenericRemoteInvocationRequest, RequestBuilder)
if a GenericRemoteInvocationResponse
has been received.request
- is the GenericRemoteInvocationRequest
that has been
performed
.builder
- is the AbstractRemoteInvocationCaller.RequestBuilder
corresponding to the given request
.response
- is the GenericRemoteInvocationResponse
to handle.protected void handleFailure(REQUEST request, AbstractRemoteInvocationCaller.RequestBuilder builder, Throwable failure)
performRequest(GenericRemoteInvocationRequest, RequestBuilder)
if a general failure
occurred on the client side (in case of a network error or the
like).request
- is the GenericRemoteInvocationRequest
that has been
performed
.builder
- is the AbstractRemoteInvocationCaller.RequestBuilder
corresponding to the given request
.failure
- is the Throwable
that has been catched on the client.protected abstract TX_CALLS createRemoteInvocationTransactionalCalls(List<CALL> calls)
calls
- is the List
with the <CALL>s.calls
.protected abstract REQUEST createRequest(int requestId, CsrfToken token, List<TX_CALLS> transactionalCalls)
GenericRemoteInvocationRequest
instance.requestId
- - see GenericRemoteInvocationRequest.getRequestId()
.token
- - see GenericRemoteInvocationRequest.getXsrfToken()
.transactionalCalls
- - see GenericRemoteInvocationRequest.getTransactionalCalls()
.Copyright © 2001–2016 mmm-Team. All rights reserved.