blob: 3f4cc495665d95dc097e3379b714092cc3244c4d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.processing.execution;
import com.yahoo.processing.Request;
import com.yahoo.processing.Response;
/**
* An adaptor of an Execution to a runnable. Calling run on this causes process to be called on the
* given processor.
*
* @author bratseth
*/
public class RunnableExecution implements Runnable {
private final Request request;
private final Execution execution;
private Response response = null;
private Throwable exception = null;
public RunnableExecution(Request request, Execution execution) {
this.request = request;
this.execution = execution;
}
/**
* Calls process on the execution of this.
* This will result in either response or exception being set on this.
* Calling this never throws an exception.
*/
public void run() {
try {
response = execution.process(request);
} catch (Exception e) {
exception = e; // TODO: Log
}
}
/**
* Returns the response from executing this, or null if exception is set or run() has not been called yet
*/
public Response getResponse() {
return response;
}
/**
* Returns the exception from executing this, or null if response is set or run() has not been called yet
*/
public Throwable getException() {
return exception;
}
}
|