You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ie...@apache.org on 2012/10/29 05:47:49 UTC

svn commit: r1403171 - in /sling/whiteboard/ieb: ./ cache/ cache/api/ cache/api/src/ cache/api/src/main/ cache/api/src/main/java/ cache/api/src/main/java/org/ cache/api/src/main/java/org/apache/ cache/api/src/main/java/org/apache/sling/ cache/api/src/m...

Author: ieb
Date: Mon Oct 29 04:47:47 2012
New Revision: 1403171

URL: http://svn.apache.org/viewvc?rev=1403171&view=rev
Log:
SLING-2555 Initial implementation of the API and impl for Caching subsystem.

Added:
    sling/whiteboard/ieb/
    sling/whiteboard/ieb/cache/
    sling/whiteboard/ieb/cache/api/
    sling/whiteboard/ieb/cache/api/README.txt   (with props)
    sling/whiteboard/ieb/cache/api/pom.xml   (with props)
    sling/whiteboard/ieb/cache/api/src/
    sling/whiteboard/ieb/cache/api/src/main/
    sling/whiteboard/ieb/cache/api/src/main/java/
    sling/whiteboard/ieb/cache/api/src/main/java/org/
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/Cache.java   (with props)
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheManagerService.java   (with props)
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheScope.java   (with props)
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/ThreadBound.java   (with props)
    sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/package-info.java   (with props)
    sling/whiteboard/ieb/cache/ehcache/
    sling/whiteboard/ieb/cache/ehcache/README.txt   (with props)
    sling/whiteboard/ieb/cache/ehcache/pom.xml   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/
    sling/whiteboard/ieb/cache/ehcache/src/main/
    sling/whiteboard/ieb/cache/ehcache/src/main/java/
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheImpl.java   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheManagerServiceImpl.java   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapCacheImpl.java   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapDeligate.java   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/ThreadLocalCacheMap.java   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/main/resources/
    sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/
    sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/
    sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/
    sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/
    sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/cache/
    sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/cache/ehcache/
    sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/cache/ehcache/ehcacheConfig.xml   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/test/
    sling/whiteboard/ieb/cache/ehcache/src/test/java/
    sling/whiteboard/ieb/cache/ehcache/src/test/java/org/
    sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/
    sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/
    sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/
    sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/
    sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/
    sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheConfigTest.java   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/MapBuilder.java   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/TestCache.java   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/test/resources/
    sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/
    sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/cluster-ehcacheConfig.xml   (with props)
    sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/simple-ehcacheConfig.xml   (with props)

Added: sling/whiteboard/ieb/cache/api/README.txt
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/api/README.txt?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/api/README.txt (added)
+++ sling/whiteboard/ieb/cache/api/README.txt Mon Oct 29 04:47:47 2012
@@ -0,0 +1,12 @@
+Commons Cache.
+
+This is an Cache API, the implementation of which will allow applications written in Sling to cache data locally, 
+cache locally with cluster wide invalidation, and cache and replicate data. The exact nature of the cache behaviour
+depends on the implementation of the API.
+
+
+Acknowledgments
+
+This code was based on a module from Sparse Content Map 29 September 2012 (git:sha1:a222df1937434ad3f07bf6c4f60b19524a158bcb), which itself was based on a snapshot of a 
+module in Sakai Nakamura 27 Jan 2011 (git:sha1:b9d8e65b733ec7c35a3d194c9a5dc12acf13cb34). All know contributors to code in this module have been
+contacted for permission to grant license to the Apache Foundation.
\ No newline at end of file

Propchange: sling/whiteboard/ieb/cache/api/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/ieb/cache/api/README.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/whiteboard/ieb/cache/api/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/api/pom.xml?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/api/pom.xml (added)
+++ sling/whiteboard/ieb/cache/api/pom.xml Mon Oct 29 04:47:47 2012
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>13</version>
+    </parent>
+
+    <artifactId>org.apache.sling.commons.cache.api</artifactId>
+    <version>0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache Sling Cache API</name>
+    <description>
+        This bundle porvides a Cache API for Sling applications to use.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/whiteboard/ieb/cache/api</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/whiteboard/ieb/cache/api</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/api</url>
+    </scm>
+    
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.3.6</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <!--  used for package-info annotations -->
+        <dependency>
+            <groupId>biz.aQute</groupId>
+            <artifactId>bndlib</artifactId>
+            <version>1.50.0</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+</project>

Propchange: sling/whiteboard/ieb/cache/api/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/ieb/cache/api/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/Cache.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/Cache.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/Cache.java (added)
+++ sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/Cache.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,87 @@
+/*
+ * 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.sling.commons.cache.api;
+
+import java.util.List;
+
+/**
+ * A Cache managed by the cache manager.
+ */
+public interface Cache<V> {
+
+	/**
+	 * Cache an object
+	 * 
+	 * @param key
+	 *            The key with which to find the object.
+	 * @param payload
+	 *            The object to cache.
+	 * @param duration
+	 *            The time to cache the object (seconds).
+	 */
+	V put(String key, V payload);
+
+	/**
+	 * Test for a non expired entry in the cache.
+	 * 
+	 * @param key
+	 *            The cache key.
+	 * @return true if the key maps to a non-expired cache entry, false if not.
+	 */
+	boolean containsKey(String key);
+
+	/**
+	 * Get the non expired entry, or null if not there (or expired)
+	 * 
+	 * @param key
+	 *            The cache key.
+	 * @return The payload, or null if the payload is null, the key is not
+	 *         found, or the entry has expired (Note: use containsKey() to
+	 *         remove this ambiguity).
+	 */
+	V get(String key);
+
+	/**
+	 * Clear all entries.
+	 */
+	void clear();
+
+	/**
+	 * Remove this entry from the cache.
+	 * 
+	 * @param key
+	 *            The cache key.
+	 */
+	void remove(String key);
+
+	/**
+	 * Remove the key and any child keys from the cache, this is an expensive
+	 * operation.
+	 * 
+	 * @param key
+	 */
+	void removeChildren(String key);
+
+	/**
+	 * @return
+	 */
+	List<V> list();
+
+}

