01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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
34: ContentCacheKeyGenerator {
35: private List segments;
36: private boolean cacheBySessionId = true;
37:
38: public JetspeedCacheKeyGenerator(List segments) {
39: this .segments = segments;
40: this .cacheBySessionId = (segments.contains("sessionid"));
41: }
42:
43: public ContentCacheKey createCacheKey(RequestContext context,
44: String windowId) {
45: ContentCacheKey key = new JetspeedContentCacheKey(segments,
46: context, windowId);
47: return key;
48: }
49:
50: public ContentCacheKey createUserCacheKey(String username,
51: String pipeline, String windowId) {
52: ContentCacheKey key = new JetspeedContentCacheKey();
53: key.createFromUser(username, pipeline, windowId);
54: return key;
55: }
56:
57: public ContentCacheKey createSessionCacheKey(String sessionId,
58: String pipeline, String windowId) {
59: ContentCacheKey key = new JetspeedContentCacheKey();
60: key.createFromSession(sessionId, pipeline, windowId);
61: return key;
62: }
63:
64: public boolean isCacheBySessionId() {
65: return cacheBySessionId;
66: }
67:
68: public boolean isCacheByUsername() {
69: return !cacheBySessionId;
70: }
71: }
|