1 /******************************************************************************* 2 * Copyright (c) 2004, 2005 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.osgi.service.runnable; 12 13 /** 14 * Like a {@link java.lang.Runnable}, an object which captures a block of code which can 15 * be passed around and executed. Unlike standard runnables, paramaterized 16 * runnables allow an arbitrary {@link java.lang.Object} to be passed in when the 17 * block is evaluated. 18 * <p> 19 * Clients may implement this interface. 20 * </p> 21 * @since 3.0 22 */ 23 public interface ParameterizedRunnable { 24 25 /** 26 * Executes the block of code encapsulated by this runnable in the context of 27 * the given object and returns the result. The result may be <code>null</code>. 28 * 29 * @param context the context for evaluating the runnable 30 * @return the result of evaluating the runnable in the given context 31 * @throws Exception if there is a problem running this runnable 32 */ 33 public Object run(Object context) throws Exception; 34 } 35