1 package org.apache.commons.jcs.engine;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.jcs.engine.behavior.ICacheEventQueue;
23 import org.apache.commons.jcs.engine.behavior.ICacheListener;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27
28
29
30
31
32
33 public class CacheEventQueueFactory<K, V>
34 {
35
36 private static final Log log = LogFactory.getLog( CacheEventQueueFactory.class );
37
38
39
40
41
42
43
44
45
46
47
48 public ICacheEventQueue<K, V> createCacheEventQueue( ICacheListener<K, V> listener, long listenerId, String cacheName,
49 String threadPoolName, ICacheEventQueue.QueueType poolType )
50 {
51 return createCacheEventQueue( listener, listenerId, cacheName, 10, 500, threadPoolName, poolType );
52 }
53
54
55
56
57
58
59
60
61
62
63
64
65
66 public ICacheEventQueue<K, V> createCacheEventQueue( ICacheListener<K, V> listener, long listenerId, String cacheName,
67 int maxFailure, int waitBeforeRetry, String threadPoolName,
68 ICacheEventQueue.QueueType poolType )
69 {
70 if ( log.isDebugEnabled() )
71 {
72 log.debug( "threadPoolName = [" + threadPoolName + "] poolType = " + poolType + " " );
73 }
74
75 ICacheEventQueue<K, V> eventQueue = null;
76 if ( poolType == null || ICacheEventQueue.QueueType.SINGLE == poolType )
77 {
78 eventQueue = new CacheEventQueue<K, V>( listener, listenerId, cacheName, maxFailure, waitBeforeRetry );
79 }
80 else if ( ICacheEventQueue.QueueType.POOLED == poolType )
81 {
82 eventQueue = new PooledCacheEventQueue<K, V>( listener, listenerId, cacheName, maxFailure, waitBeforeRetry,
83 threadPoolName );
84 }
85
86 return eventQueue;
87 }
88 }