Author: abelevich
Date: 2009-07-30 06:05:32 -0400 (Thu, 30 Jul 2009)
New Revision: 15055
Removed:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/AbstractCacheFactory.java
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/CacheManager.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/EhCacheCacheFactory.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/JBossCacheCacheFactory.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java
Log:
remove AbstractCacheFactory
Deleted:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/AbstractCacheFactory.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/AbstractCacheFactory.java 2009-07-30
10:03:47 UTC (rev 15054)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/AbstractCacheFactory.java 2009-07-30
10:05:32 UTC (rev 15055)
@@ -1,34 +0,0 @@
-package org.ajax4jsf.cache;
-
-import java.util.Map;
-
-/**
- * @author Anton Belevich
- *
- */
-public abstract class AbstractCacheFactory implements CacheFactory {
-
- private RegisterCallback registerCallback;
-
- public Cache createCache(String cacheName, Map<?,?> env) {
- Cache cache = createCache(env);
- if(registerCallback != null) {
- if(cacheName == null) {
- cacheName = cache.getClass().getName();
- }
- registerCallback.register(cacheName, cache);
- }
- return cache;
- }
-
- public abstract Cache createCache(Map <?,?> env);
-
- public RegisterCallback getRegisterCallback() {
- return registerCallback;
- }
-
- public void setRegisterCallback(RegisterCallback registerCallback) {
- this.registerCallback = registerCallback;
- }
-
-}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/CacheManager.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/CacheManager.java 2009-07-30
10:03:47 UTC (rev 15054)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/CacheManager.java 2009-07-30
10:05:32 UTC (rev 15055)
@@ -51,14 +51,6 @@
// Should this be a HashMap<String, WeakReference<Cache>>?
private final Map <String, Cache> caches = Collections.synchronizedMap(new
HashMap<String, Cache>());
-
- private RegisterCallback _registerCallback = new RegisterCallback() {
-
- public void register(String cacheName, Cache cache) {
- registerCache(cacheName, cache);
- }
-
- };
/**
* Returns the singleton CacheManager
*/
@@ -74,7 +66,19 @@
caches.put(cacheName, cache);
}
- public AbstractCacheFactory getCacheFactory(Map env , boolean registerCacheOnCreate)
{
+ public void createCache(String cacheName, Map <?,?> env) {
+ CacheFactory factory = getCacheFactory(env);
+ Cache cache = factory.createCache(env);
+ registerCache(cacheName, cache);
+ cache.start();
+ }
+
+ public void destroyCache(String cacheName) {
+ Cache cache = caches.remove(cacheName);
+ cache.stop();
+ }
+
+ public CacheFactory getCacheFactory(Map <?,?> env ) {
String[] factories;
String configuredFactoryName = findFactory(FACTORY_PROPERTY_NAME, env);
@@ -89,14 +93,10 @@
for (String factoryName : factories) {
try {
Class<?> spiClass = Class.forName(factoryName, true, loader);
- //CacheFactory cacheFactory =
CacheFactory.class.cast(spiClass.newInstance());
- AbstractCacheFactory cacheFactory =
AbstractCacheFactory.class.cast(spiClass.newInstance());
- if(registerCacheOnCreate) {
- cacheFactory.setRegisterCallback(_registerCallback);
- }
-
+ CacheFactory cacheFactory =
CacheFactory.class.cast(spiClass.newInstance());
+
log.info("Selected [" + factoryName + "]");
-
+
return cacheFactory;
} catch (Throwable iae) {
//TODO log debug
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/EhCacheCacheFactory.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/EhCacheCacheFactory.java 2009-07-30
10:03:47 UTC (rev 15054)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/EhCacheCacheFactory.java 2009-07-30
10:05:32 UTC (rev 15055)
@@ -12,7 +12,7 @@
* @author Nick Belaevski
* @since 4.0
*/
-public class EhCacheCacheFactory extends AbstractCacheFactory {
+public class EhCacheCacheFactory implements CacheFactory {
private static final Log log = LogFactory.getLog(EhCacheCacheFactory.class);
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/JBossCacheCacheFactory.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/JBossCacheCacheFactory.java 2009-07-30
10:03:47 UTC (rev 15054)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/JBossCacheCacheFactory.java 2009-07-30
10:05:32 UTC (rev 15055)
@@ -25,7 +25,7 @@
*/
//TODO - to doc - no max size eviction support
-public class JBossCacheCacheFactory extends AbstractCacheFactory {
+public class JBossCacheCacheFactory implements CacheFactory {
private org.jboss.cache.CacheFactory<String, Object> cacheFactory;
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java 2009-07-30
10:03:47 UTC (rev 15054)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/LRUMapCacheFactory.java 2009-07-30
10:05:32 UTC (rev 15055)
@@ -32,7 +32,7 @@
* created 01.05.2007
*
*/
-public class LRUMapCacheFactory extends AbstractCacheFactory {
+public class LRUMapCacheFactory implements CacheFactory {
private static final Log log = LogFactory.getLog(LRUMapCacheFactory.class);
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java 2009-07-30
10:03:47 UTC (rev 15054)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/cache/OSCacheCacheFactory.java 2009-07-30
10:05:32 UTC (rev 15055)
@@ -38,7 +38,7 @@
* created 01.05.2007
*
*/
-public class OSCacheCacheFactory extends AbstractCacheFactory {
+public class OSCacheCacheFactory implements CacheFactory {
private static final Log log = LogFactory.getLog(OSCacheCacheFactory.class);
Show replies by date