Why don't you just subclass TimerTask like this:

public abstract class MyTimerTask extends TimerTask {
public void run() {
    try {
        runImpl();
    }
    catch (RuntimeException rte) {
        log(rte);
    }
}

public abstract void runImpl();
}
}

And then implement runImpl() instead of run()?

-hendrik

tagtraum industries incorporated
1412 Glenwood Ave 1B
Raleigh, NC 27605
USA
+1 919 637 1661
http://www.tagtraum.com/


On Jun 14, 2005, at 12:52, Christopher L Merrill wrote:

Richard O. Hammer wrote:

I might get what I want by extending both Timer and TimerTask, but I thought object oriented design offered simpler ways to achieve such simple augmentations in behavior.


It does, but the author of the Timer class would have to take that
into consideration in order expose the functionality you wish to extend.

In this case, the functionality is contained within the TimerThread
class, which is not made public -- making it completely impossible
for you to extend.  This is not a failure of OO so much as it is a
failure of the author to anticipate future needs.  From a quick
perusal of the source, there was no consideration given to the
situation you encoutered in the design.

Clearly the author intended you to catch any exceptions before
propogating them to the TimerThread.  Following with that design
philosophy, you should put a try...catch(Throwable) around all
your "run" methods.


C


--
---------------------------------------------------------------------- ---
Chris Merrill                  |  http://www.webperformanceinc.com
Web Performance Inc.

Website Load Testing and Stress Testing Software
---------------------------------------------------------------------- ---

_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org



_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to