Database Reference
In-Depth Information
<action> ). The client side implementation of the protocol is shown in
Listing 8.3 .
Listing 8.3 : CommandRunner.java
class CommandRunner {
private final URI host;
static class ErrorResult extends Exception {
private static final long serialVersionUID = 1L;
private final String error;
ErrorResult(JSONObject error) {
super(error.optString("message"));
this.error = error.optString("error", "Unknown");
}
ErrorResult(Throwable ex) {
super(ex);
this.error = ex.getClass().getSimpleName();
}
String getError() {
return error;
}
}
CommandRunner(String host) {
try {
this.host = new URI("http://" + host);
} catch (URISyntaxException ex) {
throw new RuntimeException(ex);
}
}
// Handles transmitting a command and decoding the
response.
JSONObject run(String command, JSONObject arg)
throws ErrorResult {
 
 
Search WWH ::




Custom Search