1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.cache.impl;
19
20 import java.util.Iterator;
21 import java.util.List;
22
23 import org.apache.jetspeed.cache.ContentCacheKey;
24 import org.apache.jetspeed.cache.ContentCacheKeyGenerator;
25 import org.apache.jetspeed.request.RequestContext;
26
27 /***
28 * Wrapper around actual cache implementation
29 *
30 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
31 * @version $Id: $
32 */
33 public class JetspeedCacheKeyGenerator implements ContentCacheKeyGenerator
34 {
35 private List segments;
36 private boolean cacheBySessionId = true;
37
38 public JetspeedCacheKeyGenerator(List segments)
39 {
40 this.segments = segments;
41 this.cacheBySessionId = (segments.contains("sessionid"));
42 }
43
44 public ContentCacheKey createCacheKey(RequestContext context, String windowId)
45 {
46 ContentCacheKey key = new JetspeedContentCacheKey(segments, context, windowId);
47 return key;
48 }
49
50 public ContentCacheKey createUserCacheKey(String username, String pipeline, String windowId)
51 {
52 ContentCacheKey key = new JetspeedContentCacheKey();
53 key.createFromUser(username, pipeline, windowId);
54 return key;
55 }
56
57 public ContentCacheKey createSessionCacheKey(String sessionId, String pipeline, String windowId)
58 {
59 ContentCacheKey key = new JetspeedContentCacheKey();
60 key.createFromSession(sessionId, pipeline, windowId);
61 return key;
62 }
63
64 public boolean isCacheBySessionId()
65 {
66 return cacheBySessionId;
67 }
68
69 public boolean isCacheByUsername()
70 {
71 return !cacheBySessionId;
72 }
73 }