类 NodeRPCConnection
- java.lang.Object
-
- org.elastos.hive.connection.NodeRPCConnection
-
- 直接已知子类:
ServiceEndpoint
public abstract class NodeRPCConnection extends java.lang.ObjectNetwork connection for accessing hive node with restful APIs.The access token management is required for the sub-class implicitly.
For file uploading, direct connection need be created for uploading stream.
HttpURLConnection urlConnection = connection.openConnection(FilesAPI.API_UPLOAD + path); OutputStream outputStream = new UploadOutputStream(urlConnection, urlConnection.getOutputStream());For other APIs, please directly create the relating service.
FilesAPI filesAPI = connection.createService(FilesAPI.class, true); String hashCode = filesAPI.getHash(path).execute().body().getHash();
-
-
构造器概要
构造器 构造器 说明 NodeRPCConnection()
-
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 <S> ScreateService(java.lang.Class<S> serviceClass, boolean requiredAuthorization)Create a retrofit API service which can map Java call to Http request.protected abstract AccessTokengetAccessToken()protected abstract java.lang.StringgetProviderAddress()java.net.HttpURLConnectionopenConnection(java.lang.String urlPath)Open a HTTP connection to communicate with hive node.
-
-
-
方法详细资料
-
getProviderAddress
protected abstract java.lang.String getProviderAddress()
-
getAccessToken
protected abstract AccessToken getAccessToken()
-
openConnection
public java.net.HttpURLConnection openConnection(java.lang.String urlPath) throws java.io.IOExceptionOpen a HTTP connection to communicate with hive node.- 参数:
urlPath- Relative URL path of the node API.- 返回:
- The connection.
- 抛出:
java.io.IOException- exception such as timeout, network error, etc.
-
createService
public <S> S createService(java.lang.Class<S> serviceClass, boolean requiredAuthorization)Create a retrofit API service which can map Java call to Http request.- 类型参数:
S- The service class.- 参数:
serviceClass- The service class is the base class for the service.requiredAuthorization- If this service need authorization. Normally if true, the service need token when send request.- 返回:
- The service instance based on the service class.
-
-