Produced by Araxis Merge on 6/18/2018 3:37:04 PM Eastern 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 | CTT_DM2_v7.zip\VUID-rest\src\main\java\gov\vha\vuid\rest | ApplicationConfig.java | Tue Jun 12 16:41:53 2018 UTC |
| 2 | CTT_DM2_v7.zip\VUID-rest\src\main\java\gov\vha\vuid\rest | ApplicationConfig.java | Fri Jun 15 21:23:57 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 532 |
| 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 = PORT ; | |
| 34 | pr ivate Stri ng hostnam e; | |
| 35 | pr ivate Stri ng protoco l; | |
| 36 | pr ivate Rest SystemInfo systemInf o_; | |
| 37 | ||
| 38 | // 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, | |
| 39 | // this remai ns null. | |
| 40 | @C ontext | |
| 41 | Se rvletConte xt context _; | |
| 42 | ||
| 43 | pr ivate Stri ng context Path; | |
| 44 | ||
| 45 | pu blic Appli cationConf ig() | |
| 46 | { | |
| 47 | //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. | |
| 48 | //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 | |
| 49 | //sc anning. I t also see ms to forg et to scan this clas s... so re gister its elf.. | |
| 50 | supe r(new Reso urceConfig ().package s("gov.vha .vuid.rest ").registe r(JacksonF eature.cla ss).regist er(Applica tionConfig .class)); | |
| 51 | } | |
| 52 | ||
| 53 | pu blic stati c Applicat ionConfig getInstanc e() | |
| 54 | { | |
| 55 | retu rn instanc e_; | |
| 56 | } | |
| 57 | ||
| 58 | @O verride | |
| 59 | pu blic void onReload(C ontainer a rg0) | |
| 60 | { | |
| 61 | // T ODO determ ine if Vui dService s hould be r einitializ ed onReloa d() | |
| 62 | } | |
| 63 | ||
| 64 | @O verride | |
| 65 | pu blic void onShutdown (Container arg0) | |
| 66 | { | |
| 67 | shut down = tru e; | |
| 68 | log. info("Stop ping VUID Service"); | |
| 69 | Look upService. shutdownSy stem(); | |
| 70 | init ialStartup Complete = false; | |
| 71 | log. info("VUID Service s topped"); | |
| 72 | } | |
| 73 | ||
| 74 | @O verride | |
| 75 | pu blic void onStartup( Container container) | |
| 76 | { | |
| 77 | log. info("onSt artup call ed"); | |
| 78 | if ( instance_ != null) | |
| 79 | { | |
| 80 | throw new Runtim eException ("Unexpect ed!"); | |
| 81 | } | |
| 82 | inst ance_ = th is; | |
| 83 | ||
| 84 | //co ntext is n ull when r un from ec lipse with the local jetty run ner. | |
| 85 | if ( context_ = = null) | |
| 86 | { | |
| 87 | debugM ode = true ; | |
| 88 | contex tPath = "v uid-rest"; | |
| 89 | } | |
| 90 | else | |
| 91 | { | |
| 92 | contex tPath = co ntext_.get ContextPat h().replac e("/", "") ; | |
| 93 | debugM ode = (con textPath.c ontains("S NAPSHOT") ? true : f alse); | |
| 94 | } | |
| 95 | ||
| 96 | log. info("Cont ext path o f this dep loyment is '" + cont extPath + "' and deb ug mode is " + debug Mode); | |
| 97 | ||
| 98 | serv icesInit() ; | |
| 99 | } | |
| 100 | ||
| 101 | pu blic boole an isServi ceReady() | |
| 102 | { | |
| 103 | retu rn initial StartupCom plete && L ookupServi ce.getServ ice(VuidSe rvice.clas s).isReady (); | |
| 104 | } | |
| 105 | ||
| 106 | pu blic void setStatus( String sta tusMessage ) | |
| 107 | { | |
| 108 | log. debug("Res etting App licationCo nfig statu s to \"" + statusMes sage + "\" "); | |
| 109 | stat us_.set(st atusMessag e); | |
| 110 | } | |
| 111 | ||
| 112 | pu blic Strin g getStatu sMessage() | |
| 113 | { | |
| 114 | retu rn status_ .get(); | |
| 115 | } | |
| 116 | ||
| 117 | pr ivate void servicesI nit() | |
| 118 | { | |
| 119 | log. info("Serv ices Init called"); | |
| 120 | if ( startup.ge tAndDecrem ent() == 1 ) | |
| 121 | { | |
| 122 | log.in fo("Execut ing initia l services Init in b ackground thread"); | |
| 123 | Runnab le r = new Runnable( ) | |
| 124 | { | |
| 125 | @Overrid e | |
| 126 | public v oid run() | |
| 127 | { | |
| 128 | try | |
| 129 | { | |
| 130 | lo g.info("VU ID Service Init thre ad begins" ); | |
| 131 | if (shutdown ) | |
| 132 | { | |
| 133 | retu rn; | |
| 134 | } | |
| 135 | st atus_.set( "Starting DB init pr ocess"); | |
| 136 | Lo okupServic e.setRunLe vel(Lookup Service.SL _NEG_1_MET ADATA_STOR E_STARTED_ RUNLEVEL); | |
| 137 | ||
| 138 | if (shutdown ) | |
| 139 | { | |
| 140 | retu rn; | |
| 141 | } | |
| 142 | ||
| 143 | // go up one more level , to start up the lo gger, now that we ha ve config info. | |
| 144 | Lo okupServic e.setRunLe vel(Lookup Service.SL _L0); | |
| 145 | ||
| 146 | sy stemInfo_ = new Rest SystemInfo (); | |
| 147 | ||
| 148 | st atus_.set( "Ready"); | |
| 149 | ||
| 150 | if (isDebugD eploy()) { | |
| 151 | Syst em.out.pri ntln("Done setting u p VUID Ser vice"); | |
| 152 | ||
| 153 | 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.", | |
| 154 | "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")); | |
| 155 | } | |
| 156 | } | |
| 157 | catch (Exc eption e) | |
| 158 | { | |
| 159 | lo g.error("F ailure sta rting VUID Service", e); | |
| 160 | st atus_.set( "FAILED!") ; | |
| 161 | } | |
| 162 | finally | |
| 163 | { | |
| 164 | in itialStart upComplete = true; | |
| 165 | } | |
| 166 | } | |
| 167 | }; | |
| 168 | ||
| 169 | Lookup Service.ge t().getSer vice(WorkE xecutors.c lass).getE xecutor(). execute(r) ; | |
| 170 | } | |
| 171 | } | |
| 172 | ||
| 173 | /* * | |
| 174 | * 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 | |
| 175 | * @param po rt | |
| 176 | * / | |
| 177 | pu blic void setPort(in t port) | |
| 178 | { | |
| 179 | this .port = po rt; | |
| 180 | } | |
| 181 | ||
| 182 | /* * | |
| 183 | * A place f or a filte r to call in and sta sh the pro tocol when it become s known | |
| 184 | * @param pr otocol | |
| 185 | * / | |
| 186 | pu blic void setProtoco l(String p rotocol) | |
| 187 | { | |
| 188 | this .protocol = protocol ; | |
| 189 | } | |
| 190 | ||
| 191 | /* * | |
| 192 | * A place f or a filte r to call in and sta sh the ser vice host name when it becomes known | |
| 193 | * @param ho stName | |
| 194 | * / | |
| 195 | pu blic void setHostNam e(String h ostName) | |
| 196 | { | |
| 197 | this .hostname = hostName ; | |
| 198 | } | |
| 199 | ||
| 200 | /* * | |
| 201 | * Returns w hatever po rt was set by setPor t(int) | |
| 202 | * @return | |
| 203 | * / | |
| 204 | pu blic int g etPort() | |
| 205 | { | |
| 206 | retu rn port; | |
| 207 | } | |
| 208 | ||
| 209 | /* * | |
| 210 | * Returns w hatever pr otocol was set by se tProtocol( String) | |
| 211 | * @return | |
| 212 | * / | |
| 213 | pu blic Strin g getProto col() | |
| 214 | { | |
| 215 | retu rn protoco l; | |
| 216 | } | |
| 217 | ||
| 218 | /* * | |
| 219 | * Returns w hatever po rt was set by setHos tName(Stri ng) | |
| 220 | * @return | |
| 221 | * / | |
| 222 | pu blic Strin g getHostn ame() | |
| 223 | { | |
| 224 | retu rn hostnam e; | |
| 225 | } | |
| 226 | ||
| 227 | /* * | |
| 228 | * @return t rue if thi s is a deb ug deploym ent (in ec lipse, or context co ntains SNA PSHOT) | |
| 229 | * / | |
| 230 | pu blic boole an isDebug Deploy() | |
| 231 | { | |
| 232 | retu rn debugMo de; | |
| 233 | } | |
| 234 | ||
| 235 | /* * | |
| 236 | * @return S tring cont ext path, which is a hard-code d value if in eclips e Jetty | |
| 237 | * / | |
| 238 | pu blic Strin g getConte xtPath() { | |
| 239 | retu rn context Path; | |
| 240 | } | |
| 241 | ||
| 242 | pu blic boole an isShutd ownRequest ed() | |
| 243 | { | |
| 244 | retu rn shutdow n; | |
| 245 | } | |
| 246 | ||
| 247 | pu blic Servl etContext getServlet Context() | |
| 248 | { | |
| 249 | retu rn context _; | |
| 250 | } | |
| 251 | ||
| 252 | pu blic RestS ystemInfo getSystemI nfo() | |
| 253 | { | |
| 254 | retu rn systemI nfo_; | |
| 255 | } | |
| 256 | ||
| 257 | /* (non-Java doc) | |
| 258 | * @see java .lang.Obje ct#toStrin g() | |
| 259 | * / | |
| 260 | @O verride | |
| 261 | pu blic Strin g toString () { | |
| 262 | retu rn "Applic ationConfi g [status_ =" + statu s_ + ", de bugMode=" + debugMod e + ", shu tdown=" | |
| 263 | + shutdo wn + ", in itialStart upComplete =" + initi alStartupC omplete + ", port=" + port + " , hostname =" | |
| 264 | + hostna me + ", pr otocol=" + protocol + ", syste mInfo_=" + systemInf o_ | |
| 265 | + ", con textPath=" + context Path + "]" ; | |
| 266 | } | |
| 267 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.