@Override public void run() { // Copy the thread local variables Response.setCurrent(currentResponse); Context.setCurrent(currentContext); org.restlet.routing.VirtualHost.setCurrent(currentVirtualHost); org.restlet.Application.setCurrent(currentApplication); try { // Run the user task runnable.run(); } finally { Engine.clearThreadLocalVariables(); } }
/** * Handles the connector call. The default behavior is to create an REST * call and delegate it to the attached Restlet. * * @param httpCall * The HTTP server call. */ public void handle(ServerCall httpCall) { try { HttpRequest request = getAdapter().toRequest(httpCall); HttpResponse response = new HttpResponse(httpCall, request); handle(request, response); getAdapter().commit(response); } catch (Exception e) { getLogger().log(Level.WARNING, "Error while handling an HTTP server call", e); } finally { Engine.clearThreadLocalVariables(); } }