Produced by Araxis Merge on 12/13/2018 10:35:25 AM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\batchprocess | BatchProcessInvoker.java | Fri Dec 7 17:36:24 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\batchprocess | BatchProcessInvoker.java | Wed Dec 12 22:26:41 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 588 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /********* ********** ********** ********** ********** ********** ********* | |
| 2 | * Copyrii ght 2005 V HA. All ri ghts reser ved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | ||
| 5 | package go v.va.med.f w.batchpro cess; | |
| 6 | ||
| 7 | import jav a.util.Arr ayList; | |
| 8 | import jav a.util.Col lection; | |
| 9 | import jav a.util.Ite rator; | |
| 10 | import jav a.util.Lis t; | |
| 11 | import jav a.util.Map ; | |
| 12 | import jav a.util.Res ourceBundl e; | |
| 13 | import jav a.util.Tre eMap; | |
| 14 | ||
| 15 | import org .apache.co mmons.lang .StringUti ls; | |
| 16 | import org .quartz.Tr igger; | |
| 17 | import org .springfra mework.bea ns.factory .BeanFacto ryUtils; | |
| 18 | import org .springfra mework.sch eduling.qu artz.JobDe tailAwareT rigger; | |
| 19 | import org .springfra mework.sch eduling.qu artz.JobDe tailBean; | |
| 20 | ||
| 21 | import gov .va.med.fw .schedulin g.Schedule dProcessIn vocationCo ntext; | |
| 22 | import gov .va.med.fw .schedulin g.Schedule dProcessTr iggerEvent ; | |
| 23 | import gov .va.med.fw .security. SecurityCo ntextHelpe r; | |
| 24 | import gov .va.med.fw .service.A bstractCom ponent; | |
| 25 | import gov .va.med.fw .service.S erviceExce ption; | |
| 26 | import gov .va.med.fw .service.j ms.QueueDe scriptor; | |
| 27 | import gov .va.med.fw .service.j ms.QueueMe ssageProdu cerService ; | |
| 28 | import gov .va.med.fw .service.t rigger.Tri ggerEvent; | |
| 29 | import gov .va.med.fw .service.t rigger.Tri ggerIdenti ty.Destina tionType; | |
| 30 | import gov .va.med.fw .service.t rigger.Tri ggerRouter ; | |
| 31 | import gov .va.med.fw .util.Inva lidConfigu rationExce ption; | |
| 32 | ||
| 33 | /** | |
| 34 | * Invoker for dynam ic executi on of batc h processe s. This ca n be used statically | |
| 35 | * as a bo otstrap fr om an exte rnal JVM ( eg, main m ethod) or directly i njected as | |
| 36 | * a Sprin g bean int o invoking component (eg, Stru ts action) . | |
| 37 | * | |
| 38 | * <p> | |
| 39 | * Current ly makes a n assumpti on that a JobName is unique ac ross group s. | |
| 40 | * | |
| 41 | * Created Jan 25, 2 006 4:38:5 0 PM | |
| 42 | * | |
| 43 | * DNS | |
| 44 | */ | |
| 45 | public cla ss BatchPr ocessInvok er extends AbstractC omponent { | |
| 46 | st atic Strin g CONFIG_F ILE = "con fig"; | |
| 47 | ||
| 48 | st atic Strin g CONFIG_S ERVER = "s erver"; | |
| 49 | ||
| 50 | st atic Strin g CONFIG_C ONTEXT = " context"; | |
| 51 | ||
| 52 | st atic Strin g CONFIG_F ACTORY = " factory"; | |
| 53 | ||
| 54 | st atic Strin g CONFIG_Q UEUE = "qu eue"; | |
| 55 | ||
| 56 | pr ivate Dest inationTyp e defaultD estination Type = Des tinationTy pe.BATCH_P ROCESS; | |
| 57 | ||
| 58 | pr ivate Trig gerRouter triggerRou ter; | |
| 59 | ||
| 60 | /* * | |
| 61 | * These are disconnec ted in the sense tha t they can not be dis covered in the | |
| 62 | * injected applicatio nContext. | |
| 63 | * / | |
| 64 | pr ivate List undiscove rableBatch ProcessDet ails; | |
| 65 | ||
| 66 | pr ivate stat ic Map bat chProcessD etails = n ew TreeMap (); | |
| 67 | ||
| 68 | pu blic Colle ction getB atchProces sDetails() { | |
| 69 | retu rn batchPr ocessDetai ls.values( ); | |
| 70 | } | |
| 71 | ||
| 72 | pr ivate void initializ eBatchProc essDetails () { | |
| 73 | // i nitializeU nscheduled BatchProce ssDetails( ); | |
| 74 | init ializeSche duledBatch ProcessDet ails(); | |
| 75 | init ializeUndi scoverable BatchProce ssDetails( ); | |
| 76 | // b atchProces sDetails.r emove("sch eduledJob. StandardRe portGenera tion"); | |
| 77 | } | |
| 78 | ||
| 79 | pr ivate void initializ eUndiscove rableBatch ProcessDet ails() { | |
| 80 | Iter ator itr = undiscove rableBatch ProcessDet ails != nu ll ? undis coverableB atchProces sDetails | |
| 81 | .iterato r() | |
| 82 | : null; | |
| 83 | whil e (itr != null && it r.hasNext( )) { | |
| 84 | BatchP rocessDeta il detail = (BatchPr ocessDetai l) itr.nex t(); | |
| 85 | batchP rocessDeta ils.put(de tail.getJo bName(), d etail); | |
| 86 | } | |
| 87 | } | |
| 88 | ||
| 89 | pr ivate void initializ eScheduled BatchProce ssDetails( ) { | |
| 90 | // o nly discov er Trigger s in the C ontext tha t are stat ically hoo ked up | |
| 91 | // t o a Job | |
| 92 | Map beans = Be anFactoryU tils.beans OfTypeIncl udingAnces tors(getAp plicationC ontext(), | |
| 93 | JobDetai lAwareTrig ger.class) ; | |
| 94 | Iter ator itr = beans != null ? bea ns.values( ).iterator () : null; | |
| 95 | JobD etailAware Trigger tr igger = nu ll; | |
| 96 | Batc hProcessDe tail detai l = null; | |
| 97 | whil e (itr != null && it r.hasNext( )) { | |
| 98 | trigge r = (JobDe tailAwareT rigger) it r.next(); | |
| 99 | if (tr igger.getJ obDetail() != null) { | |
| 100 | detail = new Batch ProcessDet ail(); | |
| 101 | detail.s etJobName( trigger.ge tJobDetail ().getKey( ).getName( )); | |
| 102 | detail.s etJobDescr iption(tri gger.getJo bDetail(). getDescrip tion()); | |
| 103 | detail.s etGroupNam e(trigger. getJobDeta il().getKe y().getGro up()); | |
| 104 | detail.s etDestinat ionType(de faultDesti nationType ); | |
| 105 | if (trig ger instan ceof Trigg er) { | |
| 106 | detail.set TriggerNam e(((Trigge r) trigger ).getKey() .getName() ); | |
| 107 | detail.set TriggerGro up(((Trigg er) trigge r).getKey( ).getGroup ()); | |
| 108 | } | |
| 109 | batchPro cessDetail s.put(deta il.getJobN ame(), det ail); | |
| 110 | } | |
| 111 | } | |
| 112 | } | |
| 113 | ||
| 114 | pr ivate void initializ eUnschedul edBatchPro cessDetail s() { | |
| 115 | Map beans = Be anFactoryU tils.beans OfTypeIncl udingAnces tors(getAp plicationC ontext(), | |
| 116 | JobDetai lBean.clas s); | |
| 117 | Iter ator itr = beans != null ? bea ns.values( ).iterator () : null; | |
| 118 | JobD etailBean jobDetailB ean = null ; | |
| 119 | Batc hProcessDe tail detai l = null; | |
| 120 | whil e (itr != null && it r.hasNext( )) { | |
| 121 | jobDet ailBean = (JobDetail Bean) itr. next(); | |
| 122 | detail = new Bat chProcessD etail(); | |
| 123 | detail .setJobNam e(jobDetai lBean.getK ey().getNa me()); | |
| 124 | detail .setJobDes cription(j obDetailBe an.getDesc ription()) ; | |
| 125 | detail .setGroupN ame(jobDet ailBean.ge tKey().get Group()); | |
| 126 | detail .setDestin ationType( defaultDes tinationTy pe); | |
| 127 | batchP rocessDeta ils.put(de tail.getJo bName(), d etail); | |
| 128 | } | |
| 129 | } | |
| 130 | ||
| 131 | pu blic void invokeBatc hProcessWi thEvent(St ring jobNa me) throws ServiceEx ception { | |
| 132 | Batc hProcessDe tail detai l = (Batch ProcessDet ail) batch ProcessDet ails.get(j obName); | |
| 133 | invo keBatchPro cessWithEv ent(detail ); | |
| 134 | } | |
| 135 | ||
| 136 | pu blic Batch ProcessDet ail getBat chProcessD etail(Stri ng jobName ) { | |
| 137 | retu rn (BatchP rocessDeta il) batchP rocessDeta ils.get(jo bName); | |
| 138 | } | |
| 139 | ||
| 140 | pu blic void invokeBatc hProcessWi thEvent(Ba tchProcess Detail det ail, Objec t[] invoca tionArgs) | |
| 141 | throws ServiceEx ception { | |
| 142 | trig gerRouter. processTri ggerEvent( createTrig gerEvent(d etail, inv ocationArg s)); | |
| 143 | } | |
| 144 | ||
| 145 | pu blic void invokeBatc hProcessWi thEvent(Ba tchProcess Detail det ail, | |
| 146 | Schedu ledProcess Invocation Context in vContext) throws Ser viceExcept ion { | |
| 147 | trig gerRouter. processTri ggerEvent( createTrig gerEvent(d etail, inv Context)); | |
| 148 | } | |
| 149 | ||
| 150 | pu blic void invokeBatc hProcessWi thEvent(Ba tchProcess Detail det ail) throw s ServiceE xception { | |
| 151 | invo keBatchPro cessWithEv ent(detail , (Object[ ]) null); | |
| 152 | } | |
| 153 | ||
| 154 | pu blic void afterPrope rtiesSet() { | |
| 155 | // V alidate.no tNull(trig gerRouter, "A Trigge rRouter is required" ); | |
| 156 | init ializeBatc hProcessDe tails(); | |
| 157 | } | |
| 158 | ||
| 159 | pr otected Tr iggerEvent createTri ggerEvent( BatchProce ssDetail d etail, Obj ect[] invo cationArgs ) { | |
| 160 | retu rn createT riggerEven t(detail, null, invo cationArgs , | |
| 161 | (detail. getDestina tionType() != null ? detail.ge tDestinati onType() | |
| 162 | : defaultDes tinationTy pe)); | |
| 163 | } | |
| 164 | ||
| 165 | pr otected Tr iggerEvent createTri ggerEvent( BatchProce ssDetail d etail, | |
| 166 | Schedu ledProcess Invocation Context in vContext) { | |
| 167 | retu rn createT riggerEven t(detail, invContext , null, | |
| 168 | (detail. getDestina tionType() != null ? detail.ge tDestinati onType() | |
| 169 | : defaultDes tinationTy pe)); | |
| 170 | } | |
| 171 | ||
| 172 | pr otected st atic Trigg erEvent cr eateTrigge rEvent(Bat chProcessD etail deta il, | |
| 173 | Schedu ledProcess Invocation Context in vContext, Object[] i nvocationA rgs, | |
| 174 | Destin ationType dest) { | |
| 175 | if ( invContext == null) { | |
| 176 | invCon text = new Scheduled ProcessInv ocationCon text(); | |
| 177 | ||
| 178 | // Set common pr operties | |
| 179 | invCon text.setJo bDetailBea nName(deta il.getJobN ame()); | |
| 180 | invCon text.setJo bName(deta il.getJobN ame()); | |
| 181 | invCon text.setJo bGroup(det ail.getGro upName()); | |
| 182 | if (in vocationAr gs != null ) | |
| 183 | invConte xt.setInvo cationArgu ments(invo cationArgs .length == 1 ? invoc ationArgs[ 0] | |
| 184 | : invocation Args); | |
| 185 | String userName = Security ContextHel per.getUse rName(); | |
| 186 | if (St ringUtils. isNotBlank (userName) ) | |
| 187 | invConte xt.setExec utionConte xt(userNam e); | |
| 188 | } | |
| 189 | ||
| 190 | // C reate an e vent encap sulating a context | |
| 191 | retu rn new Sch eduledProc essTrigger Event(invC ontext, Tr iggerEvent | |
| 192 | .createT riggerIden tity(dest) ); | |
| 193 | } | |
| 194 | ||
| 195 | pu blic stati c void inv okeBatchPr ocess(Stri ng connect ionConfigF ileName, | |
| 196 | BatchP rocessDeta il detail, Object[] executionA rgs) { | |
| 197 | Trig gerEvent t riggerEven t = create TriggerEve nt(detail, null, exe cutionArgs , detail | |
| 198 | .getDest inationTyp e()); | |
| 199 | ||
| 200 | Queu eMessagePr oducerServ ice messag eProducer = new Queu eMessagePr oducerServ ice(); | |
| 201 | mess ageProduce r.setDescr iptor(getJ MSDescript or(connect ionConfigF ileName)); | |
| 202 | ||
| 203 | try { | |
| 204 | messag eProducer. send(trigg erEvent, t riggerEven t.getRouti ngProperti es()); | |
| 205 | } ca tch (Excep tion e) { | |
| 206 | Runtim eException e2 = new InvalidCon figuration Exception( | |
| 207 | "Unable to publish T riggerEven t for batc h process: " + detai l.getJobNa me()); | |
| 208 | e2.ini tCause(e); | |
| 209 | throw e2; | |
| 210 | } | |
| 211 | } | |
| 212 | ||
| 213 | pr otected st atic Queue Descriptor getJMSDes criptor(St ring conne ctionConfi gFileName) { | |
| 214 | Reso urceBundle bundle = ResourceBu ndle.getBu ndle(conne ctionConfi gFileName) ; | |
| 215 | Queu eDescripto r jmsDescr iptor = ne w QueueDes criptor(); | |
| 216 | jmsD escriptor. setContext Name(bundl e.getStrin g(CONFIG_C ONTEXT)); | |
| 217 | jmsD escriptor. setFactory Name(bundl e.getStrin g(CONFIG_F ACTORY)); | |
| 218 | List primary = new Array List(); | |
| 219 | prim ary.add(bu ndle.getSt ring(CONFI G_SERVER)) ; | |
| 220 | jmsD escriptor. setProvide rURLs(prim ary); | |
| 221 | jmsD escriptor. setQueueNa me(bundle. getString( CONFIG_QUE UE)); | |
| 222 | retu rn jmsDesc riptor; | |
| 223 | } | |
| 224 | ||
| 225 | pr ivate stat ic void fa il() { | |
| 226 | Syst em.err | |
| 227 | .println ("\nUsage: java -Djo b.name=a - Djob.group =b BatchPr ocessInvok er [arg1 a rg2 ...arg N]"); | |
| 228 | Syst em.exit(-1 ); | |
| 229 | } | |
| 230 | ||
| 231 | /* pu blic stati c void mai n(String a rgs[]) thr ows Except ion { | |
| 232 | Stri ng jobName = System. getPropert y("job.nam e"); | |
| 233 | Stri ng jobGrou p = System .getProper ty("job.gr oup"); | |
| 234 | if ( StringUtil s.isBlank( jobName) | | StringUt ils.isBlan k(jobGroup )) | |
| 235 | fail() ; | |
| 236 | ||
| 237 | Batc hProcessDe tail detai l = new Ba tchProcess Detail(); | |
| 238 | deta il.setJobN ame(jobNam e); | |
| 239 | deta il.setGrou pName(jobG roup); | |
| 240 | ||
| 241 | deta il.setDest inationTyp e(Destinat ionType.DE FAULT); | |
| 242 | ||
| 243 | Obje ct[] invoc ationArgs = null; | |
| 244 | if ( args != nu ll && args .length != 0) { | |
| 245 | invoca tionArgs = args; | |
| 246 | } | |
| 247 | ||
| 248 | invo keBatchPro cess(CONFI G_FILE, de tail, invo cationArgs ); | |
| 249 | } | |
| 250 | */ | |
| 251 | /* * | |
| 252 | * @return R eturns the triggerRo uter. | |
| 253 | * / | |
| 254 | pu blic Trigg erRouter g etTriggerR outer() { | |
| 255 | retu rn trigger Router; | |
| 256 | } | |
| 257 | ||
| 258 | /* * | |
| 259 | * @param tr iggerRoute r | |
| 260 | * The trig gerRouter to set. | |
| 261 | * / | |
| 262 | pu blic void setTrigger Router(Tri ggerRouter triggerRo uter) { | |
| 263 | this .triggerRo uter = tri ggerRouter ; | |
| 264 | } | |
| 265 | ||
| 266 | /* * | |
| 267 | * @return R eturns the undiscove rableBatch ProcessDet ails. | |
| 268 | * / | |
| 269 | pu blic List getUndisco verableBat chProcessD etails() { | |
| 270 | retu rn undisco verableBat chProcessD etails; | |
| 271 | } | |
| 272 | ||
| 273 | /* * | |
| 274 | * @param un discoverab leBatchPro cessDetail s | |
| 275 | * The undi scoverable BatchProce ssDetails to set. | |
| 276 | * / | |
| 277 | pu blic void setUndisco verableBat chProcessD etails(Lis t undiscov erableBatc hProcessDe tails) { | |
| 278 | this .undiscove rableBatch ProcessDet ails = und iscoverabl eBatchProc essDetails ; | |
| 279 | } | |
| 280 | ||
| 281 | /* * | |
| 282 | * @return R eturns the defaultDe stinationT ype. | |
| 283 | * / | |
| 284 | pu blic Desti nationType getDefaul tDestinati onType() { | |
| 285 | retu rn default Destinatio nType; | |
| 286 | } | |
| 287 | ||
| 288 | /* * | |
| 289 | * @param de faultDesti nationType | |
| 290 | * The defa ultDestina tionType t o set. | |
| 291 | * / | |
| 292 | pu blic void setDefault Destinatio nType(Dest inationTyp e defaultD estination Type) { | |
| 293 | this .defaultDe stinationT ype = defa ultDestina tionType; | |
| 294 | } | |
| 295 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.