You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ol...@apache.org on 2014/04/28 01:49:11 UTC
svn commit: r1590534 - in /commons/proper/jcs/trunk/src: conf/
java/org/apache/commons/jcs/jcache/ java/org/apache/commons/jcs/jcache/cdi/
resources/ resources/META-INF/services/
Author: olamy
Date: Sun Apr 27 23:49:10 2014
New Revision: 1590534
URL: http://svn.apache.org/r1590534
Log:
adding basic backbone for cdi, interceptors + metadata parsing need to be implemented
Added:
commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/
commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CachePutInterceptor.java (with props)
commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveAllInterceptor.java (with props)
commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveInterceptor.java (with props)
commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheResultInterceptor.java (with props)
commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/MakeJCacheCDIIntercetporFriendly.java (with props)
commons/proper/jcs/trunk/src/resources/META-INF/services/javax.enterprise.inject.spi.Extension
commons/proper/jcs/trunk/src/resources/jcache.ccf
Removed:
commons/proper/jcs/trunk/src/resources/cache.ccf
Modified:
commons/proper/jcs/trunk/src/conf/cache.ccf
commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingManager.java
commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingProvider.java
Modified: commons/proper/jcs/trunk/src/conf/cache.ccf
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/conf/cache.ccf?rev=1590534&r1=1590533&r2=1590534&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/conf/cache.ccf (original)
+++ commons/proper/jcs/trunk/src/conf/cache.ccf Sun Apr 27 23:49:10 2014
@@ -0,0 +1,69 @@
+# 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.
+# #############################################################
+# ################# DEFAULT CACHE REGION #####################
+# sets the default aux value for any non configured caches
+jcs.default=DC
+jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=200001
+jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.cacheattributes.UseMemoryShrinker=true
+jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.default.elementattributes.IsEternal=false
+jcs.default.elementattributes.MaxLifeSeconds=700
+jcs.default.elementattributes.IdleTime=1800
+jcs.default.elementattributes.IsSpool=true
+jcs.default.elementattributes.IsRemote=true
+jcs.default.elementattributes.IsLateral=true
+
+
+# #############################################################
+# ################# OPTIONAL THREAD POOL CONFIGURATION ###################
+# Default thread pool config
+thread_pool.default.boundarySize=2000
+thread_pool.default.maximumPoolSize=150
+thread_pool.default.minimumPoolSize=4
+thread_pool.default.keepAliveTime=350000
+# RUN ABORT WAIT BLOCK DISCARDOLDEST
+thread_pool.default.whenBlockedPolicy=RUN
+thread_pool.default.startUpSize=4
+
+# Default Cache Event Queue thread pool config, used by auxiliaries
+# since it doesn't use a boundary, some of the options are unnecessary
+thread_pool.cache_event_queue.useBoundary=false
+thread_pool.cache_event_queue.minimumPoolSize=5
+thread_pool.cache_event_queue.keepAliveTime=3500
+thread_pool.cache_event_queue.startUpSize=5
+
+# Disk Cache pool
+thread_pool.disk_cache_event_queue.useBoundary=false
+thread_pool.remote_cache_client.maximumPoolSize=15
+thread_pool.disk_cache_event_queue.minimumPoolSize=1
+thread_pool.disk_cache_event_queue.keepAliveTime=3500
+thread_pool.disk_cache_event_queue.startUpSize=1
+
+# Remote cache client thread pool config
+thread_pool.remote_cache_client.boundarySize=75
+thread_pool.remote_cache_client.maximumPoolSize=150
+thread_pool.remote_cache_client.minimumPoolSize=4
+thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.whenBlockedPolicy=RUN
+thread_pool.remote_cache_client.startUpSize=4
+
+
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingManager.java?rev=1590534&r1=1590533&r2=1590534&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingManager.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingManager.java Sun Apr 27 23:49:10 2014
@@ -1,6 +1,5 @@
package org.apache.commons.jcs.jcache;
-import org.apache.commons.jcs.access.exception.CacheException;
import org.apache.commons.jcs.engine.control.CompositeCacheManager;
import org.apache.commons.jcs.jcache.proxy.ClassLoaderAwareHandler;
@@ -34,35 +33,31 @@ public class JCSCachingManager implement
this.loader = loader;
this.properties = properties;
- if (uri == JCSCachingProvider.DEFAULT_URI && (properties == null || properties.isEmpty())) {
- try {
- instance = CompositeCacheManager.getInstance();
- } catch (final CacheException e) {
- throw new IllegalArgumentException(e);
+ instance = CompositeCacheManager.getUnconfiguredInstance();
+ final Properties props = new Properties();
+ InputStream inStream = null;
+ try {
+ if (JCSCachingProvider.DEFAULT_URI == uri || uri.toURL().getProtocol().equals("jcs")) {
+ inStream = loader.getResourceAsStream(uri.getPath());
+ } else {
+ inStream = uri.toURL().openStream();
}
- } else {
- instance = CompositeCacheManager.getUnconfiguredInstance();
- final Properties props = new Properties();
- if (uri != JCSCachingProvider.DEFAULT_URI) {
- InputStream inStream = null;
+ props.load(inStream);
+ } catch (final IOException e) {
+ throw new IllegalArgumentException(e);
+ } finally {
+ if (inStream != null) {
try {
- inStream = uri.toURL().openStream();
- props.load(inStream);
+ inStream.close();
} catch (final IOException e) {
- throw new IllegalArgumentException(e);
- } finally {
- if (inStream != null) {
- try {
- inStream.close();
- } catch (final IOException e) {
- // no-op
- }
- }
+ // no-op
}
}
+ }
+ if (properties != null) {
props.putAll(properties);
- instance.configure(props);
}
+ instance.configure(props);
}
private void assertNotClosed() {
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingProvider.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingProvider.java?rev=1590534&r1=1590533&r2=1590534&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingProvider.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/JCSCachingProvider.java Sun Apr 27 23:49:10 2014
@@ -10,7 +10,7 @@ import java.util.concurrent.ConcurrentHa
import java.util.concurrent.ConcurrentMap;
public class JCSCachingProvider implements CachingProvider {
- public static final URI DEFAULT_URI = URI.create("jcs://default");
+ public static final URI DEFAULT_URI = URI.create("jcs://jcache.ccf");
private final ConcurrentMap<ClassLoader, ConcurrentMap<URI, CacheManager>> cacheManagersByLoader =
new ConcurrentHashMap<ClassLoader, ConcurrentMap<URI, CacheManager>>();
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CachePutInterceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CachePutInterceptor.java?rev=1590534&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CachePutInterceptor.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CachePutInterceptor.java Sun Apr 27 23:49:10 2014
@@ -0,0 +1,15 @@
+package org.apache.commons.jcs.jcache.cdi;
+
+import javax.cache.annotation.CachePut;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@CachePut
+@Interceptor
+public class CachePutInterceptor {
+ @AroundInvoke
+ public Object cache(final InvocationContext ic) throws Exception {
+ throw new UnsupportedOperationException("TODO");
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CachePutInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CachePutInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveAllInterceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveAllInterceptor.java?rev=1590534&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveAllInterceptor.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveAllInterceptor.java Sun Apr 27 23:49:10 2014
@@ -0,0 +1,15 @@
+package org.apache.commons.jcs.jcache.cdi;
+
+import javax.cache.annotation.CacheRemoveAll;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@CacheRemoveAll
+@Interceptor
+public class CacheRemoveAllInterceptor {
+ @AroundInvoke
+ public Object cache(final InvocationContext ic) throws Exception {
+ throw new UnsupportedOperationException("TODO");
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveAllInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveAllInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveInterceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveInterceptor.java?rev=1590534&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveInterceptor.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveInterceptor.java Sun Apr 27 23:49:10 2014
@@ -0,0 +1,15 @@
+package org.apache.commons.jcs.jcache.cdi;
+
+import javax.cache.annotation.CacheRemove;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@CacheRemove
+@Interceptor
+public class CacheRemoveInterceptor {
+ @AroundInvoke
+ public Object cache(final InvocationContext ic) throws Exception {
+ throw new UnsupportedOperationException("TODO");
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheRemoveInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheResultInterceptor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheResultInterceptor.java?rev=1590534&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheResultInterceptor.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheResultInterceptor.java Sun Apr 27 23:49:10 2014
@@ -0,0 +1,15 @@
+package org.apache.commons.jcs.jcache.cdi;
+
+import javax.cache.annotation.CacheResult;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@CacheResult
+@Interceptor
+public class CacheResultInterceptor {
+ @AroundInvoke
+ public Object cache(final InvocationContext ic) throws Exception {
+ throw new UnsupportedOperationException("TODO");
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheResultInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/CacheResultInterceptor.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/MakeJCacheCDIIntercetporFriendly.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/MakeJCacheCDIIntercetporFriendly.java?rev=1590534&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/MakeJCacheCDIIntercetporFriendly.java (added)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/MakeJCacheCDIIntercetporFriendly.java Sun Apr 27 23:49:10 2014
@@ -0,0 +1,20 @@
+package org.apache.commons.jcs.jcache.cdi;
+
+import javax.cache.annotation.CachePut;
+import javax.cache.annotation.CacheRemove;
+import javax.cache.annotation.CacheRemoveAll;
+import javax.cache.annotation.CacheResult;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+// TODO: observe annotated type (or maybe sthg else) to cache data and inecjt this extension (used as metadata cache)
+// to get class model and this way allow to add cache annotation on the fly - == avoid java pure reflection to get metadata
+public class MakeJCacheCDIIntercetporFriendly implements Extension {
+ protected void discoverInterceptorBindings(final @Observes BeforeBeanDiscovery beforeBeanDiscoveryEvent) {
+ beforeBeanDiscoveryEvent.addInterceptorBinding(CachePut.class);
+ beforeBeanDiscoveryEvent.addInterceptorBinding(CacheResult.class);
+ beforeBeanDiscoveryEvent.addInterceptorBinding(CacheRemove.class);
+ beforeBeanDiscoveryEvent.addInterceptorBinding(CacheRemoveAll.class);
+ }
+}
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/MakeJCacheCDIIntercetporFriendly.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/jcache/cdi/MakeJCacheCDIIntercetporFriendly.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: commons/proper/jcs/trunk/src/resources/META-INF/services/javax.enterprise.inject.spi.Extension
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/resources/META-INF/services/javax.enterprise.inject.spi.Extension?rev=1590534&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/resources/META-INF/services/javax.enterprise.inject.spi.Extension (added)
+++ commons/proper/jcs/trunk/src/resources/META-INF/services/javax.enterprise.inject.spi.Extension Sun Apr 27 23:49:10 2014
@@ -0,0 +1 @@
+org.apache.commons.jcs.jcache.cdi.MakeJCacheCDIIntercetporFriendly
Added: commons/proper/jcs/trunk/src/resources/jcache.ccf
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/resources/jcache.ccf?rev=1590534&view=auto
==============================================================================
--- commons/proper/jcs/trunk/src/resources/jcache.ccf (added)
+++ commons/proper/jcs/trunk/src/resources/jcache.ccf Sun Apr 27 23:49:10 2014
@@ -0,0 +1,32 @@
+# 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.
+
+jcs.default=DC
+jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=200001
+jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.cacheattributes.UseMemoryShrinker=true
+jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
+jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
+jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.default.elementattributes.IsEternal=false
+jcs.default.elementattributes.MaxLifeSeconds=700
+jcs.default.elementattributes.IdleTime=1800
+jcs.default.elementattributes.IsSpool=true
+jcs.default.elementattributes.IsRemote=true
+jcs.default.elementattributes.IsLateral=true
+