You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:23:30 UTC
[sling-org-apache-sling-commons-cache-impl] branch master created
(now 1fc4ae0)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-cache-impl.git.
at 1fc4ae0 SLING-7167 Adjust READMEs
This branch includes the following new commits:
new 014d71c SLING-2555 moving into the right place this time, sorry.
new f4190f1 SLING-2555 Adjusted the svn paths to fit the new location.
new b782065 Use latest releases and update to new parent pom
new b6284f5 Update to latest parent pom and use latest releases in launchpad
new e71d186 Correct reactor pom and update to parent pom 16
new 7aa6a1b SLING-4698 - Set parent.relativePath to empty for all modules
new 8469a0f SLING-7167 Adjust READMEs
new 1fc4ae0 SLING-7167 Adjust READMEs
The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
--
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].
[sling-org-apache-sling-commons-cache-impl] 04/08: Update to latest
parent pom and use latest releases in launchpad
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-cache-impl.git
commit b6284f5e3b2a62c34fae5416b390deabb0f4927e
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 18 08:38:52 2013 +0000
Update to latest parent pom and use latest releases in launchpad
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1447147 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 3a9e1fb..d96f5db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>14</version>
+ <version>15</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-cache-impl] 02/08: SLING-2555
Adjusted the svn paths to fit the new location.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-cache-impl.git
commit f4190f1663cb69ffbb68c909820dd2581b2bc73f
Author: Ian Boston <ie...@apache.org>
AuthorDate: Fri Nov 9 05:29:25 2012 +0000
SLING-2555 Adjusted the svn paths to fit the new location.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1407365 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 5acbc20..ab965fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,9 +37,9 @@
</description>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/sling/whiteboard/ieb/cache/impl</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/whiteboard/ieb/cache/impl</developerConnection>
- <url>http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/impl</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/contrib/extensions/cache/impl</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/contrib/extensions/cache/impl</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/contrib/extensions/cache/impl</url>
</scm>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-cache-impl] 07/08: SLING-7167
Adjust READMEs
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-cache-impl.git
commit 8469a0fe4494a6abcf3ba638bca8db4c9e42b261
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Mon Oct 2 16:18:11 2017 +0000
SLING-7167 Adjust READMEs
switch from plain text to Markdown
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810506 13f79535-47bb-0310-9956-ffa450edef68
---
README.txt => README.md | 0
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/README.txt b/README.md
similarity index 100%
rename from README.txt
rename to README.md
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-cache-impl] 08/08: SLING-7167
Adjust READMEs
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-cache-impl.git
commit 1fc4ae082f69ed7c56dd216abb412c39d4ed8371
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Oct 3 10:03:19 2017 +0000
SLING-7167 Adjust READMEs
add uniform header linking to Sling project
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1810895 13f79535-47bb-0310-9956-ffa450edef68
---
README.md | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 4664850..82e6597 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
-Support Jar for implementations of CacheManagerService.
+# Apache Sling Cache API Implementation support library
+
+This module is part of the [Apache Sling](https://sling.apache.org) project.
This is support jar for implementing Cache services. It contains an abstract implementation of all the in
memory versions of cache that the cache service has to supply leaving instance, cluster invalidated and cluster
@@ -9,4 +11,4 @@ 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
+contacted for permission to grant license to the Apache Foundation.
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-cache-impl] 03/08: Use latest
releases and update to new parent pom
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-cache-impl.git
commit b78206528a268736ee77fcc5b61ae6800e3ce2ac
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Dec 23 06:53:35 2012 +0000
Use latest releases and update to new parent pom
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1425425 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index ab965fc..3a9e1fb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>13</version>
+ <version>14</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-cache-impl] 01/08: SLING-2555
moving into the right place this time, sorry.
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-cache-impl.git
commit 014d71c02ef7606f60c9ccb8bdf47b8bba1a39e7
Author: Ian Boston <ie...@apache.org>
AuthorDate: Fri Nov 9 05:22:15 2012 +0000
SLING-2555 moving into the right place this time, sorry.
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1407364 13f79535-47bb-0310-9956-ffa450edef68
---
README.txt | 12 ++
pom.xml | 69 ++++++++
.../cache/impl/AbstractCacheManagerService.java | 194 +++++++++++++++++++++
.../sling/commons/cache/impl/MapCacheImpl.java | 119 +++++++++++++
.../sling/commons/cache/impl/MapDeligate.java | 87 +++++++++
.../commons/cache/impl/ThreadLocalCacheMap.java | 43 +++++
6 files changed, 524 insertions(+)
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..4664850
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,12 @@
+Support Jar for implementations of CacheManagerService.
+
+This is support jar for implementing Cache services. It contains an abstract implementation of all the in
+memory versions of cache that the cache service has to supply leaving instance, cluster invalidated and cluster
+replicated caches upto the supporting cache library.
+
+
+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
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..5acbc20
--- /dev/null
+++ b/pom.xml
@@ -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>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.sling.commons.cache.impl</artifactId>
+ <version>0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Apache Sling Cache API Implementation support library</name>
+ <description>
+ This bundle provides an implementation support for Cache implementations. It is a utility jar that should be embedded.
+ </description>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/sling/whiteboard/ieb/cache/impl</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/whiteboard/ieb/cache/impl</developerConnection>
+ <url>http://svn.apache.org/viewvc/sling/whiteboard/ieb/cache/impl</url>
+ </scm>
+
+
+ <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>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/commons/cache/impl/AbstractCacheManagerService.java b/src/main/java/org/apache/sling/commons/cache/impl/AbstractCacheManagerService.java
new file mode 100644
index 0000000..c5542f1
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/cache/impl/AbstractCacheManagerService.java
@@ -0,0 +1,194 @@
+/*
+ * 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.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sling.commons.cache.api.Cache;
+import org.apache.sling.commons.cache.api.CacheManagerService;
+import org.apache.sling.commons.cache.api.CacheScope;
+
+/**
+ * The <code>AbstractCacheManagerService</code>
+ */
+public abstract class AbstractCacheManagerService implements CacheManagerService {
+
+
+ private ThreadLocalCacheMap requestCacheMapHolder = new ThreadLocalCacheMap();
+ private ThreadLocalCacheMap threadCacheMapHolder = new ThreadLocalCacheMap();
+
+ public AbstractCacheManagerService() throws IOException {
+ }
+
+
+
+ /**
+ * {@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")
+ protected <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")
+ protected <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
+ */
+ protected abstract <V> Cache<V> getInstanceCache(String name);
+
+ /**
+ * {@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();
+ }
+
+
+ protected String toString(Object object, String defaultValue) {
+ if (object == null) {
+ return defaultValue;
+ }
+ return String.valueOf(object);
+ }
+
+
+ protected 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"));
+
+ }
+
+
+}
diff --git a/src/main/java/org/apache/sling/commons/cache/impl/MapCacheImpl.java b/src/main/java/org/apache/sling/commons/cache/impl/MapCacheImpl.java
new file mode 100644
index 0000000..51f8c29
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/cache/impl/MapCacheImpl.java
@@ -0,0 +1,119 @@
+/*
+ * 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.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+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 boolean remove(String key) {
+ V o = super.remove(key);
+ if (o instanceof ThreadBound) {
+ ((ThreadBound) o).unbind();
+ }
+ return ( o != null );
+ }
+
+ /**
+ * {@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 Collection<V> values() {
+ return super.values();
+ }
+
+ public Collection<String> keys() {
+ return super.keySet();
+ }
+
+}
diff --git a/src/main/java/org/apache/sling/commons/cache/impl/MapDeligate.java b/src/main/java/org/apache/sling/commons/cache/impl/MapDeligate.java
new file mode 100644
index 0000000..a54b030
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/cache/impl/MapDeligate.java
@@ -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.impl;
+
+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.");
+ }
+
+}
diff --git a/src/main/java/org/apache/sling/commons/cache/impl/ThreadLocalCacheMap.java b/src/main/java/org/apache/sling/commons/cache/impl/ThreadLocalCacheMap.java
new file mode 100644
index 0000000..8d70c77
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/cache/impl/ThreadLocalCacheMap.java
@@ -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.impl;
+
+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<?>>();
+ }
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-cache-impl] 06/08: SLING-4698 - Set
parent.relativePath to empty for all modules
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-cache-impl.git
commit 7aa6a1b99199c668ef413ebb2433b5132588f71a
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu May 7 10:14:40 2015 +0000
SLING-4698 - Set parent.relativePath to empty for all modules
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1678154 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index aaf8ef3..d4fa3a7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
<version>16</version>
- <relativePath>../../../parent/pom.xml</relativePath>
+ <relativePath/>
</parent>
<artifactId>org.apache.sling.commons.cache.impl</artifactId>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.
[sling-org-apache-sling-commons-cache-impl] 05/08: Correct reactor
pom and update to parent pom 16
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-cache-impl.git
commit e71d186fdb15df03f5b73fe36aa9010dc241f397
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun May 5 14:38:24 2013 +0000
Correct reactor pom and update to parent pom 16
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1479333 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index d96f5db..aaf8ef3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>15</version>
+ <version>16</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.