01: /* Copyright 2001 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.utils.threading;
07:
08: /**
09: * This class exists as a convenience to execute Runnables. Although it
10: * may seem redundant, it is useful in that the superclass run() will
11: * appropriately catch and store Exceptions, so that callers need not worry
12: * about catching and handling them in their Runnable implementation.
13: * @author Aaron Hamid (arh14 at cornell dot edu)
14: */
15: public class RunnableTask extends BaseTask {
16: protected Runnable runnable;
17:
18: /**
19: * Constructs a RunnableTask with a Runnable object
20: * @param runnable a runnable implementation
21: */
22: public RunnableTask(Runnable runnable) {
23: this .runnable = runnable;
24: }
25:
26: /**
27: * Simply calls the run() on the runnable that this
28: * RunnableTask was constructed with. BaseTask
29: * will catch and store any Exception the runnable,
30: * and hence this method, throws.
31: */
32: public void execute() throws Exception {
33: // may throw RuntimeExceptions
34: // BaseTask will catch and expose them
35: // through getException
36: this.runnable.run();
37: }
38: }
|