Example #1
0
  @RequestMapping(
      value = VIEW_API_REQUEST,
      method = {RequestMethod.POST, RequestMethod.GET})
  public void listAllSupportedActions(
      HttpServletRequest request,
      HttpServletResponse response,
      @RequestParam(value = "url", required = false) String url)
      throws IOException {

    if (url == null) {
      StringBuilder sb = new StringBuilder();
      sb.append("<html><body>");
      for (String key : SERVICE_SUPPORT_MAP.keySet()) {
        RequestResponse rr = SERVICE_SUPPORT_MAP.get(key);
        sb.append("<div>url : ").append(key).append("</div>");
        sb.append("<div style=\"padding-left:15px>\">")
            .append(rr.getRequest().getDescriptorForType().getFullName())
            .append(" : ")
            .append(rr.getResponse().getDescriptorForType().getFullName())
            .append("</div>");
      }
      sb.append("</body></hhtml>");
      response.getOutputStream().write(sb.toString().getBytes());
      return;
    }

    apiRequested(response, true, url);
    return;
  }
Example #2
0
 public void onMessage(String message) {
   if (LOG.isLoggable(Level.FINE)) {
     LOG.log(Level.FINE, "onMessage({0})", message);
   }
   Response resp = new Response(responseIdKey, message);
   RequestResponse rr = uncorrelatedRequests.get(resp.getId());
   if (rr != null) {
     synchronized (rr) {
       rr.setResponse(resp);
       rr.notifyAll();
     }
   }
 }
Example #3
0
 private boolean apiRequested(HttpServletResponse response, boolean api, String request)
     throws IOException {
   if (api) {
     RequestResponse rr = SERVICE_SUPPORT_MAP.get(request);
     if (rr != null) {
       StringBuffer sb = new StringBuffer();
       sb.append(rr.getRequest().getDescriptorForType().getFullName())
           .append(" : ")
           .append(rr.getResponse().getDescriptorForType().getFullName());
       response.getOutputStream().write(sb.toString().getBytes());
     } else {
       response.getOutputStream().write("No matching service for url".getBytes());
     }
     return true;
   }
   return false;
 }
Example #4
0
 Response getResponse() throws IOException {
   if (response == null) {
     String rid = entity.getId();
     RequestResponse rr = uncorrelatedRequests.get(rid);
     synchronized (rr) {
       try {
         long timetowait = entity.getReceiveTimeout();
         response = rr.getResponse();
         if (response == null) {
           rr.wait(timetowait);
           response = rr.getResponse();
         }
       } catch (InterruptedException e) {
         // ignore
       }
     }
     if (response == null) {
       throw new SocketTimeoutException("Read timed out while invoking " + entity.getUri());
     }
   }
   return response;
 }