public class AsyncServiceImpl extends java.lang.Object implements AsyncService
The Service must be initiated with authentication for use of the API, either with a user name and password (used to retrieve a token), or directly with a token. The initiation transaction gets all account details from the server, and once it is successful the object is ready to be used to perform REST transactions.
AsyncService.AccountCallback, AsyncService.DataRetrieveCallback, AsyncService.TransactionCallback
Constructor and Description |
---|
AsyncServiceImpl(java.lang.String url) |
AsyncServiceImpl(java.lang.String url,
int connectTimeout,
int readTimeout) |
Modifier and Type | Method and Description |
---|---|
void |
abortTransaction()
Cancels any transaction currently in progress.
|
void |
doDataRetrieve(GetTransaction trans,
AsyncService.DataRetrieveCallback drc)
Asynchronous execution of a GET transaction, retrieving resource objects.
|
void |
doTransaction(ResourceTransaction trans,
AsyncService.TransactionCallback tc)
Asynchronous execution of an API transaction.
|
ServiceSpec |
getServiceSpec()
The ServiceSpec object has account information for the current client
session, such as user and customer entities and access rights, once
the service has been initiated.
|
void |
initiate(java.lang.String authenticationToken,
AsyncService.AccountCallback ac)
Initiate the service, authenticating the client with an authentication
token.
|
void |
initiate(java.lang.String username,
java.lang.String password,
AsyncService.AccountCallback ac)
Initiate the service, authenticating the client with user name and
password.
|
boolean |
isInitiated() |
boolean |
isInProgress() |
void |
setCustomerContext(long customerId,
AsyncService.AccountCallback ac)
If the currently authenticated user has access to multiple customer
accounts, it is possible to switch between them, to target a different
account.
|
public AsyncServiceImpl(java.lang.String url)
url
- server URL, such as https://www.smarttracker.no/web
public AsyncServiceImpl(java.lang.String url, int connectTimeout, int readTimeout)
url
- server URL, such as https://www.smarttracker.no/web
connectTimeout
- connection timeout for transactions (milliseconds), 0 for nonereadTimeout
- read timeout for transactions (milliseconds), 0 for nonepublic void initiate(java.lang.String username, java.lang.String password, AsyncService.AccountCallback ac)
AsyncService
initiate
in interface AsyncService
ac
- called on transaction completionpublic void initiate(java.lang.String authenticationToken, AsyncService.AccountCallback ac)
AsyncService
initiate
in interface AsyncService
ac
- called on transaction completionpublic boolean isInitiated()
isInitiated
in interface AsyncService
public void setCustomerContext(long customerId, AsyncService.AccountCallback ac)
AsyncService
setCustomerContext
in interface AsyncService
customerId
- account to switch toac
- called on transaction completionpublic ServiceSpec getServiceSpec()
getServiceSpec
in interface AsyncService
public void doTransaction(ResourceTransaction trans, AsyncService.TransactionCallback tc)
AsyncService
doTransaction
in interface AsyncService
trans
- specifies the transactiontc
- called on transaction completionpublic void doDataRetrieve(GetTransaction trans, AsyncService.DataRetrieveCallback drc)
AsyncService
doDataRetrieve
in interface AsyncService
trans
- specifies the transactiondrc
- called on transaction completionpublic boolean isInProgress()
isInProgress
in interface AsyncService
public void abortTransaction()
AsyncService
abortTransaction
in interface AsyncService