1 /******************************************************************************* 2 * Copyright (c) 2000, 2006 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.core.runtime; 12 13 /** 14 * Safe runnables represent blocks of code and associated exception 15 * handlers. They are typically used when a plug-in needs to call some 16 * untrusted code (e.g., code contributed by another plug-in via an 17 * extension). 18 * <p> 19 * This interface can be used without OSGi running. 20 * </p><p> 21 * Clients may implement this interface. 22 * </p> 23 * @see Platform#run(ISafeRunnable) 24 */ 25 public interface ISafeRunnable { 26 /** 27 * Handles an exception thrown by this runnable's <code>run</code> 28 * method. The processing done here should be specific to the 29 * particular usecase for this runnable. Generalized exception 30 * processing (e.g., logging in the platform's log) is done by the 31 * Platform's run mechanism. 32 * 33 * @param exception an exception which occurred during processing 34 * the body of this runnable (i.e., in <code>run()</code>) 35 * @see Platform#run(ISafeRunnable) 36 */ 37 public void handleException(Throwable exception); 38 39 /** 40 * Runs this runnable. Any exceptions thrown from this method will 41 * be passed to this runnable's <code>handleException</code> 42 * method. 43 * 44 * @exception Exception if a problem occurred while running this method. 45 * The exception will be processed by <code>handleException</code> 46 * @see Platform#run(ISafeRunnable) 47 */ 48 public void run() throws Exception; 49 } 50