Permalink
Browse files

[SM-2109] Fixed a bug which resulted in having CacheManager initializ…

…ed always using the default factory . StoreFactory now properly sets listeners to the store.

git-svn-id: https://svn.apache.org/repos/asf/servicemix/utils/trunk@1147077 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
iocanel committed Jul 15, 2011
1 parent d695455 commit c6850d5a31201b6c3515a4ef332eb8befa93c66a
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/main/java/org/apache/servicemix/store/ehcache/EhCacheStoreFactory.java
@@ -32,6 +32,7 @@
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 @@
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 EhCacheStoreFactory() {
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;

0 comments on commit c6850d5

Please sign in to comment.