Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Add throws clause to run() method of TimeTask object

843833Feb 2 2006 — edited Feb 14 2006
I am creating a struts application.
I have an action class that creates an object of Timer class and calls its schedule() method with a parameter of the TimerTask object. This method call executes the code written in the run() method of the TimerTask object.

My problem is that I want to return a user defined exception from this run method to the calling class i.e. the action class. But the run() method of the TimeTask object does not support any "throws" clause.

Any suggestions?

This is the code:


//Action Class:::::::::::::::::::::::::
public class Schedule extends LookupDispatchAction
{

public ActionForward startSchedule (ActionMapping am, ActionForm af,
HttpServletRequest req, HttpServletResponse res) throws Exception
{
Timer objTimer = new Timer();
OspTimerTask objOspTimerTask = new OspTimerTask();

Calendar cal = Calendar.getInstance();
objTimer.schedule(objOspTimerTask,cal.getTime(),interMilliSec);

// some code..

return...
}
}




//TimerTask implementation:::::::::::::::::::::::::::::::::::::::::::::

public class OspTimerTask extends TimerTask
{
public void run() <I want "throws" clause here>
{
try
{
//some code...
}
catch(SQLExecption e)
{
throw new UserDefinedException("My Message");
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2006
Added on Feb 2 2006
3 comments
251 views