Debian Codegraph @

java-sdk/ietfldap/org/ietf/ldap/LDAPCache.java

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is mozilla.org code.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1999
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38 package org.ietf.ldap;
39
40 import java.io.Serializable;
41 import java.util.Enumeration;
42 import java.util.Hashtable;
43 import java.util.Vector;
44 import java.util.zip.CRC32;
45
46 import org.ietf.ldap.util.DN;
47
48 /**
49 * <CODE>LDAPCache</CODE> represents an in-memory cache that you can use
50 * to reduce the number of search requests sent to the LDAP server.
51 * <P>
52 *
53 * Each item in the cache represents a search request and
54 * its results. Each item is uniquely identified by the
55 * search criteria, which includes:
56 * <P>
57 *
58 * <UL>
59 * <LI>the host name and port number of the LDAP server
60 * <LI>the base DN of the search
61 * <LI>the search filter
62 * <LI>the scope of the search
63 * <LI>the attributes to be returned in the search results
64 * <LI>the DN used to authenticate the client when binding
65 * to the server
66 * <LI>the LDAP v3 controls specified in the search request
67 * </UL>
68 * <P>
69 *
70 * After a search request is cached, the results of any
71 * subsequent search requests using the same criteria are
72 * read from the cache. Note that if any part of the
73 * criteria differs (for example, if a different DN is used
74 * when binding to the server or if a different set of
75 * attributes to be returned is specified), the search
76 * request is sent to the server.
77 * <P>
78 *
79 * When you create the cache, you specify the maximum amount
80 * of time that an item can be kept in the cache. When an
81 * item's age exceeds that time limit, the item is removed
82 * from the cache.
83 * <P>
84 *
85 * The cache also has a maximum size that you specify when
86 * creating the cache. If adding a new item exceeds the
87 * maximum size of the cache, the first entries in the cache
88 * are removed to make enough space for the new item.
89 * <P>
90 *
91 * Finally, when creating the cache, you can specify a list
92 * of the base DNs in search requests that you want to cache.
93 * For example, if you specify <CODE>o=Airius.com</CODE> as
94 * a base DN to cache, your client caches search requests
95 * where the base DN is <CODE>o=Airius.com</CODE>.
96 * <P>
97 *
98 * To specify that you want to use a cache for a particular
99 * LDAP session, call the <CODE>setCache</CODE> method of
100 * the <CODE>LDAPConnection</CODE> object that you are
101 * working with.
102 * <P>
103 *
104 * All clones of an <CODE>LDAPConnection</CODE> object share
105 * the same <CODE>LDAPCache</CODE> object.
106 * <P>
107 *
108 * Note that <CODE>LDAPCache</CODE> does not maintain consistency
109 * with the directory, so that cached search results may no longer be
110 * valid after a directory update. If the same application is performing
111 * both cached searches and directory updates, then the
112 * application should flush the corresponding cache entries after an update.
113 * To do this use the <CODE>flushEntries</CODE> method.
114 * <P>
115 *
116 * Also, note that search requests that return referrals are not cached.
117 * <P>
118 *
119 * The <CODE>LDAPCache</CODE> class includes methods for
120 * getting statistics (such as hit rates) from the cache and
121 * for flushing entries from the cache.
122 * <P>
123 *
124 * @see org.ietf.ldap.LDAPConnection#setCache(org.ietf.ldap.LDAPCache)
125 * @see org.ietf.ldap.LDAPConnection#getCache
126 */
127 public class LDAPCache implements Serializable {
128 static final long serialVersionUID = 6275167993337814294L;
129
130 /**
131 * A hashtable of search results. The key is created from the search
132 * request parameters (see createKey() method). The value is a Vector
133 * where the first element is a Long integer representing the size
134 * of all entries, followed by the actual search result entries (of type
135 * LDAPEntry).
136 */
137 private Hashtable<Long, Vector<Object>> m_cache;
138
139 /**
140 * A list of cached entries ordered by time (augments m_cache). Each
141 * element in the list is a 2 element Vector where the element at index
142 * 0 is the key in the m_cache table, and the element at index 1 is the
143 * time when the entry was created.
144 * The list is used to track the time-to-live limit and to implement the
145 * FIFO algorithm when adding new entries; if the size of the new entry
146 * exceeds the cache available space, the extra space is made by removing
147 * existing cached results in the order of their entry in the cache.
148 */
149 private Vector<Vector<Long>> m_orderedStruct;
150
151 private long m_timeToLive;
152 private long m_maxSize;
153 private String[] m_dns;
154 private long m_remainingSize = 0;
155
156 // Count of LDAPConnections that share this cache
157 private int m_refCnt = 0;
158
159 /**
160 * Delimiter used internally when creating keys
161 * for the cache.
162 */
163 public static final String DELIM = "#";
164 private TTLTimer m_timer = null;
165 private long m_totalOpers = 0;
166 private long m_hits = 0;
167 private long m_flushes = 0;
168
169 // Debug can be activated by defining debug.cache property
170 private static boolean m_debug = false;
171 static {
172 try {
173 String traceProp = System.getProperty("debug.cache");
174 m_debug = (traceProp != null);
175 }
176 catch (Exception e) {
177 ;// In browser access to property might not be allowed
178 }
179 }
180
181 /**
182 * Constructs a new <CODE>LDAPCache</CODE> object, using the
183 * specified maximum size of the cache (in bytes) and the maximum
184 * age of cached items (in seconds). When items in the cache
185 * exceed this age, they are removed from the cache.
186 * <P>
187 *
188 * @param ttl the maximum amount of time that an item can be cached
189 * (in seconds)
190 * @param size the maximum size of the cache (in bytes)
191 */
192 public LDAPCache(long ttl, long size)
193 {
194 init(ttl, size);
195 }
196
197 /**
198 * Constructs a new <CODE>LDAPCache</CODE> object, using the
199 * specified maximum size of the cache (in bytes), and the maximum
200 * age of cached items (in seconds), and an array of the base DNs
201 * of searches that you want to cache. (For example,
202 * if the array of base DNs includes <CODE>o=Airius.com</CODE>,
203 * the cache stores search results if the base DN in the search
204 * request is <CODE>o=Airius.com</CODE>.)
205 * <P>
206 *
207 * @param ttl the maximum amount of time that an item can be cached
208 * (in seconds)
209 * @param size the maximum size of the cache (in bytes)
210 * @param dns the list of base DNs of searches that you want to cache.
211 */
212 public LDAPCache(long ttl, long size, String[] dns)
213 {
214 init(ttl, size);
215
216 m_dns = new String[dns.length];
217 if ((dns != null) && (dns.length > 0))
218 for (int i=0; i<dns.length; i++) {
219 m_dns[i] = (new DN(dns[i])).toString();
220 }
221 }
222
223 /**
224 * Gets the maximum size of the cache (in bytes).
225 * <P>
226 *
227 * @return the maximum size of the cache (in bytes).
228 */
229 public long getSize()
230 {
231 return m_maxSize;
232 }
233
234 /**
235 * Gets the maximum age allowed for cached items (in
236 * seconds). (Items that exceed this age are
237 * removed from the cache.)
238 * <P>
239 *
240 * @return the maximum age of items in the cache (in
241 * seconds).
242 */
243 public long getTimeToLive()
244 {
245 return m_timeToLive/1000;
246 }
247
248 /**
249 * Gets the array of base DNs of searches to be cached.
250 * (Search requests with these base DNs are cached.)
251 * <P>
252 *
253 * @return the array of base DNs.
254 */
255 public String[] getBaseDNs()
256 {
257 return m_dns;
258 }
259
260 /**
261 * Flush the entries identified by DN and scope from the cache.
262 * <P>
263 *
264 * @param dn the distinguished name (or base DN) of the entries
265 * to be removed from the cache. Use this parameter in conjunction
266 * with <CODE>scope</CODE> to identify the entries that you want
267 * removed from the cache. If this parameter is <CODE>null</CODE>,
268 * the entire cache is flushed.
269 * @param scope the scope identifying the entries that you want
270 * removed from the cache. The value of this parameter can be
271 * one of the following:
272 * <UL>
273 * <LI><CODE>LDAPConnection.SCOPE_BASE</CODE> (to remove the entry identified
274 * by <CODE>dn</CODE>)
275 * <LI><CODE>LDAPConnection.SCOPE_ONE</CODE> (to remove the entries that
276 * have <CODE>dn</CODE> as their parent entry)
277 * <LI><CODE>LDAPConnection.SCOPE_SUB</CODE> (to remove the entries in the
278 * subtree under <CODE>dn</CODE> in the directory)
279 * </UL>
280 * <P>
281 * @return <CODE>true</CODE> if the entry is removed from the cache;
282 * <CODE>false</CODE> if the entry is not removed.
283 */
284 public synchronized boolean flushEntries(String dn, int scope) {
285
286 if (m_debug)
287 System.out.println("DEBUG: User request for flushing entry: dn "+
288 dn+" and scope "+scope);
289 // if the dn is null, invalidate the whole cache
290 if (dn == null)
291 {
292 // reclaim all the cache spaces
293 m_remainingSize = m_maxSize;
294 m_cache.clear();
295 m_orderedStruct.removeAllElements();
296 // reset stats
297 m_totalOpers = m_hits = m_flushes = 0;
298
299 return true;
300 }
301
302 DN dn2 = new DN(dn);
303
304 Enumeration<Long> e = m_cache.keys();
305
306 while(e.hasMoreElements()) {
307 Long key = e.nextElement();
308 Vector<Object> val = m_cache.get(key);
309
310 // LDAPEntries start at idx 1, at idx 0 is a Long
311 // (size of all LDAPEntries returned by search())
312 int j=1;
313 int size2=val.size();
314
315 for (; j<size2; j++) {
316 String d = ((LDAPEntry)val.elementAt(j)).getDN();
317 DN dn1 = new DN(d);
318
319 if (dn1.equals(dn2))
320 break;
321 if (scope == LDAPConnection.SCOPE_ONE) {
322 DN parentDN1 = dn1.getParent();
323 if (parentDN1.equals(dn2)) {
324 break;
325 }
326 }
327 if ((scope == LDAPConnection.SCOPE_SUB) &&
328 (dn1.isDescendantOf(dn2))) {
329 break;
330 }
331 }
332
333 if (j < size2) {
334 for (int k=0; k<m_orderedStruct.size(); k++) {
335 Vector<Long> v = m_orderedStruct.elementAt(k);
336 if (key.equals(v.elementAt(0))) {
337 m_orderedStruct.removeElementAt(k);
338 break;
339 }
340 }
341 Vector<Object> entry = m_cache.remove(key);
342 m_remainingSize += ((Long)entry.firstElement()).longValue();
343 if (m_debug)
344 System.out.println("DEBUG: Successfully removed entry ->"+key);
345
346 return true;
347 }
348 }
349
350 if (m_debug)
351 System.out.println("DEBUG: The number of keys in the cache is "
352 +m_cache.size());
353
354 return false;
355 }
356
357 /**
358 * Gets the amount of available space (in bytes) left in the cache.
359 * <P>
360 *
361 * @return the available space (in bytes) in the cache.
362 */
363 public long getAvailableSize() {
364 return m_remainingSize;
365 }
366
367 /**
368 * Gets the total number of requests for retrieving items from
369 * the cache. This includes both items successfully found in
370 * the cache and items not found in the cache.
371 * <P>
372 *
373 * @return the total number of requests for retrieving items from
374 * the cache.
375 */
376 public long getTotalOperations() {
377 return m_totalOpers;
378 }
379
380 /**
381 * Gets the total number of requests which failed to find and
382 * retrieve an item from the cache.
383 * <P>
384 *
385 * @return the number of requests that did not find and retrieve
386 * an item in the cache.
387 */
388 public long getNumMisses() {
389 return (m_totalOpers - m_hits);
390 }
391
392 /**
393 * Gets the total number of requests which successfully found and
394 * retrieved an item from the cache.
395 * @return the number of requests that successfully found and
396 * retrieved an item from the cache.
397 */
398 public long getNumHits() {
399 return m_hits;
400 }
401
402 /**
403 * Gets the total number of entries that are flushed when timer expires
404 * and <CODE>flushEntries</CODE> is called.
405 * <P>
406 *
407 * @return the total number of entries that are flushed when timer
408 * expires.
409 */
410 public long getNumFlushes() {
411 return m_flushes;
412 }
413
414 /**
415 * Create a key for a cache entry by concatenating all input parameters
416 * @return the key for a cache entry
417 * @exception LDAPException Thrown when failed to create key.
418 */
419 Long createKey(String host, int port, String baseDN, String filter,
420 int scope, String[] attrs, String bindDN, LDAPConstraints cons)
421 throws LDAPException {
422
423 DN dn = new DN(baseDN);
424 baseDN = dn.toString();
425
426 if (m_dns != null) {
427 int i=0;
428 for (; i<m_dns.length; i++) {
429 if (baseDN.equals(m_dns[i]))
430 break;
431 }
432
433 if (i >= m_dns.length)
434 throw new LDAPException(baseDN+" is not a cached base DN",
435 LDAPException.OTHER);
436 }
437
438 String key = null;
439
440 key = appendString(baseDN);
441 key = key+appendString(scope);
442 key = key+appendString(host);
443 key = key+appendString(port);
444 key = key+appendString(filter);
445 key = key+appendString(attrs);
446 key = key+appendString(bindDN);
447
448 LDAPControl[] serverControls = null;
449
450 // get server and client controls
451 if (cons != null) {
452 serverControls = cons.getControls();
453 }
454
455 if ((serverControls != null) && (serverControls.length > 0)) {
456 String[] objID = new String[serverControls.length];
457
458 for (int i=0; i<serverControls.length; i++) {
459 LDAPControl ctrl = serverControls[i];
460 long val = getCRC32(ctrl.getValue());
461 objID[i] = ctrl.getID() + ctrl.isCritical() + val;
462 }
463 key = key + appendString(objID);
464 } else {
465 key = key+appendString(0);
466 }
467
468 long val = getCRC32(key.getBytes());
469 if ( m_debug ) {
470 System.out.println("key="+val + " for "+key);
471 }
472 return val;
473 }
474
475 /**
476 * Gets the cache entry based on the specified key.
477 * @param key the key for the cache entry
478 * @return the cache entry.
479 */
480 synchronized Vector<Object> getEntry(Long key) {
481 Vector<Object> obj = m_cache.get(key);
482 m_totalOpers++;
483
484 if (m_debug) {
485 if (obj == null)
486 System.out.println("DEBUG: Entry whose key -> "+key+
487 " not found in the cache.");
488 else
489 System.out.println("DEBUG: Entry whose key -> "+key+
490 " found in the cache.");
491 }
492
493 if (obj != null)
494 m_hits++;
495
496
497 return obj;
498 }
499
500 /**
501 * Flush entries which stay longer or equal to the time-to-live.
502 */
503 synchronized void flushEntries()
504 {
505 Vector<Long> v = null;
506 boolean delete = false;
507
508 long currTime = System.currentTimeMillis();
509
510 m_flushes = 0;
511 while(true) {
512 if (m_orderedStruct.size() <= 0)
513 break;
514
515 v = m_orderedStruct.firstElement();
516 long diff = currTime-v.elementAt(1).longValue();
517 if (diff >= m_timeToLive) {
518 Long key = v.elementAt(0);
519
520 if (m_debug)
521 System.out.println("DEBUG: Timer flush entry whose key is "+key);
522 Vector<Object> entry = m_cache.remove(key);
523 m_remainingSize += ((Long)entry.firstElement()).longValue();
524
525 // always delete the first one
526 m_orderedStruct.removeElementAt(0);
527
528 m_flushes++;
529 }
530 else
531 break;
532 }
533
534 if (m_debug)
535 System.out.println("DEBUG: The number of keys in the cache is "
536 +m_cache.size());
537 }
538
539 /**
540 * Add the entry to the hashtable cache and to the vector respectively.
541 * The vector is used to keep track of the order of the entries being added.
542 * @param key the key for the cache entry
543 * @param value the cache entry being added to the cache for the specified
544 * key
545 * @return a flag indicating whether the entry was added.
546 */
547 synchronized boolean addEntry(Long key, Object value)
548 {
549 // if entry exists, dont perform add operation
550 if (m_cache.get(key) != null)
551 return false;
552
553 Vector<Object> v = (Vector<Object>)value;
554 long size = ((Long)v.elementAt(0)).longValue();
555
556 if (size > m_maxSize) {
557 if (m_debug) {
558 System.out.println("Failed to add an entry to the cache since the new entry exceeds the cache size");
559 }
560 return false;
561 }
562
563 // if the size of entry being added is bigger than the spare space in the
564 // cache
565 if (size > m_remainingSize) {
566 while (true) {
567 Vector<Long> element = m_orderedStruct.firstElement();
568 Long str = element.elementAt(0);
569 Vector<Object> val = m_cache.remove(str);
570 if (m_debug)
571 System.out.println("DEBUG: The spare size of the cache is not big enough "+
572 "to hold the new entry, deleting the entry whose key -> "+str);
573
574 // always remove the first one
575 m_orderedStruct.removeElementAt(0);
576 m_remainingSize += ((Long)val.elementAt(0)).longValue();
577 if (m_remainingSize >= size)
578 break;
579 }
580 }
581
582 m_remainingSize -= size;
583 m_cache.put(key, v);
584 Vector<Long> element = new Vector<>(2);
585 element.addElement(key);
586 element.addElement(System.currentTimeMillis());
587 m_orderedStruct.addElement(element);
588
589 // Start TTL Timer if first entry is added
590 if (m_orderedStruct.size() == 1) {
591 scheduleTTLTimer();
592 }
593
594 if (m_debug)
595 {
596 System.out.println("DEBUG: Adding a new entry whose key -> "+key);
597 System.out.println("DEBUG: The current number of keys in the cache "+
598 m_cache.size());
599 }
600 return true;
601 }
602
603 /**
604 * Flush entries which stayed longer or equal to the time-to-live, and
605 * Set up the TTLTimer for the next flush. Called when first entry is
606 * added to the cache and when the TTLTimer expires.
607 */
608 synchronized void scheduleTTLTimer() {
609 if (m_orderedStruct.size() <= 0) {
610 return;
611 }
612
613 if (m_timer == null) {
614 m_timer = new TTLTimer(this);
615 }
616
617 Vector<Long> v = m_orderedStruct.firstElement();
618 long currTime = System.currentTimeMillis();
619 long creationTime = v.elementAt(1).longValue();
620 long timeout = creationTime + m_timeToLive - currTime;
621 if (timeout > 0) {
622 m_timer.start(timeout);
623 }
624 else {
625 flushEntries();
626 scheduleTTLTimer();
627 }
628 }
629
630
631 /**
632 * Gets the number of entries being cached.
633 * @return the number of entries being cached.
634 */
635 public int getNumEntries()
636 {
637 return m_cache.size();
638 }
639
640 /**
641 * Get number of LDAPConnections that share this cache
642 * @return Reference Count
643 */
644 int getRefCount() {
645 return m_refCnt;
646 }
647
648 /**
649 * Add a new reference to this cache.
650 *
651 */
652 synchronized void addReference() {
653 m_refCnt++;
654 if (m_debug) {
655 System.err.println("Cache refCnt="+ m_refCnt);
656 }
657 }
658
659 /**
660 * Remove a reference to this cache.
661 * If the reference count is 0, cleaup the cache.
662 *
663 */
664 synchronized void removeReference() {
665 if (m_refCnt > 0) {
666 m_refCnt--;
667 if (m_debug) {
668 System.err.println("Cache refCnt="+ m_refCnt);
669 }
670 if (m_refCnt == 0 ) {
671 cleanup();
672 }
673 }
674 }
675
676 /**
677 * Cleans up
678 */
679 synchronized void cleanup() {
680 flushEntries(null, 0);
681 if (m_timer != null) {
682 m_timer.stop();
683 m_timer = null;
684 }
685 }
686
687 /**
688 * Initialize the instance variables.
689 */
690 private void init(long ttl, long size)
691 {
692 m_cache = new Hashtable<>();
693 m_timeToLive = ttl*1000;
694 m_maxSize = size;
695 m_remainingSize = size;
696 m_dns = null;
697 m_orderedStruct = new Vector<>();
698 }
699
700 /**
701 * Concatenates the specified integer with the delimiter.
702 * @param str the String to concatenate with the delimiter
703 * @return the concatenated string.
704 */
705 private String appendString(String str) {
706 if (str == null)
707 return "null"+DELIM;
708 else
709 return str.trim()+DELIM;
710 }
711
712 /**
713 * Concatenates the specified integer with the delimiter.
714 * @param num the integer to concatenate with the delimiter
715 * @return the concatenated string.
716 */
717 private String appendString(int num) {
718 return num+DELIM;
719 }
720
721 /**
722 * Concatenate the specified string array with the delimiter.
723 * @param str a string array
724 * @return the concatenated string.
725 */
726 private String appendString(String[] str) {
727
728 if ((str == null) || (str.length < 1))
729 return "0"+DELIM;
730 else {
731 String[] sorted = new String[str.length];
732 System.arraycopy( str, 0, sorted, 0, str.length );
733 sortStrings(sorted);
734
735 String s = sorted.length+DELIM;
736 for (int i=0; i<sorted.length; i++)
737 s = s+sorted[i].trim()+DELIM;
738 return s;
739 }
740 }
741
742 /**
743 * Sorts the array of strings using bubble sort.
744 * @param str the array of strings to sort. The str parameter contains
745 * the sorted result.
746 */
747 private void sortStrings(String[] str) {
748
749 for (int i=0; i<str.length; i++)
750 str[i] = str[i].trim();
751
752 for (int i=0; i<str.length-1; i++)
753 for (int j=i+1; j<str.length; j++)
754 {
755 if (str[i].compareTo(str[j]) > 0)
756 {
757 String t = str[i];
758 str[i] = str[j];
759 str[j] = t;
760 }
761 }
762 }
763
764 /**
765 * Create a 32 bits CRC from the given byte array.
766 */
767 private long getCRC32(byte[] barray) {
768 if (barray==null) {
769 return 0;
770 }
771 CRC32 crcVal = new CRC32();
772 crcVal.update(barray);
773 return crcVal.getValue();
774 }
775 }
776
777 /**
778 * Represents a timer which will timeout for every certain interval. It
779 * provides methods to start, stop, or restart timer.
780 */
781 class TTLTimer implements Runnable{
782
783 private long m_timeout;
784 private LDAPCache m_cache;
785 private Thread t = null;
786
787 /**
788 * Constructor with the specified timout.
789 * @param timeout the timeout value in milliseconds
790 */
791 TTLTimer(LDAPCache cache) {
792 m_cache = cache;
793 }
794
795 /**
796 * (Re)start the timer.
797 */
798 void start(long timeout) {
799 m_timeout = timeout;
800 if (Thread.currentThread() != t) {
801 stop();
802 }
803 t = new Thread(this, "LDAPCache-TTLTimer");
804 t.setDaemon(true);
805 t.start();
806 }
807
808 /**
809 * Stop the timer.
810 */
811 void stop() {
812 if (t !=null) {
813 t.interrupt();
814 }
815 }
816
817 /**
818 * The runnable waits until the timeout period has elapsed. It then notify
819 * the registered listener who listens for the timeout event.
820 */
821 public void run() {
822
823 synchronized(this) {
824 try {
825 this.wait(m_timeout);
826 } catch (InterruptedException e) {
827 // This happens if the timer is stopped
828 return;
829 }
830 }
831
832 m_cache.scheduleTTLTimer();
833 }
834 }