KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > remoting > transport > socket > LRUPool


1 /***************************************
2  * *
3  * JBoss: The OpenSource J2EE WebOS *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  ***************************************/

9
10 package org.jboss.remoting.transport.socket;
11
12
13 import java.util.Set JavaDoc;
14 import org.jboss.util.LRUCachePolicy;
15
16 /**
17  * This class is an extention of LRUCachePolicy. On a entry removal
18  * it makes sure to call shutdown on the pooled ServerThread
19  *
20  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
21  */

22 public class LRUPool extends LRUCachePolicy
23 {
24    public LRUPool(int min, int max)
25    {
26       super(min, max);
27    }
28
29    protected void entryRemoved(LRUCacheEntry entry)
30    {
31       ServerThread thread = (ServerThread) entry.m_object;
32       thread.evict();
33    }
34
35    public void evict()
36    {
37       // the entry will be removed by ageOut
38
ServerThread thread = (ServerThread) m_list.m_tail.m_object;
39       thread.evict();
40    }
41
42    public Set JavaDoc getContents()
43    {
44       return m_map.keySet();
45    }
46
47 }
48
Popular Tags