Produced by Araxis Merge on 12/13/2018 10:35:26 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\cache | EntityCacheManager.java | Fri Dec 7 17:36:18 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\cache | EntityCacheManager.java | Wed Dec 12 19:46:45 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 250 |
| 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 2004 V HA. All ri ghts reser ved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | // Package | |
| 5 | package go v.va.med.f w.cache; | |
| 6 | ||
| 7 | import jav a.security .SecureRan dom; | |
| 8 | // Java cl asses | |
| 9 | import jav a.util.Has hMap; | |
| 10 | import jav a.util.Map ; | |
| 11 | ||
| 12 | import org .apache.co mmons.lang .Validate; | |
| 13 | import org .springfra mework.ste reotype.Co mponent; | |
| 14 | import org .springfra mework.tra nsaction.s upport.Tra nsactionSy nchronizat ionManager ; | |
| 15 | ||
| 16 | import gov .va.med.fw .model.Abs tractEntit y; | |
| 17 | import gov .va.med.fw .model.Ent ityKey; | |
| 18 | ||
| 19 | // ESR cla sses | |
| 20 | ||
| 21 | /** | |
| 22 | * Candida tes to be cached are usually e ntities wh ose proper ties are p opulated | |
| 23 | * with da ta coming from multi ple data s ources. | |
| 24 | * | |
| 25 | * <p> | |
| 26 | * If an e ntity is r etrived fr om a datab ase using Hibernate framework and all of | |
| 27 | * the ent ity's prop erties are mapped to table col umns in a hibernate mapping | |
| 28 | * file, t here is no need to m anage the entity in this class since Hib ernate | |
| 29 | * already provides its own ca ching in a hibernate session. | |
| 30 | * | |
| 31 | * Project : Framewor k</br> Cre ated on: 1 0:01:31 AM </br> | |
| 32 | * | |
| 33 | * @author DN S
|
|
| 34 | */ | |
| 35 | //@Compone nt | |
| 36 | public cla ss EntityC acheManage r extends AbstractCa cheManager { | |
| 37 | ||
| 38 | /* * | |
| 39 | * An instan ce of seri alVersionU ID | |
| 40 | * / | |
| 41 | pr ivate stat ic final l ong serial VersionUID = 1633957 0612429601 33L; | |
| 42 | ||
| 43 | /* * | |
| 44 | * A default construct or | |
| 45 | * / | |
| 46 | pu blic Entit yCacheMana ger() { | |
| 47 | supe r(); | |
| 48 | } | |
| 49 | ||
| 50 | /* * | |
| 51 | * Stores an item by t he specifi c key in a thread-bo und data c ache | |
| 52 | * | |
| 53 | * @param ke y | |
| 54 | * A unique key repre senting an entity to store | |
| 55 | * @param en tity | |
| 56 | * An entit y to be st ored in a thread-bou nd cache | |
| 57 | * / | |
| 58 | pu blic void storeItem( AbstractEn tity entit y, Object key) { | |
| 59 | ||
| 60 | Vali date.notNu ll(entity, "An entit y must not be null") ; | |
| 61 | Vali date.notNu ll(key, "A key must not be nul l"); | |
| 62 | ||
| 63 | if ( !Transacti onSynchron izationMan ager.isAct ualTransac tionActive () | |
| 64 | && !this .shouldCac heOutsideT ransaction ()) { | |
| 65 | if (lo gger.isDeb ugEnabled( )) | |
| 66 | logger.d ebug("Not caching en tity with key [" + k ey | |
| 67 | + "] since o utside of Transactio n scope"); | |
| 68 | } el se { | |
| 69 | String name = th is.getCach eName(); | |
| 70 | if (na me != null ) { | |
| 71 | // Get a cache for the curre nt transac tion | |
| 72 | if (cont ainsItem(n ame)) { | |
| 73 | Map cache = (Map) ge tItem(name ); | |
| 74 | cache.put( key, entit y); | |
| 75 | } else { | |
| 76 | synchroniz ed (this) { | |
| 77 | // A current transacti on doesn't have a ca che yet, | |
| 78 | // create on e | |
| 79 | Ma p cache = new HashMa p(); | |
| 80 | ca che.put(ke y, entity) ; | |
| 81 | ca cheItem(na me, cache) ; | |
| 82 | } | |
| 83 | } | |
| 84 | } | |
| 85 | } | |
| 86 | } | |
| 87 | ||
| 88 | /* * | |
| 89 | * Returns a n entity f rom a thre ad-bound d ata cache | |
| 90 | * | |
| 91 | * @param ke y | |
| 92 | * A unique key repre senting an entity to store | |
| 93 | * @return R eturns an entity fro m a cache | |
| 94 | * / | |
| 95 | pu blic Abstr actEntity getItem(En tityKey ke y) { | |
| 96 | ||
| 97 | Abst ractEntity entity = null; | |
| 98 | if ( key != nul l) { | |
| 99 | String name = Tr ansactionS ynchroniza tionManage r.getCurre ntTransact ionName(); | |
| 100 | if (co ntainsItem (name)) { | |
| 101 | Map cach e = (Map) getItem(na me); | |
| 102 | Object v alue = cac he.get(key ); | |
| 103 | entity = (value in stanceof A bstractEnt ity) ? (Ab stractEnti ty) value : null; | |
| 104 | } | |
| 105 | } | |
| 106 | retu rn entity; | |
| 107 | } | |
| 108 | ||
| 109 | /* * | |
| 110 | * Returns a name of a cache whi ch is usua lly a tran saction na me that is set | |
| 111 | * in a tran saction en ity interc eptor. | |
| 112 | * | |
| 113 | * @return A cache nam e | |
| 114 | * / | |
| 115 | pr otected St ring getCa cheName() { | |
| 116 | // A transacti on name is set in an entity in terceptor | |
| 117 | Stri ng name = Transactio nSynchroni zationMana ger.getCur rentTransa ctionName( ); | |
| 118 | if ( !Transacti onSynchron izationMan ager.isAct ualTransac tionActive ()) { | |
| 119 | ||
| 120 | Secure Random ran dom = new SecureRand om(); | |
| 121 | name = String.va lueOf(rand om.nextDou ble()); | |
| 122 | Transa ctionSynch ronization Manager.se tCurrentTr ansactionN ame(name); | |
| 123 | } | |
| 124 | retu rn name; | |
| 125 | } | |
| 126 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.