Propchange: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/Cache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheManagerService.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheManagerService.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheManagerService.java (added)
+++ sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheManagerService.java Mon Oct 29 04:47:47 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.sling.commons.cache.api;
+
+/**
+ * The Cache manager provides access to all caches in the system. Caches are
+ * scoped by CacheScope and those that are bound can be unbound.
+ */
+public interface CacheManagerService {
+
+	/**
+	 * Get a cache to contain a specified type, with a defined scope. Getting a
+	 * cache of the same name in the same scope will return the same cache for
+	 * that scope. The thread invoking the method forms part of the scope for
+	 * CacheScopes THREAD or REQUEST.
+	 * 
+	 * @param <T>
+	 *            The type of the elements, but be serializable for any non
+	 *            thread bound cache.
+	 * @param name
+	 *            the name of the cache.
+	 * @param scope
+	 *            the scope of the cache.
+	 * @return the cache suitable for holding the type T
+	 */
+	<T> Cache<T> getCache(String name, CacheScope scope);
+
+	/**
+	 * Unbind the the context specified in scope.
+	 * 
+	 * @param scope
+	 */
+	void unbind(CacheScope scope);
+}

Propchange: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheManagerService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheScope.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheScope.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheScope.java (added)
+++ sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheScope.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,50 @@
+/*
+ * 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.sling.commons.cache.api;
+
+/**
+ * Defines the scope of the cache
+ */
+public enum CacheScope {
+	/**
+	 * Bind the Cache to the request scope.
+	 */
+	REQUEST(),
+	/**
+	 * Bind a cache to the Thread, forever. WARNING: use with extreme caution,
+	 * as any classes referenced in this type of cache will keep classloaders
+	 * open and result in memory leaks
+	 */
+	THREAD(),
+	/**
+	 * Bind the cache to the instance, one per instance.
+	 */
+	INSTANCE(),
+	/**
+	 * Make the cache bound to the instance, but accept cluster wide
+	 * invalidations.
+	 */
+	CLUSTERINVALIDATED(),
+	/**
+	 * Replicate the cache over the whole cluster.
+	 */
+	CLUSTERREPLICATED();
+
+}

Propchange: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/CacheScope.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/ThreadBound.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/ThreadBound.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/ThreadBound.java (added)
+++ sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/ThreadBound.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,35 @@
+/*
+ * 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.sling.commons.cache.api;
+
+/**
+ * Objects that are added to a ThreadLocalManager, that implement this method
+ * will have the unbind method called when the object is ejected from the thread
+ * local.
+ * 
+ */
+public interface ThreadBound {
+
+	/**
+	 * Invoked when the item is unbound from the thread.
+	 */
+	void unbind();
+
+}

Propchange: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/ThreadBound.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/package-info.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/package-info.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/package-info.java (added)
+++ sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/package-info.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+@Version("1.0")
+package org.apache.sling.commons.cache.api;
+
+import aQute.bnd.annotation.Version;
+

Propchange: sling/whiteboard/ieb/cache/api/src/main/java/org/apache/sling/commons/cache/api/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/ehcache/README.txt
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/README.txt?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/README.txt (added)
+++ sling/whiteboard/ieb/cache/ehcache/README.txt Mon Oct 29 04:47:47 2012
@@ -0,0 +1,10 @@
+Commons Cache.
+
+This is an implementation of the Cache API based on EhCache.
+
+
+Acknowledgments
+
+This code was based on a module from Sparse Content Map 29 September 2012 (git:sha1:a222df1937434ad3f07bf6c4f60b19524a158bcb), which itself was based on a snapshot of a 
+module in Sakai Nakamura 27 Jan 2011 (git:sha1:b9d8e65b733ec7c35a3d194c9a5dc12acf13cb34). All know contributors to code in this module have been
+contacted for permission to grant license to the Apache Foundation.
\ No newline at end of file

Propchange: sling/whiteboard/ieb/cache/ehcache/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/ieb/cache/ehcache/README.txt
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/whiteboard/ieb/cache/ehcache/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/pom.xml?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/pom.xml (added)
+++ sling/whiteboard/ieb/cache/ehcache/pom.xml Mon Oct 29 04:47:47 2012
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>13</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.commons.cache.ehcache</artifactId>
+    <version>0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache Sling Cache API</name>
+    <description>
+        This bundle provides an implementation of the Cache API using ehcache.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/whiteboard/ieb/cache/ehcache</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/whiteboard/ieb/cache/ehcache</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache</url>
+    </scm>
+    
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.3.6</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+		            <Import-Package>
+		               !sun.misc,
+		               !org.jgroups.*,
+		               !org.hibernate.cache,
+		               !edu.emory.mathcs.backport.java.util.*,
+		               *
+		            </Import-Package>
+		            <Private-Package>org.apache.sling.commons.cache.ehcache.*</Private-Package>
+		            <DynamicImport-Package>sun.misc.*</DynamicImport-Package>
+		            <Embed-Transitive>true</Embed-Transitive>
+		            <Embed-Dependency>ehcache,jsr107cache</Embed-Dependency>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+	       	<groupId>org.apache.sling</groupId>
+	       	<artifactId>org.apache.sling.commons.cache.api</artifactId>
+	       	<version>0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+        	<groupId>commons-io</groupId>
+        	<artifactId>commons-io</artifactId>
+        	<version>1.4</version>
+        	<scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.ehcache</groupId>
+      		<artifactId>ehcache</artifactId>
+      		<version>1.5.0</version>
+    	</dependency>
+	    <dependency>
+            <groupId>net.sf.jsr107cache</groupId>
+            <artifactId>jsr107cache</artifactId>
+            <version>1.0</version>
+	    </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+        	<groupId>org.slf4j</groupId>
+        	<artifactId>slf4j-simple</artifactId>
+       		<scope>test</scope>
+        </dependency>
+         <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.8.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+        
+    </dependencies>
+</project>

