/** * Clears the thread local variables set by the Restlet API and engine. */ public static void clearThreadLocalVariables() { Response.setCurrent(null); Context.setCurrent(null); org.restlet.routing.VirtualHost.setCurrent(null); org.restlet.Application.setCurrent(null); }
@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 a call. * * @param request * The request to handle. * @param response * The response to update. */ public void handle(Request request, Response response) { // Associate the response to the current thread Response.setCurrent(response); // Associate the context to the current thread if (getContext() != null) { Context.setCurrent(getContext()); } }
/** * Handles a call. * * @param request * The request to handle. * @param response * The response to update. */ public void handle(Request request, Response response) { // Associate the response to the current thread Response.setCurrent(response); // Associate the context to the current thread if (getContext() != null) { Context.setCurrent(getContext()); } }
/** * Handles the call by distributing it to the next Restlet. If no Restlet is * attached, then a {@link Status#SERVER_ERROR_INTERNAL} status is returned. * Returns {@link #CONTINUE} by default. * * @param request * The request to handle. * @param response * The response to update. * @return The continuation status. Either {@link #CONTINUE} or * {@link #STOP}. */ protected int doHandle(Request request, Response response) { final int result = CONTINUE; if (getNext() != null) { getNext().handle(request, response); // Re-associate the response to the current thread Response.setCurrent(response); // Associate the context to the current thread if (getContext() != null) { Context.setCurrent(getContext()); } } else { response.setStatus(Status.SERVER_ERROR_INTERNAL); getLogger() .warning( "A filter was executed without a next Restlet attached to it."); } return result; }
if (getTarget() != null) { Context.setCurrent(getContext());
Context.setCurrent(getContext());
if (getTarget() != null) { Context.setCurrent(getContext());
if (getTarget() != null) { Context.setCurrent(getContext());
Context.setCurrent(getContext());
Context.setCurrent(getContext());