Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8CB07C0B1 for ; Wed, 20 Jun 2012 16:06:41 +0000 (UTC) Received: (qmail 87087 invoked by uid 500); 20 Jun 2012 16:06:41 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 86987 invoked by uid 500); 20 Jun 2012 16:06:41 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 86979 invoked by uid 99); 20 Jun 2012 16:06:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jun 2012 16:06:41 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jun 2012 16:06:38 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4495E2388BEF; Wed, 20 Jun 2012 16:06:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1352192 - in /cxf/fediz/trunk/plugins/core/src/main: java/org/apache/cxf/fediz/core/ java/org/apache/cxf/fediz/core/config/ resources/ Date: Wed, 20 Jun 2012 16:06:17 -0000 To: commits@cxf.apache.org From: coheigea@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120620160617.4495E2388BEF@eris.apache.org> Author: coheigea Date: Wed Jun 20 16:06:16 2012 New Revision: 1352192 URL: http://svn.apache.org/viewvc?rev=1352192&view=rev Log: Made Cache configuration configurable Added: cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheUtil.java Modified: cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java cxf/fediz/trunk/plugins/core/src/main/resources/fediz-ehcache.xml Modified: cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java?rev=1352192&r1=1352191&r2=1352192&view=diff ============================================================================== --- cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java (original) +++ cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheTokenReplayCache.java Wed Jun 20 16:06:16 2012 @@ -26,6 +26,9 @@ import net.sf.ehcache.Cache; import net.sf.ehcache.CacheManager; import net.sf.ehcache.Ehcache; import net.sf.ehcache.Element; +import net.sf.ehcache.config.CacheConfiguration; +import net.sf.ehcache.config.Configuration; +import net.sf.ehcache.config.ConfigurationFactory; import org.apache.ws.security.util.Loader; @@ -55,10 +58,13 @@ public class EHCacheTokenReplayCache imp if (configFileURL == null) { cacheManager = CacheManager.create(); } else { - cacheManager = CacheManager.create(configFileURL); + Configuration conf = ConfigurationFactory.parseConfiguration(configFileURL); + cacheManager = CacheManager.create(conf); } - Ehcache newCache = new Cache(key, 50000, true, false, DEFAULT_TTL, DEFAULT_TTL); + CacheConfiguration cc = EHCacheUtil.getCacheConfiguration(key, cacheManager); + + Ehcache newCache = new Cache(cc); cache = cacheManager.addCacheIfAbsent(newCache); } Added: cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheUtil.java URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheUtil.java?rev=1352192&view=auto ============================================================================== --- cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheUtil.java (added) +++ cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/EHCacheUtil.java Wed Jun 20 16:06:16 2012 @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.cxf.fediz.core; + +import net.sf.ehcache.CacheManager; +import net.sf.ehcache.config.CacheConfiguration; + +/** + */ +public final class EHCacheUtil { + + private EHCacheUtil() { + // + } + + public static CacheConfiguration getCacheConfiguration(String key, CacheManager cacheManager) { + CacheConfiguration cc = cacheManager.getConfiguration().getCacheConfigurations().get(key); + if (cc == null && key.contains("-")) { + cc = cacheManager.getConfiguration().getCacheConfigurations().get( + key.substring(0, key.lastIndexOf('-') - 1)); + } + if (cc == null) { + cc = cacheManager.getConfiguration().getDefaultCacheConfiguration(); + } + if (cc == null) { + cc = new CacheConfiguration(); + } else { + cc = (CacheConfiguration)cc.clone(); + } + cc.setName(key); + return cc; + } + +} Modified: cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java?rev=1352192&r1=1352191&r2=1352192&view=diff ============================================================================== --- cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java (original) +++ cxf/fediz/trunk/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/FederationContext.java Wed Jun 20 16:06:16 2012 @@ -48,6 +48,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class FederationContext implements Closeable { + + public static final String CACHE_KEY_PREFIX = "fediz.replay.cache"; private static final Logger LOG = LoggerFactory.getLogger(FederationContext.class); @@ -162,7 +164,7 @@ public class FederationContext implement return replayCache; } String replayCacheString = config.getTokenReplayCache(); - String cacheKey = "fediz-replay-cache-" + config.getName(); + String cacheKey = CACHE_KEY_PREFIX + "-" + config.getName(); if (replayCacheString == null || "".equals(replayCacheString)) { replayCache = new EHCacheTokenReplayCache(cacheKey); } else { Modified: cxf/fediz/trunk/plugins/core/src/main/resources/fediz-ehcache.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/plugins/core/src/main/resources/fediz-ehcache.xml?rev=1352192&r1=1352191&r2=1352192&view=diff ============================================================================== --- cxf/fediz/trunk/plugins/core/src/main/resources/fediz-ehcache.xml (original) +++ cxf/fediz/trunk/plugins/core/src/main/resources/fediz-ehcache.xml Wed Jun 20 16:06:16 2012 @@ -3,7 +3,7 @@