0% found this document useful (0 votes)
106 views

Java Task Scheduler

The java class schedules tasks to start and repeat at times specified in a properties file. It runs continuously until an end event is triggered by creating a file. The class reads the properties file to determine the start and repeat times for up to three tasks. When the end file is created, it waits for active tasks to finish and then ends.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views

Java Task Scheduler

The java class schedules tasks to start and repeat at times specified in a properties file. It runs continuously until an end event is triggered by creating a file. The class reads the properties file to determine the start and repeat times for up to three tasks. When the end file is created, it waits for active tasks to finish and then ends.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Object This document describes a sample java class that is able to schedule task activities to start at the specified

time, and to repeat them at the specified time interval. Description Development environment: Eclipse Java EE IDE for Web Developers Java ersion %.&.' util.scheduler.Scheduler This class schedules the tasks accordin( to the timin( specified in properties file parameters.properties. The name of properties file is read as parameter. The main operations performed b) this class are: - to read the properties file - to check if one instance of the class is alread) active, in that case the "cheduler ends - to start and repeat the tasks: Task%, Task$, Task*, + - to catch the event to stop - to ,ait until all tasks are ended, and then end itself The class is runnin( until it receives the event to end. The event to end is raised ,hen is created the file specified in the parameter file.to.end in the properties file. E-ample: If in the properties file file.to.end=/sample/stop.txt, then ,hen the file stop.txt is created in the folder /sample, le "cheduler ends. util.scheduler.TaskN where N=1,2,3, This class is the activit) task. In the method performAction() is defined the activit) to e-ecute. para eters.properties ersion: !elios "ervice #elease $

.ll parameters are in the properties file: parameters.properties. In the follo,in( table are described the parameters:

!ara

eters

Description Wait seconds bet,een t,o successive checks on runnin( tasks before end the "cheduler Wait seconds bet,een t,o successive checks on the re/uest to end the "cheduler alue: true0false. If true onl) one instance of the "cheduler can be active 1ame of the file the "cheduler creates ,hen it starts and deletes ,hen it ends 1ame of the file that the "cheduler checks ,hen it has been re/uested to end. This file is deleted b) the application just before endin( 2inutes after that task% starts 2inutes after that task% is repeated 2inutes after that task$ starts 2inutes after that task$ is repeated 2inutes after that task* starts 2inutes after that task* is repeated

seconds.wait.active.tasks.end seconds.wait.response.verify check.one.instance.active file.to.start file.to.end

minutes.to.start.task1 minutes.to.repeat.task1 minutes.to.start.task2 minutes.to.repeat.task2 minutes.to.start.task3 minutes.to.repeat.task3 E-ample of ho, to start e repeat activities: minutes.to.start.task1=0 minutes.to.repeat.task1=

The activit) Task% starts immediatel) ,hen the "cheduler starts and is re-e-ecuted ever) 3 minutes. minutes.to.start.task2=1 minutes.to.repeat.task2=10 The activit) Task$ starts after % minute the "cheduler has started and is re-e-ecuted ever) %' minutes. minutes.to.start.task3=2 minutes.to.repeat.task3=1 The activit) Task* starts after $ minutes the "cheduler has started and is re-e-ecuted ever) %3 minutes.

"#ecution The script scheduler.!at"runs the "cheduler. #c$%&ro'ram"(iles"(x)*)%+,-%.ava*0%/re%!in%/ava.exe#"0classpath"scheduler./ar" util.scheduler.1cheduler"parameters.properties ,here: #c$%&ro'ram"(iles"(x)*)%+,-%.ava*0%/re%!in%/ava.exe#: location of java.e-e

scheduler./ar: java packa(e util.scheduler.1cheduler: java class to e-ecute parameters.properties: properties file

You might also like