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 | BaseTimedCache.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 | BaseTimedCache.java | Mon Dec 4 21:58:44 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 252 |
| 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 BaseTim edCache<K, BaseTimed CacheValue Item> exte nds TimerT ask implem ents ITime dCache{ | |
| 48 | ||
| 49 | pr otected Ma p map = nu ll; | |
| 50 | pr otected lo ng retenti onPeriod; | |
| 51 | pr ivate Stri ng parentC lassName; | |
| 52 | ||
| 53 | pr ivate Logg er logger = LogManag er.getLogg er(getClas s()); | |
| 54 | ||
| 55 | pu blic BaseT imedCache( String par ent) { | |
| 56 | supe r(); | |
| 57 | this .parentCla ssName = p arent; | |
| 58 | rete ntionPerio d = 1000 * 60 * 15; // 15 minu tes | |
| 59 | try { | |
| 60 | map = (Map<K, Ba seTimedCac heValueIte m>)ReadWri teLockColl ections.re adWriteLoc kMap(new C oncurrentH ashMap<K, BaseTimedC acheValueI tem>()); | |
| 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<gov .va.med.im aging.exch ange.BaseT imedCacheV alueItem> cacheItems = map.val ues(); | |
| 75 | logg er.debug(p arentClass Name + " c ache has [ " + cacheI tems.size( ) + "] ite ms, about to purge e xpired ite ms"); | |
| 76 | int removedIte mCount = 0 ; | |
| 77 | Iter ator<gov.v a.med.imag ing.exchan ge.BaseTim edCacheVal ueItem> ca cheIter = cacheItems .iterator( ); | |
| 78 | whil e(cacheIte r.hasNext( )) { | |
| 79 | gov.va .med.imagi ng.exchang e.BaseTime dCacheValu eItem item = cacheIt er.next(); | |
| 80 | if(ite m.getRefre shTime() < expiredTi me) | |
| 81 | { | |
| 82 | cacheIte r.remove() ; | |
| 83 | removedI temCount++ ; | |
| 84 | } | |
| 85 | } | |
| 86 | logg er.debug(" Removed '" + removed ItemCount + "' items from " + parentClas sName + " cache"); | |
| 87 | } | |
| 88 | ||
| 89 | /* (non-Java doc) | |
| 90 | * @see java .util.Time rTask#run( ) | |
| 91 | * / | |
| 92 | @O verride | |
| 93 | pu blic void run() { | |
| 94 | logg er.debug(p arentClass Name + ".r un() [" + parentClas sName + "] , purging expired ca che items" ); | |
| 95 | purg eExpiredCa cheItems() ; | |
| 96 | } | |
| 97 | ||
| 98 | /* (non-Java doc) | |
| 99 | * @see gov. va.med.ima ging.excha nge.broker .interface s.ITimedCa che#getIte m(java.lan g.Object) | |
| 100 | * / | |
| 101 | pu blic gov.v a.med.imag ing.exchan ge.BaseTim edCacheVal ueItem get Item(Objec t key) { | |
| 102 | retu rn (gov.va .med.imagi ng.exchang e.BaseTime dCacheValu eItem)map. get(key); | |
| 103 | } | |
| 104 | ||
| 105 | /* (non-Java doc) | |
| 106 | * @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) | |
| 107 | * / | |
| 108 | pu blic void updateItem (gov.va.me d.imaging. exchange.B aseTimedCa cheValueIt em object) { | |
| 109 | obje ct.updateR efreshTime (); | |
| 110 | map. put(object .getKey(), object); | |
| 111 | } | |
| 112 | ||
| 113 | /* (non-Java doc) | |
| 114 | * @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[]) | |
| 115 | * / | |
| 116 | pu blic void updateItem s(gov.va.m ed.imaging .exchange. BaseTimedC acheValueI tem[] obje cts) { | |
| 117 | for( int i = 0; i < objec ts.length; i++) { | |
| 118 | update Item(objec ts[i]); | |
| 119 | } | |
| 120 | } | |
| 121 | ||
| 122 | /* (non-Java doc) | |
| 123 | * @see gov. va.med.ima ging.excha nge.broker .interface s.ITimedCa che#setRet entionPeri od(long) | |
| 124 | * / | |
| 125 | pu blic void setRetenti onPeriod(l ong period ) { | |
| 126 | rete ntionPerio d = period ; | |
| 127 | } | |
| 128 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.