Base class for handling HTTP requests. This class is not intended for direct usage, the developer should use a subclass of this one.
An instance of this class will also emit events about the internal spooler behavoir, so that any attached com.cloudplugs.util.Listener to a RestBaseManager will be notified about what's happening in the execution flow.
See also RestManager.
More...
|
static final int | ID_NULL = RestSpooler.ID_NULL |
|
|
| RestBaseManager (RestSpooler spooler, Opts opts) |
|
RestSpooler | getSpooler () |
|
int | execRequest (Request request, RestCallback cb) |
|
int | execGet (String action, String path, RestCallback cb) |
|
int | execPut (String action, String path, String body, RestCallback cb) |
|
int | execPost (String action, String path, String body, RestCallback cb) |
|
int | execPatch (String action, String path, String body, RestCallback cb) |
|
int | execDelete (String action, String path, String body, RestCallback cb) |
|
int | execRequest (String method, String action, String path, String body, RestCallback cb) |
|
int | execRequest (String method, String action, String path, RestCallback cb, Object... body) |
|
void | finalize () throws Throwable |
|
void | wantAuth () |
|
void | wantBasicAuth () |
|
void | wantEmailAuth () |
|
void | wantMasterAuth () |
|
void | wantDeviceAuth () |
|
void | wantNoEmailAuth () |
|
void | wantNoAuth () |
|
void | wantNoDeviceAuth () |
|
|
static String | bodyGen (Object... args) |
|
static String | queryGen (Object... args) |
|
static String | pathQuery (String path, String query) |
|
static String | esc (Object s) throws UnsupportedEncodingException |
|
static Object | queryCast (Object o) throws UnsupportedEncodingException |
|
static Object | ts (Object val, String err) |
|
static Object | tso (Object val, String err) |
|
static Object | tsp (Object val, String err) |
|
static void | runOnCb (RestCallback cb, Runnable runnable) |
|
Base class for handling HTTP requests. This class is not intended for direct usage, the developer should use a subclass of this one.
An instance of this class will also emit events about the internal spooler behavoir, so that any attached com.cloudplugs.util.Listener to a RestBaseManager will be notified about what's happening in the execution flow.
See also RestManager.
◆ RestBaseManager()
◆ bodyGen()
static String bodyGen |
( |
Object... |
args | ) |
|
|
staticprotected |
◆ cancel() [1/2]
Cancel the execution of a previously enqueued request. If successfull, all information about the enqueued request will be lost.
- Parameters
-
id | the identifier asynchronous request to cancel |
- Returns
- true if the specified request has been canceled, false if that request is unknown or already executed
◆ cancel() [2/2]
Cancel the execution of a previously enqueued request. If successful, all information about the enqueued request will be lost.
- Parameters
-
request | the request to cancel |
- Returns
- true if the specified request has been canceled, false if that request is unknown or already executed
◆ esc()
static String esc |
( |
Object |
s | ) |
throws UnsupportedEncodingException |
|
staticprotected |
◆ execDelete()
int execDelete |
( |
String |
action, |
|
|
String |
path, |
|
|
String |
body, |
|
|
RestCallback |
cb |
|
) |
| |
|
protected |
◆ execGet()
◆ execPatch()
int execPatch |
( |
String |
action, |
|
|
String |
path, |
|
|
String |
body, |
|
|
RestCallback |
cb |
|
) |
| |
|
protected |
◆ execPost()
int execPost |
( |
String |
action, |
|
|
String |
path, |
|
|
String |
body, |
|
|
RestCallback |
cb |
|
) |
| |
|
protected |
◆ execPut()
int execPut |
( |
String |
action, |
|
|
String |
path, |
|
|
String |
body, |
|
|
RestCallback |
cb |
|
) |
| |
|
protected |
◆ execRequest() [1/3]
◆ execRequest() [2/3]
int execRequest |
( |
String |
method, |
|
|
String |
action, |
|
|
String |
path, |
|
|
String |
body, |
|
|
RestCallback |
cb |
|
) |
| |
|
protected |
◆ execRequest() [3/3]
int execRequest |
( |
String |
method, |
|
|
String |
action, |
|
|
String |
path, |
|
|
RestCallback |
cb, |
|
|
Object... |
body |
|
) |
| |
|
protected |
◆ finalize()
void finalize |
( |
| ) |
throws Throwable |
|
protected |
◆ getAuthId()
Shortcut for getting the authentication identifier (PlugID or email) associated in the Opts of this manager. It's just like calling this.getOpts().getAuthId().
- Returns
- authentication identifier or null if there is no authentication associated to this manager
◆ getJobOf()
Retrieve an enqueued and pending asynchronous request as an instance of RestJob.
- Parameters
-
id | the identifier of the asynchronous execution to obtain |
- Returns
- the pending exection or null if not found (for unknown
id
or already executed requests)
◆ getOpts()
- Returns
- options associated to this manager
◆ getSpooler()
◆ isEmpty()
- Returns
- false if there is at least one pending request to execute, otherwise true
◆ pathQuery()
static String pathQuery |
( |
String |
path, |
|
|
String |
query |
|
) |
| |
|
staticprotected |
◆ queryCast()
static Object queryCast |
( |
Object |
o | ) |
throws UnsupportedEncodingException |
|
staticprotected |
◆ queryGen()
static String queryGen |
( |
Object... |
args | ) |
|
|
staticprotected |
◆ runOnCb()
◆ sync() [1/2]
Wait for the end of execution of the specified asynchronous pending request and return its Response. The current thread will be suspended until the request is completed or canceled, but not more than timeout
milliseconds. If the specified pending request identifier is not valid, this method will return immediately. This method is like waitFor(int, long) but it returns the obtained response.
- Parameters
-
id | the identifier asynchronous request to synchronize |
timeout | expiration timeout: maximum milliseconds to wait or 0 to have no expiration |
- Returns
- the obtained response or null if the asyncronous execution
id
is unknown or if timeout
is expired
◆ sync() [2/2]
Like sync(int, long), but without any timeout expiration.
- Parameters
-
id | the identifier asynchronous request to synchronize |
- Returns
- the obtained response or null if the asyncronous execution
id
is unknown
◆ ts()
static Object ts |
( |
Object |
val, |
|
|
String |
err |
|
) |
| |
|
staticprotected |
◆ tso()
static Object tso |
( |
Object |
val, |
|
|
String |
err |
|
) |
| |
|
staticprotected |
◆ tsp()
static Object tsp |
( |
Object |
val, |
|
|
String |
err |
|
) |
| |
|
staticprotected |
◆ waitFor() [1/2]
boolean waitFor |
( |
int |
id, |
|
|
long |
timeout |
|
) |
| |
Wait for the end of execution of the specified asynchronous pending request. The current thread will be suspended until the request is completed or canceled, but not more than timeout
milliseconds. If the specified pending request identifier is not valid, this method will return immediately.
- Parameters
-
id | the identifier asynchronous request to synchronize |
timeout | expiration timeout: maximum milliseconds to wait or 0 to have no expiration |
- Returns
- true if the asynchronous request has been completed or canceled, false if unknown
◆ waitFor() [2/2]
boolean waitFor |
( |
int |
id | ) |
|
Like waitFor(int, long), but without any timeout expiration.
- Parameters
-
id | the identifier asynchronous request to synchronize |
- Returns
- true if the asynchronous request has been completed or canceled, false if unknown
◆ waitForIdle() [1/2]
boolean waitForIdle |
( |
long |
timeout | ) |
|
Wait for the end of execution of all asynchronous enqueued pending requests. The current thread will be suspended until all requests are completed, but not more than timeout
milliseconds.
- Parameters
-
timeout | expiration timeout: maximum milliseconds to wait or 0 to have no expiration |
- Returns
- true if all asynchronous requests have been completed or canceled, false if the spooler thread is not running (for example for empty queue) or if the
timeout
is expired
◆ waitForIdle() [2/2]
Like waitForIdle(long) but without expiration.
- Returns
- true if all asynchronous requests have been completed or canceled, false if the spooler thread is not running (for example for empty queue)
◆ waitForStop() [1/2]
boolean waitForStop |
( |
long |
timeout | ) |
|
Wait for the end of execution of the underlying spooler thread of asynchronous requests. The current thread will be suspended until the underlying spooler will be stopped, but not more than timeout
milliseconds.
- Parameters
-
timeout | expiration timeout: maximum milliseconds to wait or 0 to have no expiration |
- Returns
- false if the underlying spooler was already stopped
◆ waitForStop() [2/2]
Like waitForStop(long) but without expiration.
- Returns
- false if the underlying spooler was already stopped
◆ wantAuth()
◆ wantBasicAuth()
◆ wantDeviceAuth()
◆ wantEmailAuth()
◆ wantMasterAuth()
◆ wantNoAuth()
◆ wantNoDeviceAuth()
void wantNoDeviceAuth |
( |
| ) |
|
|
protected |
◆ wantNoEmailAuth()
◆ ID_NULL
final int ID_NULL = RestSpooler.ID_NULL |
|
static |
Constant to indicate an invalid asynchronous execution identifier.
◆ opts
◆ spooler