Author: iocanel
Date: Fri Jul 15 10:28:57 2011
New Revision: 1147077

URL: http://svn.apache.org/viewvc?rev=1147077&view=rev
Log:
[SM-2109] Fixed a bug which resulted in having CacheManager initialized always 
using the default factory . StoreFactory now properly sets listeners to the 
store.

Modified:
    
servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/ehcache/EhCacheStoreFactory.java

Modified: 
servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/ehcache/EhCacheStoreFactory.java
URL: 
http://svn.apache.org/viewvc/servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/ehcache/EhCacheStoreFactory.java?rev=1147077&r1=1147076&r2=1147077&view=diff
==============================================================================
--- 
servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/ehcache/EhCacheStoreFactory.java
 (original)
+++ 
servicemix/utils/trunk/src/main/java/org/apache/servicemix/store/ehcache/EhCacheStoreFactory.java
 Fri Jul 15 10:28:57 2011
@@ -32,6 +32,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.servicemix.id.IdGenerator;
 import org.apache.servicemix.store.Store;
+import org.apache.servicemix.store.StoreListener;
 import org.apache.servicemix.store.base.BaseStoreFactory;
 
 /**
@@ -45,7 +46,7 @@ public class EhCacheStoreFactory extends
     private Map<String, EhCacheStore> stores = new HashMap<String, 
EhCacheStore>();
 
     private CacheManagerFactory cacheManagerFactory = new 
CacheManagerFactory();
-    private CacheManager cacheManager = cacheManagerFactory.build();
+    private CacheManager cacheManager;
 
     public EhCacheStoreFactory() {
 
@@ -54,12 +55,21 @@ public class EhCacheStoreFactory extends
     public synchronized Store open(String name) throws IOException {
         EhCacheStore store = stores.get(name);
         if (store == null) {
+
+            if(cacheManager == null) {
+                cacheManager = cacheManagerFactory.build();
+            }
+
             Cache cache = cacheManager.getCache(name);
             if(cache == null) {
                 cacheManager.addCache(name);
                 cache = cacheManager.getCache(name);
             }
             store = new EhCacheStore(cache,idGenerator, name);
+
+            for(StoreListener listener:storeListeners) {
+                store.addListener(listener);
+            }
             stores.put(name, store);
         }
         return store;


Reply via email to