public abstract class RestProviderBase extends java.lang.Object implements Disposable
基于iServer Rest服务的提供者基类
限定符和类型 | 类和说明 |
---|---|
static class |
RestProviderBase.CacheModel
缓存模式。
|
protected static class |
RestProviderBase.RestRequestException |
限定符和类型 | 字段和说明 |
---|---|
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 |
protected static java.lang.String |
XML_POSTFIX |
protected static XMLDecoder |
xmlDecoder |
构造器和说明 |
---|
RestProviderBase()
构造函数。
|
限定符和类型 | 方法和说明 |
---|---|
void |
clearCache()
清除缓存。
|
void |
dispose()
释放资源对象。
|
protected <T> T |
executeRequest(Request request, java.lang.Class<T> clz)
执行请求返回对象。
|
protected <T> T |
executeRequest(Request request, java.lang.Class<T> clz, boolean useCache)
执行请求返回对象。
|
protected <T> T |
executeRequest(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel)
执行请求返回对象。
|
protected byte[] |
executeRequestByApacheHttpClientForByteArray(Request request, RestProviderBase.CacheModel cacheModel) |
protected byte[] |
executeRequestByRestletClientForByteArray(Request httpRequest, RestProviderBase.CacheModel cacheModel, Client restMapClient) |
protected byte[] |
executeRequestForByteArray(Request request)
执行请求返回字节数组。
|
protected byte[] |
executeRequestForByteArray(Request request, boolean useCache)
执行请求返回字节数组。
|
protected byte[] |
executeRequestForByteArray(Request request, RestProviderBase.CacheModel cacheModel)
执行请求返回字节数组。
|
protected byte[] |
executeRequestForByteArray(Request request, RestProviderBase.CacheModel cacheModel, Client restMapClient) |
protected <T> java.util.List<T> |
executeRequestForList(Request request, java.lang.Class<T> clz)
执行请求返回数组。
|
protected <T> java.util.List<T> |
executeRequestForList(Request request, java.lang.Class<T> clz, boolean useCache)
执行请求返回数组。
|
protected <T> java.util.List<T> |
executeRequestForList(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel)
执行请求返回数组。
|
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)
执行请求返回Stream。
|
protected java.io.InputStream |
executeRequestForStream(Request request, boolean useCache)
执行请求返回Stream。
|
protected java.io.InputStream |
executeRequestForStream(Request request, RestProviderBase.CacheModel cacheModel)
执行请求返回Stream。
|
protected java.lang.String |
executeRequestForText(Request request)
执行请求,返回字符串。
|
protected java.lang.String |
executeRequestForText(Request request, boolean useCache)
执行请求,返回字符串。
|
protected java.lang.String |
executeRequestForText(Request request, RestProviderBase.CacheModel cacheModel)
执行请求,返回字符串。
|
protected CloseableHttpClient |
getApacheHttpClient() |
protected static org.restlet.Request |
getRestletRequest(Request request) |
protected abstract RestProviderSetting |
getRestProviderSetting()
返回REST服务提供者配置信息。
|
void |
handleExeption(RestProviderBase.RestRequestException ex) |
protected void |
init(RestProviderSetting setting)
根据RestProviderSetting初使化对象。
|
CloseableHttpClient |
initHttpClient() |
protected Client |
newAndSetClient(java.lang.String socketTimeout) |
protected java.lang.String |
rectifyRestServiceRootURL(java.lang.String restUrl)
校正REST URL,去除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 XMLDecoder xmlDecoder
protected static final java.lang.String JSON_POSTFIX
protected static final java.lang.String JAVA_POSTFIX
protected static final java.lang.String XML_POSTFIX
protected final JsonConverter jsonConverter
protected CloseableHttpClient getApacheHttpClient()
public CloseableHttpClient initHttpClient()
public void dispose()
Disposable
释放资源对象。
dispose
在接口中 Disposable
public void clearCache()
清除缓存。
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
- 是否使用缓存。RestProviderBase.RestRequestException
protected java.lang.String executeRequestForText(Request request, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
request
- request请求。cacheModel
- 缓存模式。RestProviderBase.RestRequestException
protected <T> T executeRequest(Request request, java.lang.Class<T> clz) throws RestProviderBase.RestRequestException
request
- request请求。clz
- 对象类型。JSONException
RestProviderBase.RestRequestException
protected <T> T executeRequest(Request request, java.lang.Class<T> clz, boolean useCache) throws RestProviderBase.RestRequestException
request
- request请求。clz
- 对象类型。useCache
- 缓存。JSONException
RestProviderBase.RestRequestException
protected <T> T executeRequest(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
request
- request请求。clz
- 对象类型。cacheModel
- 缓存模式。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
- 是否使用缓存。RestProviderBase.RestRequestException
protected byte[] executeRequestForByteArray(Request request, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
request
- request请求。cacheModel
- 缓存模式。RestProviderBase.RestRequestException
protected byte[] executeRequestForByteArray(Request request, RestProviderBase.CacheModel cacheModel, Client restMapClient) throws RestProviderBase.RestRequestException
request
-cacheModel
-restMapClient
- RestMapProvider使用的clientRestProviderBase.RestRequestException
protected byte[] executeRequestByApacheHttpClientForByteArray(Request request, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
protected static org.restlet.Request getRestletRequest(Request request)
protected byte[] executeRequestByRestletClientForByteArray(Request httpRequest, RestProviderBase.CacheModel cacheModel, Client restMapClient) throws RestProviderBase.RestRequestException
protected <T> java.util.List<T> executeRequestForList(Request request, java.lang.Class<T> clz) throws RestProviderBase.RestRequestException
执行请求返回数组。
request
- request请求。clz
- 对象类型。JSONException
RestProviderBase.RestRequestException
protected <T> java.util.List<T> executeRequestForList(Request request, java.lang.Class<T> clz, boolean useCache) throws RestProviderBase.RestRequestException
执行请求返回数组。
request
- request请求。clz
- 对象类型。useCache
- 是否使用缓存。JSONException
RestProviderBase.RestRequestException
protected <T> java.util.List<T> executeRequestForList(Request request, java.lang.Class<T> clz, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
执行请求返回数组。
request
- request请求。clz
- 对象类型。cacheModel
- 缓存模式。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
- RestMapProvider使用的clientRestProviderBase.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
- 是否使用缓存。RestProviderBase.RestRequestException
protected java.io.InputStream executeRequestForStream(Request request, RestProviderBase.CacheModel cacheModel) throws RestProviderBase.RestRequestException
request
- request请求。cacheModel
- 缓存模式。RestProviderBase.RestRequestException
protected java.lang.String rectifyRestServiceRootURL(java.lang.String restUrl)
校正REST URL,去除URL结尾的“/”。
restUrl
-protected abstract RestProviderSetting getRestProviderSetting()
protected Client newAndSetClient(java.lang.String socketTimeout)
public void handleExeption(RestProviderBase.RestRequestException ex)