package Ġde . ot ton ow . schedule dt ask s . tracking Ċ Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . Response Entity Ċ import Ġorg . springframework . web . bind . annotation .* Ċ Ċ @ RestController Ċ @ RequestMapping ("\ ${ tracking . scheduled - jobs . path :/ scheduled - jobs }") Ċ @ Cross Origin Ċ open Ġclass ĠScheduled Job Controller Ġ@ Autowired Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġscheduled Job Tracker : ĠScheduled Job Tracker Ċ ) Ġ{ ĊĊĠĠĠ Ġ@ RequestMapping ( method Ġ= Ġ[ Request Method . GET ]) ĊĠĠĠ Ġopen Ġfun Ġget Scheduled Jobs (): ĠSet < Tracked Scheduled Job > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġscheduled Job Tracker . tracked Jobs ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ RequestMapping ( value Ġ= Ġ[" { className } "], Ġmethod Ġ= Ġ[ Request Method . GET ]) ĊĠĠĠ Ġopen Ġfun Ġget Scheduled Jobs Per Class (@ PathVariable ( name Ġ= Ġ" className ") ĠclassName : ĠString ): ĠList < Tracked Scheduled Job > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġscheduled Job Tracker . find Job sBy Class ( className ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ RequestMapping ( value Ġ= Ġ[" { className }/{ methodName } "], Ġmethod Ġ= Ġ[ Request Method . GET ]) ĊĠĠĠ Ġopen Ġfun Ġget Scheduled Job ( ĊĠĠĠĠĠĠĠ Ġ@ PathVariable ( name Ġ= Ġ" className ") ĠclassName : ĠString , ĊĠĠĠĠĠĠĠ Ġ@ PathVariable ( name Ġ= Ġ" methodName ") ĠmethodName : ĠString ĊĠĠĠ Ġ): ĠResponseEntity < Any > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġscheduled Job Ġ= Ġscheduled Job Tracker . find Job By Class And Method ( className , ĠmethodName ) ĊĠĠĠĠĠĠĠ Ġif Ġ( scheduled Job Ġ== Ġnull ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( HttpStatus . NOT _ FOUND ) ĊĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( scheduled Job ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ RequestMapping ( value Ġ= Ġ[" { className }/{ methodName }/{ uuid } "], Ġmethod Ġ= Ġ[ Request Method . GET ]) ĊĠĠĠ Ġopen Ġfun Ġget Scheduled Job Run ( ĊĠĠĠĠĠĠĠ Ġ@ PathVariable ( name Ġ= Ġ" className ") ĠclassName : ĠString , ĊĠĠĠĠĠĠĠ Ġ@ PathVariable ( name Ġ= Ġ" methodName ") ĠmethodName : ĠString , ĊĠĠĠĠĠĠĠ Ġ@ PathVariable ( name Ġ= Ġ" uuid ") Ġuuid : ĠString ĊĠĠĠ Ġ): ĠResponseEntity < Any > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġscheduled Job Run Ġ= Ġscheduled Job Tracker . find Run By Uuid ( className , ĠmethodName , Ġuuid ) ĊĠĠĠĠĠĠĠ Ġif Ġ( scheduled Job Run Ġ== Ġnull ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity ( HttpStatus . NOT _ FOUND ) ĊĊĠĠĠĠĠĠĠ Ġreturn ĠResponseEntity . ok ( scheduled Job Run ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ RequestMapping ( ĊĠĠĠĠĠĠĠ Ġvalue Ġ= Ġ[" { className }/{ methodName } "], ĊĠĠĠĠĠĠĠ Ġmethod Ġ= Ġ[ Request Method . POST ] ĊĠĠĠ Ġ) ĊĠĠĠ Ġopen Ġfun Ġtrigger Job ( ĊĠĠĠĠĠĠĠ Ġ@ PathVariable ( name Ġ= Ġ" className ") ĠclassName : ĠString , ĊĠĠĠĠĠĠĠ Ġ@ PathVariable ( name Ġ= Ġ" methodName ") ĠmethodName : ĠString ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġscheduled Job Tracker . trigger Job ( className , ĠmethodName ) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( exc : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ// ĠDon 't Ġcare Ġif Ġjob Ġfails , Ġsince Ġfails Ġare Ġvisible Ġas well ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }