Produced by Araxis Merge on 12/5/2017 12:06:38 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\CoreValueObjects\main\src\java\gov\va\med\imaging\exchange | TimedCache.java | Mon Dec 4 21:34:36 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreValueObjects\main\src\java\gov\va\med\imaging\exchange | TimedCache.java | Mon Dec 4 21:58:44 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 244 |
| Changed | 2 | 4 |
| 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 | * | |
| 3 | Package: MAG - Vis tA Imaging | |
| 4 | WARNING: Per VHA D irective 2 004-038, t his routin e should n ot be modi fied. | |
| 5 | Date Cre ated: Dec 26, 2006 | |
| 6 | Site Nam e: Washin gton OI Fi eld Office , Silver S pring, MD | |
| 7 | Developer:
|
|
| 8 | Descript ion: | |
| 9 | Ba se timed c ache. Hold s cached i tems and i mplements the TimerT ask.run() event to p urge cache items aft er a desir ed amount of time. | |
| 10 | ||
| 11 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
| 12 | ;; Property of the US Government . | |
| 13 | ;; No permis sion to co py or redi stribute t his softwa re is give n. | |
| 14 | ;; Use of un released v ersions of this soft ware requi res the us er | |
| 15 | ;; to execu te a writt en test ag reement wi th the Vis tA Imaging | |
| 16 | ;; Developm ent Office of the De partment o f Veterans Affairs, | |
| 17 | ;; telephon e (301) 73 4-0100. | |
| 18 | ;; | |
| 19 | ;; The Food and Drug A dministrat ion classi fies this software a s | |
| 20 | ;; a Class I I medical device. A s such, it may not b e changed | |
| 21 | ;; in any wa y. Modifi cations to this soft ware may r esult in a n | |
| 22 | ;; adulterat ed medical device un der 21CFR8 20, the us e of which | |
| 23 | ;; is consid ered to be a violati on of US F ederal Sta tutes. | |
| 24 | ;; +-------- ---------- ---------- ---------- ---------- ---------- ---------- + | |
| 25 | ||
| 26 | */ | |
| 27 | package go v.va.med.i maging.exc hange; | |
| 28 | ||
| 29 | import jav a.util.Col lection; | |
| 30 | import jav a.util.Ite rator; | |
| 31 | import jav a.util.Map ; | |
| 32 | import jav a.util.Tim erTask; | |
| 33 | import jav a.util.con current.Co ncurrentHa shMap; | |
| 34 | ||
| 35 | import org .apache.lo gging.log4 j.LogManag er; | |
| 36 | import org .apache.lo gging.log4 j.Logger; | |
| 37 | ||
| 38 | import gov .va.med.im aging.Read WriteLockC ollections ; | |
| 39 | import gov .va.med.im aging.core .interface s.ITimedCa che; | |
| 40 | ||
| 41 | /** | |
| 42 | * Base ti med cache. Holds cac hed items and implem ents the T imerTask.r un() event to purge cache item s after a desired am ount of ti me. | |
| 43 | * | |
| 44 | * @author
|
|
| 45 | * | |
| 46 | */ | |
| 47 | public cla ss TimedCa che<U exte nds BaseTi medCacheVa lueItem> e xtends Tim erTask{ | |
| 48 | ||
| 49 | pr otected Ma p<Object, U> map = n ull; | |
| 50 | pr otected lo ng retenti onPeriod; | |
| 51 | pr ivate Stri ng cachedO bjectType; | |
| 52 | ||
| 53 | pr ivate Logg er logger = LogManag er.getLogg er(getClas s()); | |
| 54 | ||
| 55 | pu blic Timed Cache(Stri ng cachedO bjectType) { | |
| 56 | supe r(); | |
| 57 | this .cachedObj ectType = cachedObje ctType; | |
| 58 | rete ntionPerio d = 1000 * 60 * 15; // 15 minu tes | |
| 59 | try { | |
| 60 | map = new Concur rentHashMa p<Object, U>(); | |
| 61 | } | |
| 62 | catc h(Exceptio n eX) { | |
| 63 | map = null; | |
| 64 | eX.pri ntStackTra ce(); | |
| 65 | } | |
| 66 | } | |
| 67 | ||
| 68 | /* (non-Java doc) | |
| 69 | * @see gov. va.med.ima ging.excha nge.broker .interface s.ITimedCa che#purgeE xpiredCach eItems() | |
| 70 | * / | |
| 71 | pu blic void purgeExpir edCacheIte ms() { | |
| 72 | long expiredTi me = Syste m.currentT imeMillis( ) - retent ionPeriod; | |
| 73 | ||
| 74 | Coll ection<U> cacheItems = map.val ues(); | |
| 75 | logg er.debug(c achedObjec tType + " cache has [" + cache Items.size () + "] it ems"); | |
| 76 | Iter ator<U> ca cheIter = cacheItems .iterator( ); | |
| 77 | whil e(cacheIte r.hasNext( )) { | |
| 78 | U item = cacheIt er.next(); | |
| 79 | if(ite m.getRefre shTime() < expiredTi me) { | |
| 80 | cacheIte r.remove() ; | |
| 81 | } | |
| 82 | } | |
| 83 | } | |
| 84 | ||
| 85 | /* (non-Java doc) | |
| 86 | * @see java .util.Time rTask#run( ) | |
| 87 | * / | |
| 88 | @O verride | |
| 89 | pu blic void run() { | |
| 90 | logg er.debug(c achedObjec tType + ". run() [" + cachedObj ectType + "], purgin g expired cache item s"); | |
| 91 | purg eExpiredCa cheItems() ; | |
| 92 | } | |
| 93 | ||
| 94 | /* (non-Java doc) | |
| 95 | * @see gov. va.med.ima ging.excha nge.broker .interface s.ITimedCa che#getIte m(java.lan g.Object) | |
| 96 | * / | |
| 97 | pu blic U get Item(Objec t key) { | |
| 98 | retu rn map.get (key); | |
| 99 | } | |
| 100 | ||
| 101 | /* (non-Java doc) | |
| 102 | * @see gov. va.med.ima ging.excha nge.broker .interface s.ITimedCa che#update Item(gov.v a.med.imag ing.exchan ge.broker. BaseTimedC acheValueI tem) | |
| 103 | * / | |
| 104 | pu blic void updateItem (U object) { | |
| 105 | obje ct.updateR efreshTime (); | |
| 106 | map. put(object .getKey(), object); | |
| 107 | } | |
| 108 | ||
| 109 | /* (non-Java doc) | |
| 110 | * @see gov. va.med.ima ging.excha nge.broker .interface s.ITimedCa che#update Items(gov. va.med.ima ging.excha nge.broker .BaseTimed CacheValue Item[]) | |
| 111 | * / | |
| 112 | pu blic void updateItem s(U[] obje cts) { | |
| 113 | for( int i = 0; i < objec ts.length; i++) { | |
| 114 | update Item(objec ts[i]); | |
| 115 | } | |
| 116 | } | |
| 117 | ||
| 118 | /* (non-Java doc) | |
| 119 | * @see gov. va.med.ima ging.excha nge.broker .interface s.ITimedCa che#setRet entionPeri od(long) | |
| 120 | * / | |
| 121 | pu blic void setRetenti onPeriod(l ong period ) { | |
| 122 | rete ntionPerio d = period ; | |
| 123 | } | |
| 124 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.