public class LocalServerRestClient extends Object
An instance of this class is used to send data to, query data from or execute logic on the server.
If a series of multiple requests is to be sent to the server, it is recommended to keep an instance of this class (because it caches resources) and invoke multiple requests with it.
This class is thread-safe.
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_KEY_SOCKET_CONNECT_TIMEOUT
The
key for the connection timeout used with Config.getPropertyAsInt(String, int) . |
static String |
CONFIG_KEY_SOCKET_READ_TIMEOUT
The
key for the read timeout used with Config.getPropertyAsInt(String, int) . |
Modifier | Constructor and Description |
---|---|
protected |
LocalServerRestClient()
Create a new client.
|
Modifier and Type | Method and Description |
---|---|
javax.ws.rs.client.Invocation.Builder |
assignCredentials(javax.ws.rs.client.Invocation.Builder builder) |
<R> R |
execute(Request<R> request) |
String |
getBaseUrl()
Get the server's base-URL.
|
javax.ws.rs.client.Client |
getClientOrFail()
|
CredentialsProvider |
getCredentialsProvider() |
static LocalServerRestClient |
getInstance() |
Integer |
getSocketConnectTimeout() |
Integer |
getSocketReadTimeout() |
void |
handleAndRethrowException(RuntimeException x) |
void |
registerRestComponent(Object restComponent) |
void |
setCredentialsProvider(CredentialsProvider credentialsProvider) |
void |
setSocketConnectTimeout(Integer socketConnectTimeout) |
void |
setSocketReadTimeout(Integer socketReadTimeout) |
public static final String CONFIG_KEY_SOCKET_CONNECT_TIMEOUT
key
for the connection timeout used with Config.getPropertyAsInt(String, int)
.
The configuration can be overridden by a system property - see Config.SYSTEM_PROPERTY_PREFIX
.
public static final String CONFIG_KEY_SOCKET_READ_TIMEOUT
key
for the read timeout used with Config.getPropertyAsInt(String, int)
.
The configuration can be overridden by a system property - see Config.SYSTEM_PROPERTY_PREFIX
.
protected LocalServerRestClient()
public static LocalServerRestClient getInstance()
public Integer getSocketConnectTimeout()
public void setSocketConnectTimeout(Integer socketConnectTimeout)
public Integer getSocketReadTimeout()
public void setSocketReadTimeout(Integer socketReadTimeout)
public String getBaseUrl()
This base-URL is the base of the LocalServerRest
application. Hence all URLs
beneath this base-URL are processed by the LocalServerRest
application.
public javax.ws.rs.client.Invocation.Builder assignCredentials(javax.ws.rs.client.Invocation.Builder builder)
public void registerRestComponent(Object restComponent)
public javax.ws.rs.client.Client getClientOrFail()
Client
. Never null
.IllegalStateException
- if there is no Client
bound to the current thread.acquireClient()
public void handleAndRethrowException(RuntimeException x)
public CredentialsProvider getCredentialsProvider()
public void setCredentialsProvider(CredentialsProvider credentialsProvider)
Copyright © 2013–2019. All rights reserved.