public abstract class NodeRPCConnection
extends java.lang.Object
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();
| Constructor and Description |
|---|
NodeRPCConnection() |
| Modifier and Type | Method and Description |
|---|---|
<S> S |
createService(java.lang.Class<S> serviceClass,
boolean requiredAuthorization)
Create a retrofit API service which can map Java call to Http request.
|
protected abstract AccessToken |
getAccessToken() |
protected abstract java.lang.String |
getProviderAddress() |
java.net.HttpURLConnection |
openConnection(java.lang.String urlPath)
Open a HTTP connection to communicate with hive node.
|
protected abstract java.lang.String getProviderAddress()
protected abstract AccessToken getAccessToken()
public java.net.HttpURLConnection openConnection(java.lang.String urlPath)
throws java.io.IOException
urlPath - Relative URL path of the node API.java.io.IOException - exception such as timeout, network error, etc.public <S> S createService(java.lang.Class<S> serviceClass,
boolean requiredAuthorization)
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.