Author: abelevich
Date: 2009-07-30 06:06:57 -0400 (Thu, 30 Jul 2009)
New Revision: 15056
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/CacheInitializationListener.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/InitializationListener.java
Log:
use CacheManager destroy method to unregister and stop caches
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/CacheInitializationListener.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/CacheInitializationListener.java 2009-07-30
10:05:32 UTC (rev 15055)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/CacheInitializationListener.java 2009-07-30
10:06:57 UTC (rev 15056)
@@ -1,15 +1,11 @@
package org.ajax4jsf.event;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.Map.Entry;
-import javax.faces.context.FacesContext;
import javax.faces.event.SystemEvent;
import org.ajax4jsf.cache.Cache;
-import org.ajax4jsf.cache.CacheFactory;
import org.ajax4jsf.cache.CacheManager;
/**
@@ -20,40 +16,23 @@
@Override
public void init(SystemEvent event) {
-
-// CacheManager cacheManager = CacheManager.getInstance();
-// FacesContext facesContext = FacesContext.getCurrentInstance();
-//
-// Map<?,?> envMap = facesContext.getExternalContext().getInitParameterMap();
-// CacheFactory cacheFactory = cacheManager.getCacheFactory(envMap);
-// Cache cache = cacheFactory.createCache(envMap);
-//
-// if(cache != null) {
-// String cacheName = cache.getClass().getName();
-// cacheManager.registerCache(cacheName, cache);
-// cache.start();
-// }
-//
+ //TODO read configuration ??
}
- //stop and remove all caches instances
+
@Override
public void destroy(SystemEvent event) {
-
CacheManager cacheManager = CacheManager.getInstance();
Map <String, Cache> caches = cacheManager.getCaches();
- System.out.println("CacheInitializationListener.destroy()");
if(!caches.isEmpty()) {
-
- Iterator <Map.Entry<String, Cache>> iterator =
caches.entrySet().iterator();
- while(iterator.hasNext()) {
- Entry <String, Cache> entry = iterator.next();
- Cache cache = entry.getValue();
- cache.stop();
- iterator.remove();
+ Set <String> cacheNames = caches.keySet();
+ for(String cacheName: cacheNames) {
+ try {
+ cacheManager.destroyCache(cacheName);
+ } catch (Exception e) {
+ looger.error("Error during stop cache " + cacheName, e);
+ }
}
-
}
-
- }
+ }
}
Modified:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/InitializationListener.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/InitializationListener.java 2009-07-30
10:05:32 UTC (rev 15055)
+++
root/framework/trunk/impl/src/main/java/org/ajax4jsf/event/InitializationListener.java 2009-07-30
10:06:57 UTC (rev 15056)
@@ -7,6 +7,9 @@
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
+import org.richfaces.util.RichfacesLogger;
+import org.slf4j.Logger;
+
/**
* framework initialization listener
* @author Anton Belevich
@@ -14,7 +17,8 @@
*/
public abstract class InitializationListener implements SystemEventListener {
-
+ protected static final Logger looger = RichfacesLogger.CACHE.getLogger();
+
public boolean isListenerForSource(Object source) {
return source instanceof Application ? true : false;
}
Show replies by date