1 package hudson.remoting; 2 3 11 final class Response<RSP,EXC extends Throwable > extends Command { 12 15 private final int id; 16 17 final RSP returnValue; 18 final EXC exception; 19 20 Response(int id, RSP returnValue) { 21 this.id = id; 22 this.returnValue = returnValue; 23 this.exception = null; 24 } 25 26 Response(int id, EXC exception) { 27 this.id = id; 28 this.returnValue = null; 29 this.exception = exception; 30 } 31 32 35 @Override 36 protected void execute(Channel channel) { 37 Request req = channel.pendingCalls.get(id); 38 if(req==null) 39 return; req.onCompleted(this); 41 channel.pendingCalls.remove(id); 42 } 43 44 public String toString() { 45 return "Response[retVal="+toString(returnValue)+",exception="+toString(exception)+"]"; 46 } 47 48 private static String toString(Object o) { 49 if(o==null) return "null"; 50 else return o.toString(); 51 } 52 53 private static final long serialVersionUID = 1L; 54 } 55 | Popular Tags |