/** * Indicates if there is a next Restlet. * * @return True if there is a next Restlet. */ public boolean hasNext() { return getNext() != null; }
/** * Releases the resource by stopping any connector automatically created and * associated to the "next" property (see {@link #getNext()} method. */ @Override protected void doRelease() throws ResourceException { if ((getNext() != null) && this.nextCreated) { if (getNext() instanceof Restlet) { try { ((Restlet) getNext()).stop(); } catch (Exception e) { throw new ResourceException(e); } } setNext(null); } }
/** * Handles the outbound call by invoking the next handler. * * @param request * The request to handle. * @return The response created. * @see #getNext() */ public Response handleOutbound(Request request) { Response response = createResponse(request); Uniform next = getNext(); if (next != null) { // Effectively handle the call handle(request, response, null, 0, next); // Update the last received response. setResponse(response); } else { getLogger() .warning( "Unable to process the call for a client resource. No next Restlet has been provided."); } return response; }
/** * Constructor. * * @param resource * The client resource to copy. */ public ClientResource(ClientResource resource) { Request request = new Request(resource.getRequest()); Response response = new Response(request); this.next = resource.getNext(); this.maxRedirects = resource.getMaxRedirects(); this.retryOnError = resource.isRetryOnError(); this.retryDelay = resource.getRetryDelay(); this.retryAttempts = resource.getRetryAttempts(); this.followingRedirects = resource.isFollowingRedirects(); this.requestEntityBuffering = resource.isRequestEntityBuffering(); this.responseEntityBuffering = resource.isResponseEntityBuffering(); setApplication(resource.getApplication()); init(resource.getContext(), request, response); }