public void handleRestRequest(RestRequest req, Map<String, String> wireAttrs,
RequestContext requestContext,
TransportCallback<RestResponse> callback)
{
final URI address = req.getURI();
final RestRequestHandler handler = _restHandlers.get(address);
if (handler == null)
{
final RestResponse response =
RestStatus.responseForStatus(RestStatus.NOT_FOUND, "No resource for URI: " + address);
callback.onResponse(TransportResponseImpl.success(response));
return;
}
try
{
handler.handleRequest(req, requestContext, new TransportCallbackAdapter<RestResponse>(callback));
}
catch (Exception e)
{
final Exception ex = RestException.forError(RestStatus.INTERNAL_SERVER_ERROR, e);
callback.onResponse(TransportResponseImpl.<RestResponse>error(ex));