1 /******************************************************************************* 2 * Copyright (c) 2005, 2007 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.debug.core; 12 13 import org.eclipse.core.runtime.IStatus; 14 15 /** 16 * Common base interface for an asynchronously processed request. A request may succeed, 17 * fail or be canceled as indicated by the request's status. When a request is complete 18 * the client fulfilling the request must call <code>done()</code> on the request whether 19 * the operation succeeds, fails, or is canceled. 20 * <p> 21 * Specific requests (sub types of this interface) often include data pertaining to 22 * the request and usually contain results of the request. 23 * </p> 24 * <p> 25 * Clients are expected to poll a request (using <code>isCanceled</code>) 26 * periodically and abort at their earliest convenience calling <code>done()</code>. 27 * A request can be canceled by the originator of the request or a client 28 * fulfilling a request. 29 * </p> 30 * <p> 31 * Clients that invoke request handlers may implemented this interface. 32 * </p> 33 * @since 3.3 34 */ 35 public interface IRequest { 36 37 /** 38 * Sets the status for this request indicating whether this request 39 * succeeded, failed, or was canceled. When a request fails, the status 40 * indicates why the request failed. A <code>null</code> status is considered 41 * to be successful. Only clients fulfilling a request should call this 42 * method. Clients making a request are not intended to call this method. 43 * 44 * @param status request status or <code>null</code> 45 */ 46 public void setStatus(IStatus status); 47 48 /** 49 * Returns the status of this request, or <code>null</code>. 50 * 51 * @return request status - <code>null</code> is equivalent 52 * to an OK status 53 */ 54 public IStatus getStatus(); 55 56 /** 57 * Indicates this request is complete. Clients must call this method 58 * whether the request succeeds, fails, or is cancelled to indicate that 59 * processing is complete. Only clients fulfilling a request should call this 60 * method. Clients making a request are not intended to call this method. 61 */ 62 public void done(); 63 64 /** 65 * Cancels this request. A request may be canceled by the originator of request 66 * or a client fulfilling a request. Optionally a canceled status may be set on 67 * this request with more details. A client fulfilling a request must still call 68 * <code>done()</code> to indicate the request is complete. 69 */ 70 public void cancel(); 71 72 /** 73 * Returns whether this request has been canceled. 74 * <p> 75 * Clients fulfilling a request are expected to poll a request (using <code>isCanceled</code>) 76 * periodically and abort at their earliest convenience calling <code>done()</code>. 77 * A request can be canceled by the originator of the request or a processor fulfilling a 78 * request. 79 * </p> 80 * @return whether this request has been canceled 81 */ 82 public boolean isCanceled(); 83 84 } 85