Produced by Araxis Merge on 12/5/2017 12:06:37 PM Central 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 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreRouter\main\src\java\gov\va\med\imaging\core | RouterImpl.java | Mon Dec 4 21:34:32 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreRouter\main\src\java\gov\va\med\imaging\core | RouterImpl.java | Mon Dec 4 21:58:24 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 504 |
| 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 | package go v.va.med.i maging.cor e; | |
| 2 | ||
| 3 | import gov .va.med.Pr otocolHand lerUtility ; | |
| 4 | import gov .va.med.im aging.core .annotatio ns.routerf acade.Rout erCommandE xecution; | |
| 5 | import gov .va.med.im aging.core .interface s.IAppConf iguration; | |
| 6 | import gov .va.med.im aging.core .interface s.Router; | |
| 7 | import gov .va.med.im aging.core .interface s.exceptio ns.Connect ionExcepti on; | |
| 8 | import gov .va.med.im aging.core .interface s.exceptio ns.MethodE xception; | |
| 9 | import gov .va.med.im aging.core .interface s.router.A synchronou sCommandRe sult; | |
| 10 | import gov .va.med.im aging.core .interface s.router.C ommand; | |
| 11 | import gov .va.med.im aging.core .router.Ab stractComm andImpl; | |
| 12 | import gov .va.med.im aging.data source.Dat aSourcePro vider; | |
| 13 | import gov .va.med.im aging.data source.Pro vider; | |
| 14 | import gov .va.med.im aging.data source.Rou tingOverri deSpi; | |
| 15 | import gov .va.med.im aging.data source.Sit eResolutio nDataSourc eSpi; | |
| 16 | import gov .va.med.im aging.data source.exc eptions.No ValidServi ceConstruc torError; | |
| 17 | import gov .va.med.im aging.exch ange.confi guration.A ppConfigur ation; | |
| 18 | import gov .va.med.se rver.Serve rAdapterIm pl; | |
| 19 | import gov .va.med.se rver.Serve rLifecycle Event; | |
| 20 | import gov .va.med.se rver.Serve rLifecycle Listener; | |
| 21 | import jav a.net.Malf ormedURLEx ception; | |
| 22 | import jav a.util.Lis t; | |
| 23 | import org .apache.lo gging.log4 j.LogManag er; | |
| 24 | import org .apache.lo gging.log4 j.Logger; | |
| 25 | ||
| 26 | /** | |
| 27 | * The Rou ter is the core obje ct in the VIX system . | |
| 28 | * It take s requests from faca des and se lects a se rvice | |
| 29 | * to sati sfy the re quest. | |
| 30 | * It also deals wit h reading/ writing fr om the cac he. | |
| 31 | * | |
| 32 | * The Rou ter is the entire ex ternal int erface to the facade component s. | |
| 33 | * | |
| 34 | * @author
|
|
| 35 | * | |
| 36 | */ | |
| 37 | public cla ss RouterI mpl | |
| 38 | implements Router, S erverLifec ycleListen er | |
| 39 | { | |
| 40 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(Rout er.class); | |
| 41 | st atic | |
| 42 | { | |
| 43 | Prot ocolHandle rUtility.i nitialize( true); | |
| 44 | } | |
| 45 | ||
| 46 | pr ivate fina l AppConfi guration a ppConfigur ation; | |
| 47 | pr ivate fina l SiteReso lutionData SourceSpi siteResolv er; | |
| 48 | pr ivate fina l List<Rou tingOverri deSpi> rou tingOverri deServices ; | |
| 49 | // priv ate final IImageConv ersion ima geConversi on; | |
| 50 | pr ivate fina l DataSour ceProvider provider; | |
| 51 | ||
| 52 | // asynchron ous router commands are delega ted to a h elper clas s | |
| 53 | pr ivate fina l Asynchro nousRouter Impl async hRouter; | |
| 54 | // private fi nal Comman dFactoryIm pl asynchC ommandFact ory; | |
| 55 | ||
| 56 | pr ivate bool ean failov erOnMethod Exception = true; | |
| 57 | ||
| 58 | ||
| 59 | ||
| 60 | /* * | |
| 61 | * | |
| 62 | * @param ap pConfigura tion | |
| 63 | * @param do dCache | |
| 64 | * @param va Cache | |
| 65 | * @param im gConversio n | |
| 66 | * @param li fecycleAda pter | |
| 67 | * @throws M alformedUR LException | |
| 68 | * @throws N oValidServ iceConstru ctorError | |
| 69 | * @throws C onnectionE xception | |
| 70 | * / | |
| 71 | pu blic Route rImpl( | |
| 72 | AppC onfigurati on appConf iguration | |
| 73 | ) | |
| 74 | th rows Malfo rmedURLExc eption, Co nnectionEx ception | |
| 75 | { | |
| 76 | logg er.info("R outerImpl( ) - " + th is.hashCod e()); | |
| 77 | ||
| 78 | this .appConfig uration = appConfigu ration; | |
| 79 | // this .imageConv ersion = i mgConversi on; | |
| 80 | prov ider = new Provider( ); | |
| 81 | site Resolver = provider. createSite Resolution DataSource (); | |
| 82 | rout ingOverrid eServices = provider .createRou tingOverri deServices (); | |
| 83 | ||
| 84 | appC onfigurati on.getLoca lSiteNumbe r(); | |
| 85 | ||
| 86 | Serv erAdapterI mpl.getSin gleton().a ddServerLi fecycleLis tener(this ); | |
| 87 | ||
| 88 | logg er.info("< ctor> site resolver was" + (si teResolver == null ? " NOT " : " ") + "c reated suc cessfully. "); | |
| 89 | if(r outingOver rideServic es != null && routin gOverrideS ervices.si ze() > 0) | |
| 90 | { | |
| 91 | String msg = "Th e followin g routing overrides are in pla ce: "; | |
| 92 | for(Ro utingOverr ideSpi ove rrideServi ce : routi ngOverride Services) | |
| 93 | msg += o verrideSer vice.toStr ing() + ", "; | |
| 94 | logger .warn(msg) ; | |
| 95 | } | |
| 96 | ||
| 97 | this .asynchRou ter = new Asynchrono usRouterIm pl(this); | |
| 98 | //th is.asynchC ommandFact ory = new CommandFac toryImpl(t his, dodCa che, vaCac he); | |
| 99 | } | |
| 100 | ||
| 101 | // public voi d setAppCo nfiguratio n(AppConfi guration a ppConfigur ation) | |
| 102 | // { | |
| 103 | // this .appConfig uration = appConfigu ration; | |
| 104 | // } | |
| 105 | ||
| 106 | // --------- ---------- ---------- ---------- ---------- ---------- -------- | |
| 107 | // Applicati on Configu ration pro perties ma de availab le for com mands | |
| 108 | // --------- ---------- ---------- ---------- ---------- ---------- -------- | |
| 109 | @O verride | |
| 110 | pu blic boole an isCachi ngEnabled( ) | |
| 111 | { | |
| 112 | retu rn getAppC onfigurati on().isCac hingEnable d(); | |
| 113 | } | |
| 114 | ||
| 115 | @O verride | |
| 116 | pu blic IAppC onfigurati on getAppC onfigurati on() | |
| 117 | { | |
| 118 | retu rn appConf iguration; | |
| 119 | } | |
| 120 | ||
| 121 | pu blic SiteR esolutionD ataSourceS pi getSite Resolver() | |
| 122 | { | |
| 123 | retu rn siteRes olver; | |
| 124 | } | |
| 125 | ||
| 126 | /* * | |
| 127 | * @return t he DataSou rceProvide r | |
| 128 | * / | |
| 129 | pu blic DataS ourceProvi der getPro vider() | |
| 130 | { | |
| 131 | retu rn this.pr ovider; | |
| 132 | } | |
| 133 | ||
| 134 | /* * | |
| 135 | * The boole an propert y Failover OnMethodEx ception ef fects how the Router Impl | |
| 136 | * behaves w hen a Meth odExceptio n occurs w ithin a Se rvice impl ementation . | |
| 137 | * If Failov erOnMethod Exception is true th en the Rou terImpl wi ll attempt to | |
| 138 | * use an al ternate pr otocol to contact th e remote s ite. If a ll availab le | |
| 139 | * protocols result in failure t hen the Me thodExcept ion will b e included in a | |
| 140 | * Composite MethodExce ption, alo ng with th e Exceptio n instance s generate d from | |
| 141 | * each prot ocol attem pted. | |
| 142 | * If Failov erOnMethod Exception is false t hen a Meth odExceptio n in a | |
| 143 | * Service i mplementat ion is pas sed up to the client . | |
| 144 | * In either case all MethodExce ption occu rrences ar e logged. | |
| 145 | * @return | |
| 146 | * / | |
| 147 | pu blic boole an isFailo verOnMetho dException () | |
| 148 | { | |
| 149 | re turn failo verOnMetho dException ; | |
| 150 | } | |
| 151 | ||
| 152 | pr otected vo id setFail overOnMeth odExceptio n(boolean failoverOn MethodExce ption) | |
| 153 | { | |
| 154 | th is.failove rOnMethodE xception = failoverO nMethodExc eption; | |
| 155 | } | |
| 156 | ||
| 157 | // ========= ========== ========== ========== ========== ========== = | |
| 158 | // ServerLif ecycleList ener Imple mentation | |
| 159 | // ========= ========== ========== ========== ========== ========== = | |
| 160 | @O verride | |
| 161 | public void serv erLifecycl eEvent(Ser verLifecyc leEvent ev ent) | |
| 162 | { | |
| 163 | logg er.info("C oreRouter received a server " + event.ge tEventType ().toStrin g() + " ev ent."); | |
| 164 | } | |
| 165 | ||
| 166 | ||
| 167 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== == | |
| 168 | // Asynchron ous Proces sing Relat ed Methods | |
| 169 | // ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== == | |
| 170 | // @Override | |
| 171 | //publ ic Command Factory ge tAsynchron ousCommand Factory() | |
| 172 | //{ | |
| 173 | // return asynchComm andFactory ; | |
| 174 | //} | |
| 175 | ||
| 176 | /* * | |
| 177 | * Submit a command fo r asynchro nous execu tion, opti onally pro viding a l istener wh ere the re sults | |
| 178 | * may be co mmunicated back to t he client. | |
| 179 | * | |
| 180 | * @param co mmand - an Asynchron ousCommand instance, created b y this Rou ter's Asyn chronousCo mmandFacto ry | |
| 181 | * as return ed by the getAsynchr onousComma ndFactory( ). | |
| 182 | * @param re sultQueue - an optio nal Queue reference where the client can obtain th e result o f the asyn chronous | |
| 183 | * command | |
| 184 | * @se e gov.va.m ed.imaging .core.inte rfaces.Rou ter#doAsyn chronously (gov.va.me d.imaging. core.inter faces.Asyn chronousRo uterComman dTypes, ja va.util.Qu eue) | |
| 185 | */ | |
| 186 | @Overr ide | |
| 187 | public <T extend s Object> void doAsy nchronousl y(Command< T> command ) | |
| 188 | { | |
| 189 | if (command i nstanceof AbstractCo mmandImpl) | |
| 190 | { | |
| 191 | logg er.info("A synchronou s executio n of comma nd of type '" + comm and.getCla ss().getSi mpleName() +"' reque sted."); | |
| 192 | if(i sCommandAs ynchronous lyExecutab le(command )) | |
| 193 | { | |
| 194 | logger .info("Sub mitting co mmand of t ype '" + c ommand.get Class().ge tSimpleNam e() +"' fo r asynchro nous execu tion."); | |
| 195 | asynch Router.doA synchronou sly((Abstr actCommand Impl<?>)co mmand); | |
| 196 | } | |
| 197 | else | |
| 198 | { | |
| 199 | logger .warn("Com mand of ty pe '" + co mmand.getC lass().get SimpleName () +"' is not eligib le for asy nchronous execution and is bei ng execute d synchron ously."); | |
| 200 | try | |
| 201 | { | |
| 202 | T result = doSynchro nously(com mand); | |
| 203 | Asynchrono usCommandR esult<T> a synchResul t = new As ynchronous CommandRes ult<T>(com mand, resu lt); | |
| 204 | } | |
| 205 | catch (MethodExc eption x) | |
| 206 | { | |
| 207 | x.printSta ckTrace(); | |
| 208 | } | |
| 209 | catch (Connectio nException x) | |
| 210 | { | |
| 211 | x.printSta ckTrace(); | |
| 212 | } | |
| 213 | } | |
| 214 | } | |
| 215 | el se | |
| 216 | logg er.error(" Request fo r asynchro nous execu tion of an Command t hat is not compatibl e with thi s Router i mplementat ion."); | |
| 217 | } | |
| 218 | ||
| 219 | privat e boolean isCommandA synchronou slyExecuta ble(Comman d<?> comma nd) | |
| 220 | { | |
| 221 | Ro uterComman dExecution commandAn notation = command.g etClass(). getAnnotat ion(Router CommandExe cution.cla ss); | |
| 222 | re turn comma ndAnnotati on != null && comman dAnnotatio n.asynchro nous(); | |
| 223 | } | |
| 224 | ||
| 225 | privat e boolean isCommandD istributab le(Command <?> comman d) | |
| 226 | { | |
| 227 | Ro uterComman dExecution commandAn notation = command.g etClass(). getAnnotat ion(Router CommandExe cution.cla ss); | |
| 228 | re turn comma ndAnnotati on != null && comman dAnnotatio n.distribu table(); | |
| 229 | } | |
| 230 | ||
| 231 | /** | |
| 232 | * | |
| 233 | * @se e gov.va.m ed.imaging .core.inte rfaces.Rou ter#doSync hronously( gov.va.med .imaging.c ore.interf aces.route r.Command) | |
| 234 | * pub lic Object doSynchro nously(Com mand<?> co mmand) | |
| 235 | */ | |
| 236 | @Overr ide | |
| 237 | public <T extend s Object> T doSynchr onously(Co mmand<T> c ommand) | |
| 238 | th rows Metho dException , Connecti onExceptio n | |
| 239 | { | |
| 240 | if (command i nstanceof AbstractCo mmandImpl< ?>) | |
| 241 | { | |
| 242 | return ((Abstrac tCommandIm pl<T>)comm and).callS ynchronous ly(); | |
| 243 | } | |
| 244 | el se | |
| 245 | { | |
| 246 | logg er.error(" Request fo r synchron ous execut ion of com mand '" + | |
| 247 | (comma nd == null ? "<null> " : comman d.toString ()) + | |
| 248 | "' tha t is not c ompatible with this Router imp lementatio n."); | |
| 249 | retu rn null; | |
| 250 | } | |
| 251 | } | |
| 252 | ||
| 253 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.