package Ġio . hol unda . ext . custom job Ċ Ċ import Ġio . hol unda . job . Custom Job Handler Builder Ċ import Ġio . hol unda . job . api .* Ċ import Ġorg . camunda . bpm . engine . impl . cfg . Process Engine Configuration Impl Ċ import Ġorg . camunda . bpm . engine . impl . context . Context Ċ import Ġorg . camunda . bpm . engine . impl . interceptor . Command Ċ import Ġorg . camunda . bpm . engine . impl . persistence . entity . Message Entity Ċ import Ġorg . camunda . bpm . engine . impl . persistence . entity . Timer Entity Ċ import Ġjava . util .* Ċ Ċ class ĠCam unda Job Gateway ( private Ġval Ġconfiguration : ĠProcess Engine Configuration Impl , Ġprivate Ġval Ġjob Handler Builder : ĠCustom Job Handler Builder ) Ġ: ĠCreate Job Gateway Ġ{ ĊĊĠ Ġoverride Ġfun Ġsend ( cmd : ĠCreate Job Command ): ĠString Ġ= Ġexecute ( when Ġ( cmd ) Ġ{ ĊĠĠĠ Ġis ĠSchedule Job Command Ġ-> Ġto Cam unda Command ( cmd ) ĊĠĠĠ Ġis ĠInsert Job Command Ġ-> Ġto Cam unda Command ( cmd ) ĊĠ Ġ}) ĊĊĠ Ġprivate Ġfun ĠJob Payload . to Config () Ġ= Ġjob Handler Builder . job Handler Configuration ( this ) ĊĊĠ Ġprivate Ġfun Ġto Cam unda Command ( cmd : ĠSchedule Job Command ) Ġ= ĠCommand Ġ{ ĊĠĠĠ Ġval Ġjob Ġ= ĠTimer Entity (). apply Ġ{ ĊĠĠĠĠĠ Ġjob Handler Type Ġ= Ġcmd . job Handler Type ĊĠĠĠĠĠ Ġdu ed ate Ġ= ĠDate . from ( cmd . due Date ) ĊĠĠĠĠĠ Ġjob Handler Configuration Ġ= Ġcmd . payload . to Config () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġit . job Manager . schedule ( job ) ĊĊĠĠĠ Ġreturn @ Command Ġjob . id ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġto Cam unda Command ( cmd : ĠInsert Job Command ) Ġ= ĠCommand Ġ{ ĊĠĠĠ Ġval Ġjob Ġ= ĠMessage Entity (). apply Ġ{ ĊĠĠĠĠĠ Ġjob Handler Type Ġ= Ġcmd . job Handler Type ĊĠĠĠĠĠ Ġjob Handler Configuration Ġ= Ġcmd . payload . to Config () ĊĠĠĠ Ġ} ĊĠĠĠ Ġit . job Manager . insert Job ( job ) ĊĊĠĠĠ Ġreturn @ Command Ġjob . id ĊĠ Ġ} ĊĊĊĊĠ Ġprivate Ġfun Ġexecute ( command : ĠCommand < String >): ĠString Ġ= ĊĠĠĠ Ġif Ġ( Context . get Command Context () Ġ== Ġnull ) ĊĠĠĠĠĠ Ġconfiguration . command Executor Tx Required . execute ( command ) ĊĠĠĠ Ġelse ĊĠĠĠĠĠ Ġcommand . execute ( Context . get Command Context ()) Ċ } ĊĊ