-
1. Re: RemoteCacheManager doesn't implement CacheManager?
mircea.markus May 13, 2010 12:42 PM (in response to supinko)The reason why RemoteCacheManager doesn't directly subclass CacheManager (but its parent CacheContainer) was the fact that CacheManager also have methods specific to a local cache manager: defineConfiguration, isCoordinator etc
A way to solve you problem is to work with caches directly, and hold a reference to Lifecycle (both RemoteCM and DefaultCM implement Lifecycle):
Cache c; Lifecycle cmLifecycle; if (usingRemoteGrid) { CacheManager cacheMgr cacheMgr = new RemoteCacheManager(); c = cacheMgr.getCache("someName"); cmLifecycle = cacheMgr; } else { CacheManager cacheMgr = new DefaultCacheManager(); c = cacheMgr.getCache("someName"); cmLifecycle = cacheMgr; } c.put("k","v"); ... void shutdown() { cmLifecycle .stop(); }
But now looking at this example it might make sense indeed to have RemoteCacheManager implement CacheManager and throw these exception. Opinions ?
-
2. Re: RemoteCacheManager doesn't implement CacheManager?
meetoblivion May 13, 2010 1:00 PM (in response to mircea.markus)that sounds like a better idea to me, i nearly broke my keyboard in half until I realized it wasn't inheriting CacheManager (plus, the naming seems weird). Since it does implement Lifecycle we should have a way to be able to identify a LifecycleCacheContainer maybe?
-
3. Re: RemoteCacheManager doesn't implement CacheManager?
manik May 13, 2010 1:02 PM (in response to mircea.markus)Well if CacheContainer extended Lifecycle we could just do:
Cache c; CacheContainer cc; if (usingRemoteGrid) { cc = new RemoteCacheManager(); } else { cc = new DefaultCacheManager(); } c = cc.getCache("cacheName"); ... void shutdown() { cc.stop(); }
-
4. Re: RemoteCacheManager doesn't implement CacheManager?
supinko May 13, 2010 1:11 PM (in response to manik)Having CacheContainer extend Lifecycle would solve my problem in a pretty low impact way, and it also makes a lot of sense because all CacheContainers need to start and stop anyway.
The only oddity is that the names of RemoteCacheManager and DefaultCacheManager are so similar to CacheManager that I think the normal instinct would be to use CacheManager as a common interface. One way to accomplish this would be to insert a LocalCacheManager interface or abstract class between CacheManager and DefaultCacheManager. LocalCacheManager would contain all the "extra" methods that aren't in RemoteCacheManager.
Thanks,
Supin
-
5. Re: RemoteCacheManager doesn't implement CacheManager?
meetoblivion May 13, 2010 1:07 PM (in response to manik)Would that be a necessary extension point? E.g. would any implementation of CacheContainer need to be a Lifecycle (are there cases where it wouldn't/shouldn't/can't be?
-
6. Re: RemoteCacheManager doesn't implement CacheManager?
manik May 13, 2010 2:32 PM (in response to supinko)Yeah I see what you mean. Perhaps it makes sense to do something like:
I don't like using the word LocalCacheManager as it insinuates that you only create local-mode caches from such a manager whereas you can create replicated and distributed caches too. Embedded is a more correct term as caches created by such a cache manager run within the same JVM.
-
7. Re: RemoteCacheManager doesn't implement CacheManager?
mircea.markus May 14, 2010 6:26 AM (in response to meetoblivion)that sounds like a better idea to me, i nearly broke my keyboard in half until I realized it wasn't inheriting CacheManager (plus, the naming seems weird). Since it does implement Lifecycle we should have a way to be able to identify a LifecycleCacheContainer maybe?
Yep, I think that would make more sense. Sorry for the keyboard.
-
8. Re: RemoteCacheManager doesn't implement CacheManager?
mircea.markus May 14, 2010 6:30 AM (in response to mircea.markus)Yeah I see what you mean. Perhaps it makes sense to do something like:
Yep, that looks as the way it should be, IMO. It brakes the backward-compatibility of CacheManager through. What about going for a compromise solution in 4.1 ( CacheContainer extended Lifecycle) and do the full API change in 5.0 ?
-
9. Re: RemoteCacheManager doesn't implement CacheManager?
manik May 14, 2010 6:45 AM (in response to mircea.markus)I'm not too fussed about doing this in 4.1.0 TBH. It's still early days and in 4.0.0, people always used DefaultCacheManager anyway (since that was all we had!) Care to create a JIRA?
-
10. Re: RemoteCacheManager doesn't implement CacheManager?
mircea.markus May 14, 2010 1:41 PM (in response to manik)