Produced by Araxis Merge on 7/6/2017 8:23:35 PM Central Daylight 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 | OSCIF_CTT_v4_build 1.zip\VUID-rest\src\main\java\gov\vha\vuid\rest | ApplicationConfig.java | Wed May 31 03:59:14 2017 UTC |
| 2 | OSCIF_CTT_v4_build 1.zip\VUID-rest\src\main\java\gov\vha\vuid\rest | ApplicationConfig.java | Mon Jul 3 18:55:26 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 472 |
| 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.vha.vuid .rest; | |
| 2 | ||
| 3 | import jav a.util.con current.at omic.Atomi cInteger; | |
| 4 | import jav ax.servlet .ServletCo ntext; | |
| 5 | import jav ax.ws.rs.A pplication Path; | |
| 6 | import jav ax.ws.rs.c ore.Contex t; | |
| 7 | import org .apache.lo gging.log4 j.LogManag er; | |
| 8 | import org .apache.lo gging.log4 j.Logger; | |
| 9 | import org .glassfish .jersey.ja ckson.Jack sonFeature ; | |
| 10 | import org .glassfish .jersey.se rver.Resou rceConfig; | |
| 11 | import org .glassfish .jersey.se rver.spi.C ontainer; | |
| 12 | import org .glassfish .jersey.se rver.spi.C ontainerLi fecycleLis tener; | |
| 13 | import gov .vha.isaac .ochre.api .LookupSer vice; | |
| 14 | import gov .vha.isaac .ochre.api .util.Work Executors; | |
| 15 | import gov .vha.vuid. rest.api1. data.RestS ystemInfo; | |
| 16 | import gov .vha.vuid. rest.api1. RestPaths; | |
| 17 | import gov .vha.vuid. rest.data. VuidServic e; | |
| 18 | import jav afx.beans. property.S impleStrin gProperty; | |
| 19 | import jav afx.beans. property.S tringPrope rty; | |
| 20 | ||
| 21 | @Applicati onPath(Res tPaths.app PathCompon ent) | |
| 22 | public cla ss Applica tionConfig extends R esourceCon fig implem ents Conta inerLifecy cleListene r | |
| 23 | { | |
| 24 | pr ivate stat ic final A tomicInteg er startup = new Ato micInteger (1); | |
| 25 | pr ivate Logg er log = L ogManager. getLogger( Applicatio nConfig.cl ass); | |
| 26 | ||
| 27 | pr ivate stat ic Applica tionConfig instance_ ; | |
| 28 | ||
| 29 | pr ivate Stri ngProperty status_ = new Simpl eStringPro perty("Not Started") ; | |
| 30 | pr ivate bool ean debugM ode = true ; | |
| 31 | pr ivate bool ean shutdo wn = false ; | |
| 32 | pr ivate bool ean initia lStartupCo mplete = f alse; | |
| 33 | pr ivate int PORT = P ; | |
| 34 | pr ivate Stri ng hostnam e; | |
| 35 | pr ivate Rest SystemInfo systemInf o_; | |
| 36 | ||
| 37 | // Note - thi s injectio n works fi ne, when d eployed as a war to tomcat. H owever, wh en launche d in the l ocalJettyR unner from eclipse, | |
| 38 | // this remai ns null. | |
| 39 | @C ontext | |
| 40 | Se rvletConte xt context _; | |
| 41 | ||
| 42 | pr ivate Stri ng context Path; | |
| 43 | ||
| 44 | pu blic Appli cationConf ig() | |
| 45 | { | |
| 46 | //If we leave everything to annota tions, is picks up t he eclipse moxy gson writer, w hich doesn 't handle abstract c lasses pro perly. | |
| 47 | //Th e goal her e is to fo rce it to use Jackso n, but it seems that registeri ng jackson disables scanning, so also ha ve to re-e nable | |
| 48 | //sc anning. I t also see ms to forg et to scan this clas s... so re gister its elf.. | |
| 49 | supe r(new Reso urceConfig ().package s("gov.vha .vuid.rest ").registe r(JacksonF eature.cla ss).regist er(Applica tionConfig .class)); | |
| 50 | } | |
| 51 | ||
| 52 | pu blic stati c Applicat ionConfig getInstanc e() | |
| 53 | { | |
| 54 | retu rn instanc e_; | |
| 55 | } | |
| 56 | ||
| 57 | @O verride | |
| 58 | pu blic void onReload(C ontainer a rg0) | |
| 59 | { | |
| 60 | // T ODO determ ine if Vui dService s hould be r einitializ ed onReloa d() | |
| 61 | } | |
| 62 | ||
| 63 | @O verride | |
| 64 | pu blic void onShutdown (Container arg0) | |
| 65 | { | |
| 66 | shut down = tru e; | |
| 67 | log. info("Stop ping VUID Service"); | |
| 68 | Look upService. shutdownSy stem(); | |
| 69 | init ialStartup Complete = false; | |
| 70 | log. info("VUID Service s topped"); | |
| 71 | } | |
| 72 | ||
| 73 | @O verride | |
| 74 | pu blic void onStartup( Container container) | |
| 75 | { | |
| 76 | log. info("onSt artup call ed"); | |
| 77 | if ( instance_ != null) | |
| 78 | { | |
| 79 | throw new Runtim eException ("Unexpect ed!"); | |
| 80 | } | |
| 81 | inst ance_ = th is; | |
| 82 | ||
| 83 | //co ntext is n ull when r un from ec lipse with the local jetty run ner. | |
| 84 | if ( context_ = = null) | |
| 85 | { | |
| 86 | debugM ode = true ; | |
| 87 | contex tPath = "v uid-rest"; | |
| 88 | } | |
| 89 | else | |
| 90 | { | |
| 91 | contex tPath = co ntext_.get ContextPat h().replac e("/", "") ; | |
| 92 | debugM ode = (con textPath.c ontains("S NAPSHOT") ? true : f alse); | |
| 93 | } | |
| 94 | ||
| 95 | log. info("Cont ext path o f this dep loyment is '" + cont extPath + "' and deb ug mode is " + debug Mode); | |
| 96 | ||
| 97 | serv icesInit() ; | |
| 98 | } | |
| 99 | ||
| 100 | pu blic boole an isServi ceReady() | |
| 101 | { | |
| 102 | retu rn initial StartupCom plete && L ookupServi ce.getServ ice(VuidSe rvice.clas s).isReady (); | |
| 103 | } | |
| 104 | ||
| 105 | pu blic void setStatus( String sta tusMessage ) | |
| 106 | { | |
| 107 | log. debug("Res etting App licationCo nfig statu s to \"" + statusMes sage + "\" "); | |
| 108 | stat us_.set(st atusMessag e); | |
| 109 | } | |
| 110 | ||
| 111 | pu blic Strin g getStatu sMessage() | |
| 112 | { | |
| 113 | retu rn status_ .get(); | |
| 114 | } | |
| 115 | ||
| 116 | pr ivate void servicesI nit() | |
| 117 | { | |
| 118 | log. info("Serv ices Init called"); | |
| 119 | if ( startup.ge tAndDecrem ent() == 1 ) | |
| 120 | { | |
| 121 | log.in fo("Execut ing initia l services Init in b ackground thread"); | |
| 122 | Runnab le r = new Runnable( ) | |
| 123 | { | |
| 124 | @Overrid e | |
| 125 | public v oid run() | |
| 126 | { | |
| 127 | try | |
| 128 | { | |
| 129 | lo g.info("VU ID Service Init thre ad begins" ); | |
| 130 | if (shutdown ) | |
| 131 | { | |
| 132 | retu rn; | |
| 133 | } | |
| 134 | st atus_.set( "Starting DB init pr ocess"); | |
| 135 | Lo okupServic e.setRunLe vel(Lookup Service.ME TADATA_STO RE_STARTED _RUNLEVEL) ; | |
| 136 | ||
| 137 | if (shutdown ) | |
| 138 | { | |
| 139 | retu rn; | |
| 140 | } | |
| 141 | ||
| 142 | // go up one more level , to start up the lo gger, now that we ha ve config info. | |
| 143 | Lo okupServic e.setRunLe vel(0); / /TODO fix to constan t | |
| 144 | ||
| 145 | sy stemInfo_ = new Rest SystemInfo (); | |
| 146 | ||
| 147 | st atus_.set( "Ready"); | |
| 148 | ||
| 149 | if (isDebugD eploy()) { | |
| 150 | Syst em.out.pri ntln("Done setting u p VUID Ser vice"); | |
| 151 | ||
| 152 | Syst em.out.pri ntln(Strin g.format(" Applicatio n started. \nTry out (POST) %s% s\nStop th e applicat ion by pre ssing ente r.", | |
| 153 | "http:// localhost: 8181/", "v uid-rest/w rite/1/vui ds/allocat e?blockSiz e=10&reaso n=a%20reas on&ssoToke n=TestUser :vuid_requ estor")); | |
| 154 | } | |
| 155 | } | |
| 156 | catch (Exc eption e) | |
| 157 | { | |
| 158 | lo g.error("F ailure sta rting VUID Service", e); | |
| 159 | st atus_.set( "FAILED!") ; | |
| 160 | } | |
| 161 | finally | |
| 162 | { | |
| 163 | in itialStart upComplete = true; | |
| 164 | } | |
| 165 | } | |
| 166 | }; | |
| 167 | ||
| 168 | Lookup Service.ge t().getSer vice(WorkE xecutors.c lass).getE xecutor(). execute(r) ; | |
| 169 | } | |
| 170 | } | |
| 171 | ||
| 172 | /* * | |
| 173 | * A place f or a filte r to call in and sta sh the ser vice liste n port whe n it becom es known | |
| 174 | * @param po rt | |
| 175 | * / | |
| 176 | pu blic void setPort(in t port) | |
| 177 | { | |
| 178 | this .port = po rt; | |
| 179 | } | |
| 180 | ||
| 181 | /* * | |
| 182 | * A place f or a filte r to call in and sta sh the ser vice host name when it becomes known | |
| 183 | * @param ho stName | |
| 184 | * / | |
| 185 | pu blic void setHostNam e(String h ostName) | |
| 186 | { | |
| 187 | this .hostname = hostName ; | |
| 188 | } | |
| 189 | ||
| 190 | /* * | |
| 191 | * Returns w hatever po rt was set by setPor t(int) | |
| 192 | * @return | |
| 193 | * / | |
| 194 | pu blic int g etPort() | |
| 195 | { | |
| 196 | retu rn port; | |
| 197 | } | |
| 198 | ||
| 199 | /* * | |
| 200 | * Returns w hatever po rt was set by setHos tName(Stri ng) | |
| 201 | * @return | |
| 202 | * / | |
| 203 | pu blic Strin g getHostn ame() | |
| 204 | { | |
| 205 | retu rn hostnam e; | |
| 206 | } | |
| 207 | ||
| 208 | /* * | |
| 209 | * @return t rue if thi s is a deb ug deploym ent (in ec lipse, or context co ntains SNA PSHOT) | |
| 210 | * / | |
| 211 | pu blic boole an isDebug Deploy() | |
| 212 | { | |
| 213 | retu rn debugMo de; | |
| 214 | } | |
| 215 | ||
| 216 | /* * | |
| 217 | * @return S tring cont ext path, which is a hard-code d value if in eclips e Jetty | |
| 218 | * / | |
| 219 | pu blic Strin g getConte xtPath() { | |
| 220 | retu rn context Path; | |
| 221 | } | |
| 222 | ||
| 223 | pu blic boole an isShutd ownRequest ed() | |
| 224 | { | |
| 225 | retu rn shutdow n; | |
| 226 | } | |
| 227 | ||
| 228 | pu blic Servl etContext getServlet Context() | |
| 229 | { | |
| 230 | retu rn context _; | |
| 231 | } | |
| 232 | ||
| 233 | pu blic RestS ystemInfo getSystemI nfo() | |
| 234 | { | |
| 235 | retu rn systemI nfo_; | |
| 236 | } | |
| 237 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.