Propchange: sling/whiteboard/ieb/cache/ehcache/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/ieb/cache/ehcache/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheImpl.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheImpl.java (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheImpl.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,187 @@
+/*
+ * 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.sling.commons.cache.ehcache;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Element;
+
+import org.apache.sling.commons.cache.api.Cache;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class CacheImpl<V> implements Cache<V> {
+
+	private static final Logger LOGGER = LoggerFactory
+			.getLogger(CacheImpl.class);
+	private String cacheName;
+	private net.sf.ehcache.Cache cache;
+	private long miss;
+	private long hits;
+	private long gets;
+
+	/**
+	 * @param cacheManager
+	 * @param name
+	 */
+	public CacheImpl(CacheManager cacheManager, String name) {
+		if (name == null) {
+			cacheName = "default";
+		} else {
+			cacheName = name;
+		}
+		synchronized (cacheManager) {
+			cache = cacheManager.getCache(cacheName);
+			if (cache == null) {
+				cacheManager.addCache(cacheName);
+				cache = cacheManager.getCache(cacheName);
+				if (cache == null) {
+					throw new RuntimeException(
+							"Failed to create Cache with name " + cacheName);
+				}
+			}
+		}
+	}
+
+	/**
+	 * {@inherit-doc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#clear()
+	 */
+	public void clear() {
+		cache.removeAll();
+	}
+
+	/**
+	 * {@inherit-doc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#containsKey(java.lang.String)
+	 */
+	public boolean containsKey(String key) {
+		return cache.isKeyInCache(key);
+	}
+
+	/**
+	 * {@inherit-doc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#get(java.lang.String)
+	 */
+	public V get(String key) {
+		Element e = cache.get(key);
+		if (e == null) {
+			return stats(null);
+		}
+		return stats(e.getObjectValue());
+	}
+
+	/**
+	 * Records stats
+	 * 
+	 * @param objectValue
+	 * @return the Object Value
+	 */
+	@SuppressWarnings("unchecked")
+	private V stats(Object objectValue) {
+		if (objectValue == null) {
+			miss++;
+		} else {
+			hits++;
+		}
+		gets++;
+		if (gets % 1000 == 0) {
+			long hp = (100 * hits) / gets;
+			long mp = (100 * miss) / gets;
+			LOGGER.info(
+					"{} Cache Stats hits {} ({}%), misses {} ({}%), calls {}",
+					new Object[] { cacheName, hits, hp, miss, mp, gets });
+		}
+		return (V) objectValue;
+	}
+
+	/**
+	 * {@inherit-doc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#put(java.lang.String,
+	 *      java.lang.Object)
+	 */
+	@SuppressWarnings("unchecked")
+	public V put(String key, V payload) {
+		V previous = null;
+		if (cache.isKeyInCache(key)) {
+			Element e = cache.get(key);
+			if (e != null) {
+				previous = (V) e.getObjectValue();
+			}
+		}
+		cache.put(new Element(key, payload));
+		return previous;
+	}
+
+	/**
+	 * {@inherit-doc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#remove(java.lang.String)
+	 */
+	public void remove(String key) {
+		cache.remove(key);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#removeChildren(java.lang.String)
+	 */
+	public void removeChildren(String key) {
+		cache.remove(key);
+		if (!key.endsWith("/")) {
+			key = key + "/";
+		}
+		List<?> keys = cache.getKeys();
+		for (Object k : keys) {
+			if (((String) k).startsWith(key)) {
+				cache.remove(k);
+			}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#list()
+	 */
+	@SuppressWarnings("unchecked")
+	public List<V> list() {
+		List<String> keys = cache.getKeys();
+		List<V> values = new ArrayList<V>();
+		for (String k : keys) {
+			Element e = cache.get(k);
+			if (e != null) {
+				values.add((V) e.getObjectValue());
+			}
+		}
+		return values;
+	}
+
+}

Propchange: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheManagerServiceImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheManagerServiceImpl.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheManagerServiceImpl.java (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheManagerServiceImpl.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,315 @@
+/*
+ * 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.sling.commons.cache.ehcache;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.management.ManagementFactory;
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.management.ManagementService;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.commons.cache.api.Cache;
+import org.apache.sling.commons.cache.api.CacheManagerService;
+import org.apache.sling.commons.cache.api.CacheScope;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The <code>CacheManagerServiceImpl</code>
+ */
+@Component(immediate = true, metatype = true)
+@Service(value = CacheManagerService.class)
+public class CacheManagerServiceImpl implements CacheManagerService {
+
+	public static final String DEFAULT_CACHE_CONFIG = "sling/ehcacheConfig.xml";
+
+	@Property(value = DEFAULT_CACHE_CONFIG)
+	public static final String CACHE_CONFIG = "cache-config";
+
+	@Property(value = "The Apache Software Foundation")
+	static final String SERVICE_VENDOR = "service.vendor";
+
+	@Property(value = "Cache Manager Service Implementation")
+	static final String SERVICE_DESCRIPTION = "service.description";
+
+	@Property()
+	public static final String BIND_ADDRESS = "bind-address";
+
+	@Property(value = "sling/ehcache/data")
+	public static final String CACHE_STORE = "cache-store";
+
+	private static final String CONFIG_PATH = "org/apache/sling/commons/cache/ehcache/ehcacheConfig.xml";
+
+	private static final Logger LOGGER = LoggerFactory
+			.getLogger(CacheManagerServiceImpl.class);
+	private CacheManager cacheManager;
+	private Map<String, Cache<?>> caches = new HashMap<String, Cache<?>>();
+	private ThreadLocalCacheMap requestCacheMapHolder = new ThreadLocalCacheMap();
+	private ThreadLocalCacheMap threadCacheMapHolder = new ThreadLocalCacheMap();
+
+	public CacheManagerServiceImpl() throws IOException {
+	}
+
+	@Activate
+	public void activate(Map<String, Object> properties)
+			throws FileNotFoundException, IOException {
+		String config = toString(properties.get(CACHE_CONFIG),
+				DEFAULT_CACHE_CONFIG);
+		File configFile = new File(config);
+		if (configFile.exists()) {
+			LOGGER.info("Configuring Cache from {} ",
+					configFile.getAbsolutePath());
+			InputStream in = null;
+			try {
+				in = processConfig(new FileInputStream(configFile), properties);
+				cacheManager = new CacheManager(in);
+			} finally {
+				if (in != null) {
+					in.close();
+				}
+			}
+		} else {
+			LOGGER.info("Configuring Cache from Classpath Default {} ",
+					CONFIG_PATH);
+			InputStream in = processConfig(this.getClass().getClassLoader()
+					.getResourceAsStream(CONFIG_PATH), properties);
+			if (in == null) {
+				throw new IOException(
+						"Unable to open config at classpath location "
+								+ CONFIG_PATH);
+			}
+			cacheManager = new CacheManager(in);
+			in.close();
+		}
+
+		final WeakReference<CacheManagerServiceImpl> ref = new WeakReference<CacheManagerServiceImpl>(
+				this);
+		/*
+		 * Add in a shutdown hook, for safety
+		 */
+		Runtime.getRuntime().addShutdownHook(new Thread() {
+			/*
+			 * (non-Javadoc)
+			 * 
+			 * @see java.lang.Thread#run()
+			 */
+			@Override
+			public void run() {
+				try {
+					CacheManagerServiceImpl cm = ref.get();
+					if (cm != null) {
+						cm.deactivate();
+					}
+				} catch (Throwable t) {
+					LOGGER.debug(t.getMessage(), t);
+				}
+			}
+		});
+
+		// register the cache manager with JMX
+		MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
+		ManagementService.registerMBeans(cacheManager, mBeanServer, true, true,
+				true, true);
+
+	}
+
+	private String toString(Object object, String defaultValue) {
+		if (object == null) {
+			return defaultValue;
+		}
+		return String.valueOf(object);
+	}
+
+	private InputStream processConfig(InputStream in,
+			Map<String, Object> properties) throws IOException {
+		if (in == null) {
+			return null;
+		}
+		StringBuilder config = new StringBuilder(IOUtils.toString(in, "UTF-8"));
+		in.close();
+		int pos = 0;
+		for (;;) {
+			int start = config.indexOf("${", pos);
+			if (start < 0) {
+				break;
+			}
+			int end = config.indexOf("}", start);
+			if (end < 0) {
+				throw new IllegalArgumentException(
+						"Config file malformed, unterminated variable "
+								+ config.substring(start,
+										Math.min(start + 10, config.length())));
+			}
+			String key = config.substring(start + 2, end);
+			if (properties.containsKey(key)) {
+				String replacement = (String) properties.get(key);
+				config.replace(start, end + 1, replacement);
+				pos = start + replacement.length();
+			} else {
+				throw new IllegalArgumentException(
+						"Missing replacement property " + key);
+			}
+		}
+		return new ByteArrayInputStream(config.toString().getBytes("UTF-8"));
+
+	}
+
+	/**
+	 * perform a shutdown
+	 */
+	@Deactivate
+	public void deactivate() {
+		if (cacheManager != null) {
+			cacheManager.shutdown();
+			cacheManager = null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.CacheManagerService#getCache(java.lang.String)
+	 */
+	public <V> Cache<V> getCache(String name, CacheScope scope) {
+		switch (scope) {
+		case INSTANCE:
+			return getInstanceCache(name);
+		case CLUSTERINVALIDATED:
+			return getInstanceCache(name);
+		case CLUSTERREPLICATED:
+			return getInstanceCache(name);
+		case REQUEST:
+			return getRequestCache(name);
+		case THREAD:
+			return getThreadCache(name);
+		default:
+			return getInstanceCache(name);
+		}
+	}
+
+	/**
+	 * Generate a cache bound to the thread.
+	 * 
+	 * @param name
+	 * @return
+	 */
+	@SuppressWarnings("unchecked")
+	private <V> Cache<V> getThreadCache(String name) {
+		Map<String, Cache<?>> threadCacheMap = threadCacheMapHolder.get();
+		Cache<V> threadCache = (Cache<V>) threadCacheMap.get(name);
+		if (threadCache == null) {
+			threadCache = new MapCacheImpl<V>();
+			threadCacheMap.put(name, threadCache);
+		}
+		return threadCache;
+	}
+
+	/**
+	 * Generate a cache bound to the request
+	 * 
+	 * @param name
+	 * @return
+	 */
+	@SuppressWarnings("unchecked")
+	private <V> Cache<V> getRequestCache(String name) {
+		Map<String, Cache<?>> requestCacheMap = requestCacheMapHolder.get();
+		Cache<V> requestCache = (Cache<V>) requestCacheMap.get(name);
+		if (requestCache == null) {
+			requestCache = new MapCacheImpl<V>();
+			requestCacheMap.put(name, requestCache);
+		}
+		return requestCache;
+	}
+
+	/**
+	 * @param name
+	 * @return
+	 */
+	@SuppressWarnings("unchecked")
+	private <V> Cache<V> getInstanceCache(String name) {
+		if (name == null) {
+			return new CacheImpl<V>(cacheManager, null);
+		} else {
+			Cache<V> c = (Cache<V>) caches.get(name);
+			if (c == null) {
+				c = new CacheImpl<V>(cacheManager, name);
+				caches.put(name, c);
+			}
+			return c;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.CacheManagerService#unbind(org.apache.sling.commons.cache.api.CacheScope)
+	 */
+	public void unbind(CacheScope scope) {
+		switch (scope) {
+		case REQUEST:
+			unbindRequest();
+			break;
+		case THREAD:
+			unbindThread();
+			break;
+		default:
+			break;
+		}
+	}
+
+	/**
+   *
+   */
+	private void unbindThread() {
+		Map<String, Cache<?>> threadCache = threadCacheMapHolder.get();
+		for (Cache<?> cache : threadCache.values()) {
+			cache.clear();
+		}
+		threadCacheMapHolder.remove();
+	}
+
+	/**
+   *
+   */
+	private void unbindRequest() {
+		Map<String, Cache<?>> requestCache = requestCacheMapHolder.get();
+		for (Cache<?> cache : requestCache.values()) {
+			cache.clear();
+		}
+		requestCacheMapHolder.remove();
+	}
+
+}

Propchange: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/CacheManagerServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapCacheImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapCacheImpl.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapCacheImpl.java (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapCacheImpl.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,113 @@
+/*
+ * 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.sling.commons.cache.ehcache;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.sling.commons.cache.api.Cache;
+import org.apache.sling.commons.cache.api.ThreadBound;
+
+/**
+ *
+ */
+public class MapCacheImpl<V> extends HashMap<String, V> implements Cache<V> {
+
+	/**
+   *
+   */
+	private static final long serialVersionUID = -5400056532743570231L;
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#containsKey(java.lang.String)
+	 */
+	public boolean containsKey(String key) {
+		return super.containsKey(key);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#get(java.lang.String)
+	 */
+	public V get(String key) {
+		return super.get(key);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#remove(java.lang.String)
+	 */
+	public void remove(String key) {
+		V o = super.remove(key);
+		if (o instanceof ThreadBound) {
+			((ThreadBound) o).unbind();
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see java.util.HashMap#clear()
+	 */
+	@Override
+	public void clear() {
+		for (String k : super.keySet()) {
+			Object o = get(k);
+			if (o instanceof ThreadBound) {
+				((ThreadBound) o).unbind();
+			}
+		}
+		super.clear();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#removeChildren(java.lang.String)
+	 */
+	public void removeChildren(String key) {
+		super.remove(key);
+		if (!key.endsWith("/")) {
+			key = key + "/";
+		}
+		Set<String> keys = super.keySet();
+		for (String k : keys) {
+			if ((k).startsWith(key)) {
+				super.remove(k);
+			}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.apache.sling.commons.cache.api.Cache#list()
+	 */
+	public List<V> list() {
+		return new ArrayList<V>(super.values());
+	}
+
+}

Propchange: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapCacheImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapDeligate.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapDeligate.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapDeligate.java (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapDeligate.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,87 @@
+/*
+ * 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.sling.commons.cache.ehcache;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.sling.commons.cache.api.Cache;
+
+public class MapDeligate<K, V> implements Map<K, V> {
+
+	private Cache<V> cache;
+
+	public MapDeligate(Cache<V> cache) {
+		this.cache = cache;
+	}
+
+	public void clear() {
+		cache.clear();
+	}
+
+	public boolean containsKey(Object key) {
+		return cache.containsKey((java.lang.String) key);
+	}
+
+	public boolean containsValue(Object value) {
+		throw new UnsupportedOperationException("This map is lookup only.");
+	}
+
+	public Set<Entry<K, V>> entrySet() {
+		throw new UnsupportedOperationException("This map is lookup only.");
+	}
+
+	public V get(Object key) {
+		return cache.get((String) key);
+	}
+
+	public boolean isEmpty() {
+		return false;
+	}
+
+	public Set<K> keySet() {
+		throw new UnsupportedOperationException("This map is lookup only.");
+	}
+
+	public V put(K key, V value) {
+		return cache.put((String) key, value);
+	}
+
+	public void putAll(Map<? extends K, ? extends V> m) {
+		throw new UnsupportedOperationException(
+				"This map is singly add only, use an iterator or loop.");
+	}
+
+	public int size() {
+		throw new UnsupportedOperationException("This map is lookup only.");
+	}
+
+	public V remove(Object key) {
+		V value = cache.get((String) key);
+		cache.remove((String) key);
+		return value;
+	}
+
+	public Collection<V> values() {
+		throw new UnsupportedOperationException("This map is lookup only.");
+	}
+
+}

Propchange: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/MapDeligate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/ThreadLocalCacheMap.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/ThreadLocalCacheMap.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/ThreadLocalCacheMap.java (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/ThreadLocalCacheMap.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,43 @@
+/*
+ * 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.sling.commons.cache.ehcache;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.commons.cache.api.Cache;
+
+/**
+ * Represents a Cache stored on the thread, used in the request thread and in
+ * other threads. When used in Threads there is a potential for memory leaks as
+ * perm space is not cleaned up. This will be caused by references to
+ * classloaders being in the Map, and keeping the classloaders open.
+ */
+public class ThreadLocalCacheMap extends ThreadLocal<Map<String, Cache<?>>> {
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see java.lang.ThreadLocal#initialValue()
+	 */
+	@Override
+	protected Map<String, Cache<?>> initialValue() {
+		return new HashMap<String, Cache<?>>();
+	}
+}

Propchange: sling/whiteboard/ieb/cache/ehcache/src/main/java/org/apache/sling/commons/cache/ehcache/ThreadLocalCacheMap.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/cache/ehcache/ehcacheConfig.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/cache/ehcache/ehcacheConfig.xml?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/cache/ehcache/ehcacheConfig.xml (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/cache/ehcache/ehcacheConfig.xml Mon Oct 29 04:47:47 2012
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+/*
+ * 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.
+ */
+ -->
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="ehcache.xsd">
+  <!--
+    Mandatory Default Cache configuration. These settings will be applied to caches created
+    programmtically using CacheManager.add(String cacheName). The defaultCache has an implicit name
+    "default" which is a reserved cache name.
+  -->
+  <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="600"
+    timeToLiveSeconds="600" overflowToDisk="false" diskPersistent="false" memoryStoreEvictionPolicy="LRU" />
+</ehcache>
\ No newline at end of file

Propchange: sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/cache/ehcache/ehcacheConfig.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/ieb/cache/ehcache/src/main/resources/org/apache/sling/commons/cache/ehcache/ehcacheConfig.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheConfigTest.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheConfigTest.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheConfigTest.java (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheConfigTest.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,127 @@
+/*
+ * 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.sling.commons.cache.ehcache;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.sling.commons.cache.api.Cache;
+import org.apache.sling.commons.cache.api.CacheScope;
+import org.apache.sling.commons.cache.api.ThreadBound;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class CacheConfigTest {
+
+	private CacheManagerServiceImpl cacheManagerService;
+
+	@Before
+	public void setUp() throws IOException, InstantiationException,
+			IllegalAccessException, ClassNotFoundException {
+		cacheManagerService = new CacheManagerServiceImpl();
+		Map<String, Object> properties = MapBuilder.getMap(CacheManagerServiceImpl.CACHE_STORE,
+				(Object) "target/ehcache/store", 
+				CacheManagerServiceImpl.BIND_ADDRESS, "127.0.0.1",
+				CacheManagerServiceImpl.CACHE_CONFIG, "src/test/resources/testconfig/simple-ehcacheConfig.xml"
+				);
+		cacheManagerService.activate(properties);
+	}
+
+
+	@After
+	public void tearDown() {
+		cacheManagerService.deactivate();
+	}
+
+	private void exerciseCache(String cacheName, CacheScope scope) {
+		Cache<String> cache = cacheManagerService.getCache(cacheName, scope);
+		cache.put("fish", "cat");
+		assertTrue("Expected element to be in cache", cache.containsKey("fish"));
+		Cache<String> sameCache = cacheManagerService
+				.getCache(cacheName, scope);
+		assertEquals("Expected cache to work", "cat", sameCache.get("fish"));
+		sameCache.put("fish", "differentcat");
+		assertEquals("Expected cache value to propogate", "differentcat",
+				cache.get("fish"));
+		sameCache.remove("fish");
+		sameCache.remove("another");
+		assertNull("Expected item to be removed from cache", cache.get("fish"));
+		cache.put("foo", "bar");
+		cache.clear();
+		assertNull("Expected cache to be empty", cache.get("foo"));
+		cacheManagerService.unbind(scope);
+	}
+
+	@Test
+	public void testCacheStorage() {
+		for (CacheScope scope : CacheScope.values()) {
+			exerciseCache("TestCache", scope);
+		}
+	}
+
+	@Test
+	public void testNullCacheNames() {
+		for (CacheScope scope : CacheScope.values()) {
+			exerciseCache(null, scope);
+		}
+	}
+
+	@Test
+	public void testCacheWithChildKeys() {
+		for (CacheScope scope : CacheScope.values()) {
+			String cacheName = "SomeTestCache";
+			Cache<String> cache = cacheManagerService
+					.getCache(cacheName, scope);
+			cache.put("fish", "cat");
+			assertTrue("Expected element to be in cache",
+					cache.containsKey("fish"));
+			cache.put("fish/child", "childcat");
+			cache.put("fish/child/child", "childcatchild");
+			Cache<String> sameCache = cacheManagerService.getCache(cacheName,
+					scope);
+			sameCache.removeChildren("fish/child/child");
+			assertNull("Expected key to be removed",
+					cache.get("fish/child/child"));
+			sameCache.removeChildren("fish");
+			assertNull("Expected key to be removed", cache.get("fish"));
+			assertNull("Expected key to be removed", cache.get("fish/child"));
+		}
+	}
+
+	@Test
+	public void testThreadUnbinding() {
+		ThreadBound testItem = Mockito.mock(ThreadBound.class);
+		Cache<ThreadBound> threadBoundCache = cacheManagerService.getCache(
+				"testCache", CacheScope.THREAD);
+		threadBoundCache.put("testItem", testItem);
+		threadBoundCache.remove("testItem");
+		threadBoundCache.put("testItem", testItem);
+		threadBoundCache.clear();
+		
+		Mockito.verify(testItem, Mockito.times(2)).unbind();
+	}
+
+}

Propchange: sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/CacheConfigTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/MapBuilder.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/MapBuilder.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/MapBuilder.java (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/MapBuilder.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,40 @@
+/*
+ * 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.sling.commons.cache.ehcache;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A very simple class that avoids needing Guava as a dependency (aka Google Collections)
+ *
+ */
+public class MapBuilder {
+
+	@SuppressWarnings("unchecked")
+	public static <K, V> Map<K, V> getMap(Object ... kv) {
+		Map<K,V> m = new HashMap<K, V>();
+		for ( int i = 0; i < kv.length; i+=2 ) {
+			m.put((K)kv[i], (V)kv[i+1]);
+		}
+		return m;
+	}
+
+}

Propchange: sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/MapBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/TestCache.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/TestCache.java?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/TestCache.java (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/TestCache.java Mon Oct 29 04:47:47 2012
@@ -0,0 +1,117 @@
+/*
+ * 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.sling.commons.cache.ehcache;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.sling.commons.cache.api.Cache;
+import org.apache.sling.commons.cache.api.CacheScope;
+import org.apache.sling.commons.cache.api.ThreadBound;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class TestCache {
+
+  private CacheManagerServiceImpl cacheManagerService;
+
+  @Before
+  public void setUp() throws IOException, InstantiationException, IllegalAccessException,
+      ClassNotFoundException {
+    cacheManagerService = new CacheManagerServiceImpl();
+    Map<String, Object> properties = MapBuilder.getMap("cache-store",(Object)"target/ehcache/store", "bind-address", "127.0.0.1");
+	cacheManagerService.activate(properties);
+  }
+  
+  @After
+  public void tearDown() {
+	  cacheManagerService.deactivate();
+  }
+
+  private void exerciseCache(String cacheName, CacheScope scope) {
+    Cache<String> cache = cacheManagerService.getCache(cacheName, scope);
+    cache.put("fish", "cat");
+    assertTrue("Expected element to be in cache", cache.containsKey("fish"));
+    Cache<String> sameCache = cacheManagerService.getCache(cacheName, scope);
+    assertEquals("Expected cache to work", "cat", sameCache.get("fish"));
+    sameCache.put("fish", "differentcat");
+    assertEquals("Expected cache value to propogate", "differentcat", cache.get("fish"));
+    sameCache.remove("fish");
+    sameCache.remove("another");
+    assertNull("Expected item to be removed from cache", cache.get("fish"));
+    cache.put("foo", "bar");
+    cache.clear();
+    assertNull("Expected cache to be empty", cache.get("foo"));
+    cacheManagerService.unbind(scope);
+  }
+
+  @Test
+  public void testCacheStorage() {
+    for (CacheScope scope : CacheScope.values()) {
+      exerciseCache("TestCache", scope);
+    }
+  }
+
+  @Test
+  public void testNullCacheNames() {
+    for (CacheScope scope : CacheScope.values()) {
+      exerciseCache(null, scope);
+    }
+  }
+
+  @Test
+  public void testCacheWithChildKeys() {
+    for (CacheScope scope : CacheScope.values()) {
+      String cacheName = "SomeTestCache";
+      Cache<String> cache = cacheManagerService.getCache(cacheName, scope);
+      cache.put("fish", "cat");
+      assertTrue("Expected element to be in cache", cache.containsKey("fish"));
+      cache.put("fish/child", "childcat");
+      cache.put("fish/child/child", "childcatchild");
+      Cache<String> sameCache = cacheManagerService.getCache(cacheName, scope);
+      sameCache.removeChildren("fish/child/child");
+      assertNull("Expected key to be removed", cache.get("fish/child/child"));
+      sameCache.removeChildren("fish");
+      assertNull("Expected key to be removed", cache.get("fish"));
+      assertNull("Expected key to be removed", cache.get("fish/child"));
+    }
+  }
+
+  @Test
+  public void testThreadUnbinding() {
+    ThreadBound testItem = Mockito.mock(ThreadBound.class);
+    Cache<ThreadBound> threadBoundCache = cacheManagerService.getCache("testCache",
+        CacheScope.THREAD);
+    threadBoundCache.put("testItem", testItem);
+    threadBoundCache.remove("testItem");
+    threadBoundCache.put("testItem", testItem);
+    threadBoundCache.clear();
+    
+    Mockito.verify(testItem, Mockito.times(2)).unbind();
+  }
+
+}

Propchange: sling/whiteboard/ieb/cache/ehcache/src/test/java/org/apache/sling/commons/cache/ehcache/TestCache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/cluster-ehcacheConfig.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/cluster-ehcacheConfig.xml?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/cluster-ehcacheConfig.xml (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/cluster-ehcacheConfig.xml Mon Oct 29 04:47:47 2012
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+/*
+ * 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.
+ */
+ -->
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:noNamespaceSchemaLocation="ehcache.xsd">
+
+
+    <diskStore path="${cache-store}"/>
+
+	<!-- the group address and muticast port may need changing, I am assuming 
+		all the cluster hosts are on the same subnet and no forwarding is required. 
+		The group address and port have been changed from the default just incase 
+		there are any other ehcache instances on the same subnet. The hostName must 
+		be customsed -->
+	<cacheManagerPeerProviderFactory
+		class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
+		properties="hostName=${bind-address},
+                        peerDiscovery=automatic,
+                        multicastGroupAddress=230.0.0.2,
+                        multicastGroupPort=4450, timeToLive=1"
+		propertySeparator="," />
+
+	<cacheManagerPeerListenerFactory
+		class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
+		properties="hostName=${bind-address},
+                    port=40001,
+                    remoteObjectPort=40002,
+                    socketTimeoutMillis=120000"
+		propertySeparator="," />
+	<!-- Mandatory Default Cache configuration. These settings will be applied 
+		to caches created programmtically using CacheManager.add(String cacheName). 
+		The defaultCache has an implicit name "default" which is a reserved cache 
+		name. -->
+	<defaultCache maxElementsInMemory="10000" eternal="false"
+		timeToIdleSeconds="600" timeToLiveSeconds="600" overflowToDisk="false"
+		diskPersistent="false" memoryStoreEvictionPolicy="LRU" />
+
+    <!--  cluster invalidated -->
+	<cache name="cacheA" maxElementsInMemory="100000"
+		eternal="false" overflowToDisk="false"
+		timeToIdleSeconds="300" timeToLiveSeconds="600"
+		memoryStoreEvictionPolicy="LFU"  >
+		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
+         properties="replicateAsynchronously=true,
+         replicatePuts=false,
+         replicatePutsViaCopy=false,
+         replicateUpdates=false,
+         replicateUpdatesViaCopy=true,
+         replicateRemovals=true,
+         asynchronousReplicationIntervalMillis=500"
+         propertySeparator="," />
+	</cache>
+
+    <!--  small objects, cluster invalidated -->
+	<cache name="cacheB" maxElementsInMemory="100000"
+		eternal="false" overflowToDisk="false"
+		timeToIdleSeconds="300" timeToLiveSeconds="600"
+		memoryStoreEvictionPolicy="LFU"  >
+		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
+         properties="replicateAsynchronously=true,
+         replicatePuts=false,
+         replicatePutsViaCopy=false,
+         replicateUpdates=false,
+         replicateUpdatesViaCopy=true,
+         replicateRemovals=true,
+         asynchronousReplicationIntervalMillis=500"
+         propertySeparator="," />
+	</cache>
+
+    <!--  larger objects, cluster invalidated -->
+	<cache name="cacheC" maxElementsInMemory="50000"
+		eternal="false" overflowToDisk="false"
+		timeToIdleSeconds="300" timeToLiveSeconds="600"
+		memoryStoreEvictionPolicy="LFU"  >
+		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
+         properties="replicateAsynchronously=true,
+         replicatePuts=false,
+         replicatePutsViaCopy=false,
+         replicateUpdates=false,
+         replicateUpdatesViaCopy=false,
+         replicateRemovals=true,
+         asynchronousReplicationIntervalMillis=500"
+         propertySeparator="," />
+	</cache>
+
+    <!--  replicated. -->
+	<cache name="cacheD" maxElementsInMemory="10000"
+		eternal="false" overflowToDisk="false"
+		timeToIdleSeconds="300" timeToLiveSeconds="600"
+		memoryStoreEvictionPolicy="LFU"  >
+		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
+         properties="replicateAsynchronously=true,
+         replicatePuts=true,
+         replicatePutsViaCopy=true,
+         replicateUpdates=true,
+         replicateUpdatesViaCopy=true,
+         replicateRemovals=true,
+         asynchronousReplicationIntervalMillis=500"
+         propertySeparator="," />
+        <bootstrapCacheLoaderFactory
+          class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
+          properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"
+          propertySeparator="," />
+	</cache>
+
+	<cache name="cacheE" maxElementsInMemory="10000"
+		eternal="false" overflowToDisk="false"
+		timeToIdleSeconds="300" timeToLiveSeconds="600"
+		memoryStoreEvictionPolicy="LFU"  >
+		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
+         properties="replicateAsynchronously=true,
+         replicatePuts=true,
+         replicatePutsViaCopy=true,
+         replicateUpdates=true,
+         replicateUpdatesViaCopy=true,
+         replicateRemovals=true,
+         asynchronousReplicationIntervalMillis=500"
+         propertySeparator="," />
+        <bootstrapCacheLoaderFactory
+          class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
+          properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"
+          propertySeparator="," />
+	</cache>
+
+    <!--  the Token store must be saved to disk localy, normally will only need 5x number of servers.
+    Fully replicated, synchronously -->
+	<cache name="TokenStore"
+		maxElementsInMemory="10000" maxElementsOnDisk="100000" eternal="true"
+		overflowToDisk="true" diskSpoolBufferSizeMB="20" memoryStoreEvictionPolicy="LFU"
+		diskPersistent="true"  >
+		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
+         properties="replicateAsynchronously=false,
+         replicatePuts=true,
+         replicatePutsViaCopy=true,
+         replicateUpdates=true,
+         replicateUpdatesViaCopy=true,
+         replicateRemovals=true"
+         propertySeparator="," />
+        <bootstrapCacheLoaderFactory
+          class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
+          properties="bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000"
+          propertySeparator="," />
+         
+	</cache>
+
+
+</ehcache>
\ No newline at end of file

Propchange: sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/cluster-ehcacheConfig.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/cluster-ehcacheConfig.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/simple-ehcacheConfig.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/simple-ehcacheConfig.xml?rev=1403171&view=auto
==============================================================================
--- sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/simple-ehcacheConfig.xml (added)
+++ sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/simple-ehcacheConfig.xml Mon Oct 29 04:47:47 2012
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+/*
+ * 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.
+ */
+ -->
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="ehcache.xsd">
+  <!--
+    Mandatory Default Cache configuration. These settings will be applied to caches created
+    programmtically using CacheManager.add(String cacheName). The defaultCache has an implicit name
+    "default" which is a reserved cache name.
+  -->
+  <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="600"
+    timeToLiveSeconds="600" overflowToDisk="false" diskPersistent="false" memoryStoreEvictionPolicy="LRU" />
+</ehcache>
\ No newline at end of file

Propchange: sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/simple-ehcacheConfig.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/whiteboard/ieb/cache/ehcache/src/test/resources/testconfig/simple-ehcacheConfig.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml