1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * 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 and15 * limitations under the License.16 */1718packageorg.apache.jetspeed.cache.impl;
1920import java.util.Iterator;
21import java.util.List;
2223import org.apache.jetspeed.cache.ContentCacheKey;
24import org.apache.jetspeed.cache.ContentCacheKeyGenerator;
25import org.apache.jetspeed.request.RequestContext;
2627/***28 * Wrapper around actual cache implementation29 * 30 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>31 * @version $Id: $32 */33publicclassJetspeedCacheKeyGenerator implements ContentCacheKeyGenerator
34 {
35private List segments;
36privateboolean cacheBySessionId = true;
3738publicJetspeedCacheKeyGenerator(List segments)
39 {
40this.segments = segments;
41this.cacheBySessionId = (segments.contains("sessionid"));
42 }
4344public ContentCacheKey createCacheKey(RequestContext context, String windowId)
45 {
46 ContentCacheKey key = newJetspeedContentCacheKey(segments, context, windowId);
47return key;
48 }
4950public ContentCacheKey createUserCacheKey(String username, String pipeline, String windowId)
51 {
52 ContentCacheKey key = newJetspeedContentCacheKey();
53 key.createFromUser(username, pipeline, windowId);
54return key;
55 }
5657public ContentCacheKey createSessionCacheKey(String sessionId, String pipeline, String windowId)
58 {
59 ContentCacheKey key = newJetspeedContentCacheKey();
60 key.createFromSession(sessionId, pipeline, windowId);
61return key;
62 }
6364publicboolean isCacheBySessionId()
65 {
66return cacheBySessionId;
67 }
6869publicboolean isCacheByUsername()
70 {
71return !cacheBySessionId;
72 }
73 }