Produced by Araxis Merge on 6/11/2019 10:54:16 AM 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 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\util | ApplicationContextModelProperties.java | Wed May 29 15:26:00 2019 UTC |
| 2 | HTRE_P3_v14.5_iter_4_build_14.zip\java\gov\va\med\fw\util | ApplicationContextModelProperties.java | Mon Jun 10 19:30:05 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 752 |
| 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 2006 V HA. All ri ghts reser ved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | ||
| 5 | package go v.va.med.f w.util; | |
| 6 | ||
| 7 | import jav a.lang.ref lect.Acces sibleObjec t; | |
| 8 | import jav a.lang.ref lect.Field ; | |
| 9 | import jav a.lang.ref lect.Modif ier; | |
| 10 | import jav a.util.Arr ayList; | |
| 11 | import jav a.util.Has hMap; | |
| 12 | import jav a.util.Ite rator; | |
| 13 | import jav a.util.Lis t; | |
| 14 | import jav a.util.Map ; | |
| 15 | ||
| 16 | import org .apache.co mmons.lang .ClassUtil s; | |
| 17 | import org .springfra mework.bea ns.factory .BeanNotOf RequiredTy peExceptio n; | |
| 18 | import org .springfra mework.bea ns.factory .NoSuchBea nDefinitio nException ; | |
| 19 | import org .springfra mework.con text.Appli cationCont ext; | |
| 20 | ||
| 21 | import gov .va.med.fw .model.Con figurableM odelProper ties; | |
| 22 | import gov .va.med.fw .model.loo kup.ModelP ropertiesA pplication Type; | |
| 23 | import gov .va.med.fw .service.A bstractCom ponent; | |
| 24 | ||
| 25 | /** | |
| 26 | * Concret e service for a conf igurable s et of mode l properti es. Suppor ts well | |
| 27 | * known a pplication s as defin ed in Mode lPropertie sApplicati onType, as well as | |
| 28 | * project specific applicatio ns via the overloade d getModel Properties method. | |
| 29 | * | |
| 30 | * <p> | |
| 31 | * The def ault behav ior is tha t if a Cla ss is not found in c onfigurati on, then | |
| 32 | * all its propertie s will be used (glob al still h as veto ri ghts). If a Class is | |
| 33 | * in an i nheritance hierarchy , then eac h of its s uperclasse s are also checked | |
| 34 | * aginst configurat ion, each giving vet o power to the globa l. | |
| 35 | * | |
| 36 | * @see go v.va.med.f w.model.lo okup.Model Properties Applicatio nType | |
| 37 | * @see #g etModelPro perties(Cl ass, Strin g) Created Mar 13, 2 006 2:34:4 8 PM | |
| 38 | * @author DNS DN S
|
|
| 39 | */ | |
| 40 | public cla ss Applica tionContex tModelProp erties ext ends Abstr actCompone nt impleme nts | |
| 41 | Mode lPropertie sManager { | |
| 42 | pr ivate fina l static S tring GLOB AL_PER_DOM AIN_OBJECT = "global "; | |
| 43 | ||
| 44 | pr ivate stat ic List ap plicationC ontextList = new Arr ayList(); | |
| 45 | ||
| 46 | pr ivate Map classModel Properties = new Has hMap(); | |
| 47 | ||
| 48 | /* * Global i s only ove rruled by instance c onfigurati on. */ | |
| 49 | pr ivate Map globalMode lPropertie s = new Ha shMap(); | |
| 50 | ||
| 51 | pr ivate Stri ng rootCla ssName; | |
| 52 | ||
| 53 | pr ivate bool ean useTra nsients = false; | |
| 54 | ||
| 55 | pu blic void flushCache () { | |
| 56 | clas sModelProp erties.cle ar(); | |
| 57 | } | |
| 58 | ||
| 59 | /* | |
| 60 | * (non-Java doc) | |
| 61 | * | |
| 62 | * @see | |
| 63 | * gov.va.me d.fw.servi ce.ModelPr opertiesMa nager#getI dentityPro perties(ja va | |
| 64 | * .lang.Cla ss) | |
| 65 | * / | |
| 66 | pu blic List getIdentit yPropertie s(Class cl azz) { | |
| 67 | retu rn getMode lPropertie s(clazz, M odelProper tiesApplic ationType. IDENTITY.g etName()); | |
| 68 | } | |
| 69 | ||
| 70 | /* | |
| 71 | * (non-Java doc) | |
| 72 | * | |
| 73 | * @see | |
| 74 | * gov.va.me d.fw.servi ce.ModelPr opertiesMa nager#getC opyPropert ies(java.l ang | |
| 75 | * .Class) | |
| 76 | * / | |
| 77 | pu blic List getCopyPro perties(Cl ass clazz) { | |
| 78 | retu rn getMode lPropertie s(clazz, M odelProper tiesApplic ationType. COPY.getNa me()); | |
| 79 | } | |
| 80 | ||
| 81 | pu blic List getMatchDo mainValues Properties (Class cla zz) { | |
| 82 | retu rn getMode lPropertie s(clazz, M odelProper tiesApplic ationType. MATCH_DOMA IN_VALUES | |
| 83 | .getName ()); | |
| 84 | } | |
| 85 | ||
| 86 | pu blic List getMatchDo mainConcep tPropertie s(Class cl azz) { | |
| 87 | retu rn getMode lPropertie s(clazz, M odelProper tiesApplic ationType. MATCH_DOMA IN_CONCEPT | |
| 88 | .getName ()); | |
| 89 | } | |
| 90 | ||
| 91 | /* * | |
| 92 | * Returns t he set (co uld be any number) o f properti es for the intereste d | |
| 93 | * applicati on. | |
| 94 | * | |
| 95 | * @param cl azz | |
| 96 | * @param ap plication | |
| 97 | * @return L ist | |
| 98 | * / | |
| 99 | pu blic List getModelPr operties(C lass clazz , String a pplication ) { | |
| 100 | Stri ng key = c lazz.getNa me() + "." + applica tion; | |
| 101 | List propertyN ames = (Li st) classM odelProper ties.get(k ey); | |
| 102 | if ( propertyNa mes == nul l) { | |
| 103 | /* | |
| 104 | * Sin ce this in ternally c alls Sprin g and it p erforms lo cking via | |
| 105 | * obj ect synchr onization (ie, singl etonCache) then we c an not | |
| 106 | * syn chronize a s it cause d in testi ng competi ng threads to | |
| 107 | * dea dlock. Wor st case he re is doub le set-up for same | |
| 108 | * cla ssModelPro perties. T his is liv able, and obviously more | |
| 109 | * pre ferable to deadlocki ng. | |
| 110 | */ | |
| 111 | // syn chronized (this) { | |
| 112 | proper tyNames = initialize ModelPrope rties(claz z, applica tion); | |
| 113 | classM odelProper ties.put(k ey, proper tyNames); | |
| 114 | // } | |
| 115 | } | |
| 116 | retu rn propert yNames; | |
| 117 | } | |
| 118 | ||
| 119 | /* * | |
| 120 | * Gets the properties for the s pecified c lass and a pplication type. If the | |
| 121 | * applicati on isn't f ound, then the ident ity proper ties are t ried. If a ny | |
| 122 | * propertie s couldn't be found, the globa l ones are used. | |
| 123 | * | |
| 124 | * @param cl azz | |
| 125 | * The clas s of prope rties to g et | |
| 126 | * @param ap plication | |
| 127 | * The appl ication ty pe | |
| 128 | * @return T he propert ies | |
| 129 | * / | |
| 130 | pu blic Confi gurableMod elProperti es getConf igurableMo delPropert ies(Class clazz, | |
| 131 | String applicati on) { | |
| 132 | // G et the pro perties fo r this app lication t ype. | |
| 133 | Conf igurableMo delPropert ies modelP roperties = getModel Properties Bean(clazz , applicat ion); | |
| 134 | // f or now, if there is no entry f or this no n-identity applicati on type, | |
| 135 | // d efault to using the .identity one | |
| 136 | if ( modelPrope rties == n ull | |
| 137 | && !Mode lPropertie sApplicati onType.IDE NTITY.getN ame().equa ls(applica tion)) | |
| 138 | modelP roperties = getModel Properties Bean(clazz , ModelPro pertiesApp licationTy pe.IDENTIT Y | |
| 139 | .getName() ); | |
| 140 | ||
| 141 | // n ow add on the global -per-domai n object p roperties | |
| 142 | Conf igurableMo delPropert ies global PerDomainO bject = ge tModelProp ertiesBean (clazz, | |
| 143 | GLOBAL_P ER_DOMAIN_ OBJECT); | |
| 144 | if ( globalPerD omainObjec t != null) { | |
| 145 | if (mo delPropert ies != nul l) { | |
| 146 | modelPro perties.ad dInclusion s(globalPe rDomainObj ect.getInc lusions()) ; | |
| 147 | modelPro perties.ad dExclusion s(globalPe rDomainObj ect.getExc lusions()) ; | |
| 148 | } else { | |
| 149 | modelPro perties = globalPerD omainObjec t; | |
| 150 | } | |
| 151 | } | |
| 152 | ||
| 153 | // n ow make su re modelPr operties h as a globa l-per-appl ication ob ject | |
| 154 | // p roperties | |
| 155 | Conf igurableMo delPropert ies global PerApplica tion = get GlobalMode lPropertie sObject(ap plication) ; | |
| 156 | if ( globalPerA pplication != null) { | |
| 157 | if (mo delPropert ies != nul l) { | |
| 158 | modelPro perties.se tGlobalPro perties(gl obalPerApp lication); | |
| 159 | } else { | |
| 160 | if (glob alPerAppli cation != null) | |
| 161 | modelPrope rties = ne w Configur ableModelP roperties( globalPerA pplication ); | |
| 162 | } | |
| 163 | } | |
| 164 | ||
| 165 | if ( modelPrope rties == n ull) { | |
| 166 | // no configurat ion for do main-per-a pplication , global-p er-domain, | |
| 167 | // and global-pe r-applicat ion....all ow all pro perties | |
| 168 | modelP roperties = new Conf igurableMo delPropert ies(); | |
| 169 | modelP roperties. allowAllPr operties() ; | |
| 170 | } | |
| 171 | ||
| 172 | // R eturn the final prop erties | |
| 173 | retu rn modelPr operties; | |
| 174 | } | |
| 175 | ||
| 176 | /* * | |
| 177 | * Gets the properties bean for the specif ied class and applic ation type . | |
| 178 | * | |
| 179 | * @param cl azz | |
| 180 | * The clas s of prope rties to g et | |
| 181 | * @param ap plication | |
| 182 | * The appl ication ty pe | |
| 183 | * @return T he propert ies bean | |
| 184 | * / | |
| 185 | pr ivate Conf igurableMo delPropert ies getMod elProperti esBean(Cla ss clazz, String app lication) { | |
| 186 | // G et the pro perties fo r this app lication t ype. | |
| 187 | Conf igurableMo delPropert ies modelP roperties = null; | |
| 188 | try { | |
| 189 | modelP roperties = (Configu rableModel Properties ) getBean( clazz.getN ame() + ". " | |
| 190 | + applicat ion); | |
| 191 | } ca tch (NoSuc hBeanDefin itionExcep tion e) { | |
| 192 | // Lea ve modelPr operties n ull | |
| 193 | } ca tch (BeanN otOfRequir edTypeExce ption e) { | |
| 194 | // Lea ve modelPr operties n ull | |
| 195 | } | |
| 196 | retu rn modelPr operties; | |
| 197 | } | |
| 198 | ||
| 199 | /* * | |
| 200 | * Gets the global pro perties fo r the spec ified appl ication ty pe. | |
| 201 | * | |
| 202 | * @param ap plication | |
| 203 | * The appl ication ty pe | |
| 204 | * @return T he global properties | |
| 205 | * / | |
| 206 | pr ivate Conf igurableMo delPropert ies getGlo balModelPr opertiesOb ject(Strin g applicat ion) { | |
| 207 | // s hould not synchroniz e this met hod as thi s could ca use deadlo cks in | |
| 208 | // r ecursion s cenarios w ith compet ing thread s | |
| 209 | Conf igurableMo delPropert ies modelP roperties = (Configu rableModel Properties ) globalMo delPropert ies | |
| 210 | .get(app lication); | |
| 211 | if ( modelPrope rties == n ull) { | |
| 212 | modelP roperties = new Conf igurableMo delPropert ies(); | |
| 213 | modelP roperties. rejectAllP roperties( ); // reme mber this does not | |
| 214 | // mea n everythi ng is | |
| 215 | // rej ected, jus t the glob al | |
| 216 | // wil l say so | |
| 217 | global ModelPrope rties.put( applicatio n, modelPr operties); | |
| 218 | } | |
| 219 | retu rn modelPr operties; | |
| 220 | } | |
| 221 | ||
| 222 | /* * | |
| 223 | * Here is t he general algorithm : 1) For t argetClass , get | |
| 224 | * Configura bleModelPr operties f rom config uration (w ith global s attached ) 2) | |
| 225 | * Build can didate Fie lds from i nheritance hierarchy 3) For ea ch Field, loop | |
| 226 | * through i nheritance hierarchy 4) For ea ch Class i n inherita nce hierar chy | |
| 227 | * (starting with targ etClass), get its Co nfigurable ModelPrope rties from | |
| 228 | * configura tion (with globals a ttached) 5 ) Ask its | |
| 229 | * Configura bleModelPr operties ( with globa ls attache d) if it i s ok to us e | |
| 230 | * it. If no t, stop. I f ok, dete rmine why ok. 6) Det ermine ok logic | |
| 231 | * (implicit or explic it): | |
| 232 | * | |
| 233 | * If was ex plicitly s pecified t o be ok (i e, in incl usions), u se it and do | |
| 234 | * not keep going up t he inherit ance hiera rchy. If w as not exp licitly | |
| 235 | * specified to be ok and none w ere (ie, i nclusions was empty) , continue up | |
| 236 | * the inher itance hie rarchy (st ep 4). If was not ex plicitly s pecified t o be | |
| 237 | * ok and ot hers were (ie, inclu sions was not empty but did no t include it), | |
| 238 | * then do n ot use it. | |
| 239 | * | |
| 240 | * The ratio nale was o nce (at le ast one) p roperty wa s specifie d to be | |
| 241 | * "included ", then th ey were th e only one s allowed. | |
| 242 | * | |
| 243 | * @param cl azz | |
| 244 | * @return t he list of propertie s | |
| 245 | * / | |
| 246 | pr ivate List initializ eModelProp erties(Cla ss clazz, String app lication) { | |
| 247 | List props = n ew ArrayLi st(); | |
| 248 | ||
| 249 | // i nitialize from Class definitio n and conf iguration | |
| 250 | Conf igurableMo delPropert ies instan ceModelPro perties = getConfigu rableModel Properties (clazz, | |
| 251 | applicat ion); | |
| 252 | ||
| 253 | List classes = new Array List(); | |
| 254 | clas ses.add(cl azz); | |
| 255 | if ( instanceMo delPropert ies.isInhe ritAncesto rsProperti es()) | |
| 256 | classe s.addAll(C lassUtils. getAllSupe rclasses(c lazz)); | |
| 257 | Iter ator itrCl asses = cl asses.iter ator(); | |
| 258 | Clas s targetCl azz = null ; | |
| 259 | bool ean isDesc endantOfRo otClassNam e = false; | |
| 260 | Stri ng realize dRootClass Name = roo tClassName ; | |
| 261 | ||
| 262 | // f irst build list of a ll candida te fields | |
| 263 | List candidate Fields = n ew ArrayLi st(); | |
| 264 | Fiel d[] fields = null; | |
| 265 | whil e (itrClas ses.hasNex t()) { | |
| 266 | target Clazz = (C lass) itrC lasses.nex t(); | |
| 267 | if (!i sDescendan tOfRootCla ssName) | |
| 268 | isDescen dantOfRoot ClassName = targetCl azz.getNam e().equals (rootClass Name); | |
| 269 | fields = targetC lazz.getDe claredFiel ds(); // t his gets a ll | |
| 270 | // (in cluding pr ivate) | |
| 271 | Access ibleObject .setAccess ible(field s, true); // would f ail with | |
| 272 | // Sec urityManag er | |
| 273 | for (i nt i = 0; fields != null && i < fields.l ength; i++ ) { | |
| 274 | if ((fie lds[i].get Name().ind exOf('$') == -1) | |
| 275 | && (useTrans ients || ! Modifier.i sTransient (fields[i] .getModifi ers())) | |
| 276 | && (!Modifie r.isStatic (fields[i] .getModifi ers()))) { | |
| 277 | candidateF ields.add( fields[i]) ; | |
| 278 | } | |
| 279 | } | |
| 280 | } | |
| 281 | if ( !isDescend antOfRootC lassName) | |
| 282 | realiz edRootClas sName = Ob ject.class .getName() ; | |
| 283 | ||
| 284 | // l oop throug h each Fie ld | |
| 285 | Iter ator itrFi elds = can didateFiel ds.iterato r(); | |
| 286 | Fiel d field = null; | |
| 287 | Conf igurableMo delPropert ies target ClassModel Properties = null; | |
| 288 | whil e (itrFiel ds.hasNext ()) { | |
| 289 | field = (Field) itrFields. next(); | |
| 290 | // log ("dealing with Field : " + fiel d.getName( )); | |
| 291 | // loo p through class hier archy | |
| 292 | itrCla sses = cla sses.itera tor(); | |
| 293 | while (itrClasse s.hasNext( )) { | |
| 294 | targetCl azz = (Cla ss) itrCla sses.next( ); | |
| 295 | // log(" dealing wi th Class: " + target Clazz.getN ame()); | |
| 296 | if (targ etClazz == clazz) | |
| 297 | targetClas sModelProp erties = i nstanceMod elProperti es; | |
| 298 | else | |
| 299 | targetClas sModelProp erties = g etConfigur ableModelP roperties( targetClaz z, | |
| 300 | appl ication); | |
| 301 | ||
| 302 | if (!tar getClassMo delPropert ies.should Include(fi eld.getNam e())) { | |
| 303 | // log("Cl ass " + ta rgetClazz. getName() + | |
| 304 | // " is NO T ok with this field : " + fiel d.getName( )); | |
| 305 | break; | |
| 306 | } | |
| 307 | ||
| 308 | // deter mine if we should co ntinue up inheritanc e chain | |
| 309 | if (targ etClassMod elProperti es.isPrope rtySpecifi ed(field.g etName()) | |
| 310 | || targetCla zz.getName ().equals( realizedRo otClassNam e)) { | |
| 311 | // ok, we' re done pr ocessing, add Field | |
| 312 | props.add( field); | |
| 313 | break; | |
| 314 | } | |
| 315 | } | |
| 316 | } | |
| 317 | ||
| 318 | retu rn props; | |
| 319 | } | |
| 320 | ||
| 321 | /* * | |
| 322 | * @return R eturns the rootClass Name. | |
| 323 | * / | |
| 324 | pu blic Strin g getRootC lassName() { | |
| 325 | retu rn rootCla ssName; | |
| 326 | } | |
| 327 | ||
| 328 | /* * | |
| 329 | * @param ro otClassNam e | |
| 330 | * The root ClassName to set. | |
| 331 | * / | |
| 332 | pu blic void setRootCla ssName(Str ing rootCl assName) { | |
| 333 | this .rootClass Name = roo tClassName ; | |
| 334 | } | |
| 335 | ||
| 336 | /* * | |
| 337 | * @return R eturns the useTransi ents. | |
| 338 | * / | |
| 339 | pu blic boole an isUseTr ansients() { | |
| 340 | retu rn useTran sients; | |
| 341 | } | |
| 342 | ||
| 343 | /* * | |
| 344 | * @param us eTransient s | |
| 345 | * The useT ransients to set. | |
| 346 | * / | |
| 347 | pu blic void setUseTran sients(boo lean useTr ansients) { | |
| 348 | this .useTransi ents = use Transients ; | |
| 349 | } | |
| 350 | ||
| 351 | pu blic Map g etGlobalMo delPropert ies() { | |
| 352 | retu rn globalM odelProper ties; | |
| 353 | } | |
| 354 | ||
| 355 | pu blic void setGlobalM odelProper ties(Map g lobalModel Properties ) { | |
| 356 | this .globalMod elProperti es = globa lModelProp erties; | |
| 357 | } | |
| 358 | ||
| 359 | @O verride | |
| 360 | pu blic void afterPrope rtiesSet() throws Ex ception { | |
| 361 | // T ODO Auto-g enerated m ethod stub | |
| 362 | supe r.afterPro pertiesSet (); | |
| 363 | appl icationCon textList.a dd(0, getA pplication Context()) ; | |
| 364 | } | |
| 365 | ||
| 366 | pr ivate Conf igurableMo delPropert ies getBea n(String b eanName) { | |
| 367 | Conf igurableMo delPropert ies bean = null; | |
| 368 | for (int i = 0 ; i < appl icationCon textList.s ize(); i++ ) { | |
| 369 | bean = (Configur ableModelP roperties) ((Applica tionContex t) applica tionContex tList | |
| 370 | .get(i)).g etBean(bea nName); | |
| 371 | if (be an != null ) { | |
| 372 | return b ean; | |
| 373 | } | |
| 374 | } | |
| 375 | retu rn null; | |
| 376 | } | |
| 377 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.