public abstract class RestProviderBase extends java.lang.Object implements Disposable
Modifier and Type | Class and Description |
---|---|
static class |
RestProviderBase.CacheModel
The cache mode.
|
protected static class |
RestProviderBase.RestRequestException |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
JAVA_POSTFIX |
protected static JavaStreamConverter |
javaConverter |
protected static java.lang.String |
JSON_POSTFIX |
protected JsonConverter |
jsonConverter |
protected static JsonDecoder |
jsonDecoder |
static java.util.concurrent.locks.ReentrantLock |
lock |
protected static LocLogger |
logger |
protected static ResourceManager |
message |
Constructor and Description |
---|
RestProviderBase()
The Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
Clear the cache.
|
void |
dispose()
Release the resource object.
|
protected <T> T |
executeRequest(Request request, java.lang.Class<T> clz)
Execute the request and return the object.
|
protected <T> T |
executeRequest(Request request, java.lang.Class<T> clz, boolean useCache)
Execute the request and return the object.
|
protected <T> T |
executeRequest(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel)
Execute the request and return the object.
|
protected byte[] |
executeRequestForByteArray(Request request)
Execute the request and return the byte array.
|
protected byte[] |
executeRequestForByteArray(Request request, boolean useCache)
Execute the request and return the byte array.
|
protected byte[] |
executeRequestForByteArray(Request request, RestProviderBase.CacheModel cacheModel)
Execute the request and return the byte array.
|
protected byte[] |
executeRequestForByteArray(Request request, RestProviderBase.CacheModel cacheModel, Client restMapClient) |
protected <T> java.util.List<T> |
executeRequestForList(Request request, java.lang.Class<T> clz)
Execute the request to return the array.
|
protected <T> java.util.List<T> |
executeRequestForList(Request request, java.lang.Class<T> clz, boolean useCache)
Execute the request to return the array.
|
protected <T> java.util.List<T> |
executeRequestForList(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel)
Execute the request to return the array.
|
protected <T> java.util.List<T> |
executeRequestForList(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel, Client restMapClient) |
protected java.io.InputStream |
executeRequestForStream(Request request)
Execute the request and return the Stream.
|
protected java.io.InputStream |
executeRequestForStream(Request request, boolean useCache)
Execute the request and return the Stream.
|
protected java.io.InputStream |
executeRequestForStream(Request request, RestProviderBase.CacheModel cacheModel)
Execute the request and return the Stream.
|
protected java.lang.String |
executeRequestForText(Request request)
Execute the request and return the string.
|
protected java.lang.String |
executeRequestForText(Request request, boolean useCache)
Execute the request and return the string.
|
protected java.lang.String |
executeRequestForText(Request request, RestProviderBase.CacheModel cacheModel)
Execute the request and return the string.
|
protected abstract RestProviderSetting |
getRestProviderSetting()
Return the rest service provider configuration information.
|
void |
handleExeption(RestProviderBase.RestRequestException ex) |
protected void |
init(RestProviderSetting setting)
Initialize the object according to RestProvider Setting.
|
protected Client |
newAndSetClient(Client nclient, java.lang.String socketTimeout) |
protected java.lang.String |
rectifyRestServiceRootURL(java.lang.String restUrl)
Correct the REST URL, remove the "/" at the end of the URL.
|
public static final java.util.concurrent.locks.ReentrantLock lock
protected static final ResourceManager message
protected static final LocLogger logger
protected static final JavaStreamConverter javaConverter
protected static final JsonDecoder jsonDecoder
protected static final java.lang.String JSON_POSTFIX
protected static final java.lang.String JAVA_POSTFIX
protected final JsonConverter jsonConverter
public void dispose()
Disposable
Release the resource object.
dispose
in interface Disposable
public void clearCache()
Clear the cache.
protected void init(RestProviderSetting setting)
setting
-protected java.lang.String executeRequestForText(Request request) throws RestProviderBase.RestRequestException
request
- request.RestProviderBase.RestRequestException
protected java.lang.String executeRequestForText(Request request, boolean useCache) throws RestProviderBase.RestRequestException
request
- request.useCache
- Whether to use caching.RestProviderBase.RestRequestException
protected java.lang.String executeRequestForText(Request request, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
request
- request.cacheModel
- Cache mode.RestProviderBase.RestRequestException
protected <T> T executeRequest(Request request, java.lang.Class<T> clz) throws RestProviderBase.RestRequestException
request
- request.clz
- Object type.JSONException
RestProviderBase.RestRequestException
protected <T> T executeRequest(Request request, java.lang.Class<T> clz, boolean useCache) throws RestProviderBase.RestRequestException
request
- request.clz
- Object type.useCache
- cache.JSONException
RestProviderBase.RestRequestException
protected <T> T executeRequest(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
request
- request.clz
- Object type.cacheModel
- Cache mode.RestProviderBase.RestRequestException
JSONException
protected byte[] executeRequestForByteArray(Request request) throws RestProviderBase.RestRequestException
request
- request.RestProviderBase.RestRequestException
protected byte[] executeRequestForByteArray(Request request, boolean useCache) throws RestProviderBase.RestRequestException
request
- request.useCache
- Whether to use caching.RestProviderBase.RestRequestException
protected byte[] executeRequestForByteArray(Request request, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
request
- request.cacheModel
- Cache mode.RestProviderBase.RestRequestException
protected byte[] executeRequestForByteArray(Request request, RestProviderBase.CacheModel cacheModel, Client restMapClient) throws RestProviderBase.RestRequestException
request
-cacheModel
-restMapClient
- The client used by RestMapProviderRestProviderBase.RestRequestException
protected <T> java.util.List<T> executeRequestForList(Request request, java.lang.Class<T> clz) throws RestProviderBase.RestRequestException
Execute the request to return the array.
request
- request.clz
- Object type.JSONException
RestProviderBase.RestRequestException
protected <T> java.util.List<T> executeRequestForList(Request request, java.lang.Class<T> clz, boolean useCache) throws RestProviderBase.RestRequestException
Execute the request to return the array.
request
- request.clz
- Object type.useCache
- Whether to use caching.JSONException
RestProviderBase.RestRequestException
protected <T> java.util.List<T> executeRequestForList(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
Execute the request to return the array.
request
- request.clz
- Object type.cacheModel
- Cache mode.RestProviderBase.RestRequestException
protected <T> java.util.List<T> executeRequestForList(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel, Client restMapClient) throws RestProviderBase.RestRequestException
request
-clz
-cacheModel
-restMapClient
- The client used by RestMapProviderRestProviderBase.RestRequestException
protected java.io.InputStream executeRequestForStream(Request request) throws RestProviderBase.RestRequestException
request
- request.RestProviderBase.RestRequestException
protected java.io.InputStream executeRequestForStream(Request request, boolean useCache) throws RestProviderBase.RestRequestException
request
- request.useCache
- Whether to use caching.RestProviderBase.RestRequestException
protected java.io.InputStream executeRequestForStream(Request request, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
request
- request.cacheModel
- Cache mode.RestProviderBase.RestRequestException
protected java.lang.String rectifyRestServiceRootURL(java.lang.String restUrl)
Correct the REST URL, remove the "/" at the end of the URL.
restUrl
-protected abstract RestProviderSetting getRestProviderSetting()
protected Client newAndSetClient(Client nclient, java.lang.String socketTimeout)
public void handleExeption(RestProviderBase.RestRequestException ex)