R
- the response type, i.e. the type of the objectRef sent from the server back to the client.public interface Request<R>
Every REST request should be a separate class implementing this interface. It should be instantiated for
an individual invocation, parameterised (usually directly via the constructor) and passed to
LocalServerRestClient.execute(Request)
.
Objects of this type are therefore short-lived: They normally are only used for one single invocation and
forgotten afterwards. In most cases, anonymous instances are directly passed to the
LocalServerRestClient.execute(...)
method as shown in this example:
return getLocalServerRestClient().execute(new DoThisAndThatOnServer(param1, param2));
Implementations of this interface are not thread-safe.
Important: Please do not directly implement this interface! If the REST request queries a
response from the server, it is recommended to sub-class AbstractRequest
. If there is no response,
implementors should sub-class VoidRequest
instead.
Modifier and Type | Method and Description |
---|---|
R |
execute()
Execute the actual request.
|
LocalServerRestClient |
getLocalServerRestClient()
Gets the
LocalServerRestClient . |
boolean |
isResultNullable()
Indicates, if the result of the invocation can be
null . |
void |
setLocalServerRestClient(LocalServerRestClient localServerRestClient)
Sets the
LocalServerRestClient . |
LocalServerRestClient getLocalServerRestClient()
LocalServerRestClient
.
LocalServerRestClient.execute(Request)
assigns this property, before invoking
execute()
. After the invocation, this property is cleared, again.
LocalServerRestClient
. Never null
during
execution (but otherwise it normally is null
).setLocalServerRestClient(LocalServerRestClient)
void setLocalServerRestClient(LocalServerRestClient localServerRestClient)
LocalServerRestClient
.localServerRestClient
- the LocalServerRestClient
. May be null
.getLocalServerRestClient()
R execute()
Important: You should never invoke this method directly! Instead, pass the Request
to
LocalServerRestClient.execute(Request)
.
null
. Depending on
isResultNullable()
a null
result is considered an error and causes an exception.boolean isResultNullable()
null
.
If the server must send a response, i.e. the invocation must not return empty-handed, this
should be false
. In case, the server still does not send a reply, it is considered an
error causing an exception.
Please note: If a request never returns a response (like a Java void method), it is recommended
that you sub-class VoidRequest
.
true
if null
as response is allowed; false
otherwise.Copyright © 2013–2019. All rights reserved.