[infinispan-dev] Feedback from Mobicents Cluster Framework on top of Infinispan 5.0 Alpha1

Galder Zamarreño galder at redhat.com
Fri Jan 7 05:34:14 EST 2011


On Jan 5, 2011, at 8:06 PM, Manik Surtani wrote:

> Thanks for the feedback, Eduardo.  I'll address each one separately, although Galder's done an excellent job already.  :)
> 
> On 4 Jan 2011, at 16:12, Eduardo Martins wrote:
> 
>>> 
>>> Oh right, I see what you mean. You're saying that getCacheManager() in Cache returns a CacheContainer rather than an EmbeddedCacheManager. There's a reason for this:
>>> 
>>> CacheContainer is the common demoninator for operations that are accessible by remote and local caches. EmbeddedCacheManager extends CacheContainer to add operations that only make sense on a local basis, whereas RemoteCacheManager does the same for remotely accessed Infinispan instances. For the moment, you cannot add listeners to remote cache/cachemanager instances, hence why those methods are only available in EmbeddedCacheManager.
>>> 
>>> It might make sense to have an EmbeddedCache interface that ties up this up via covariant returns, i.e.:
>>> 
>>> EmbeddedCacheManager getCacheManager();
>>> 
>> 
>> Agree.
> 
> This was changed in 4.1.0 when we introduced the RemoteCacheManager (Hot Rod client).  But yeah I appreciate your concerns re: not being able to add a cache manager listener when all you have is a reference to a cache - however I would have expected that you'd also have a reference to an EmbeddedCacheManager (since you created the cache!) so you could add listeners there.
> 
> I don't think a covariant return type will work.  If Cache.getCacheManager() returns EmbeddedCacheManager, then RemoteCache.getCacheManager() cannot return RemoteCacheManager since it isn't a sub-interface of EmbeddedCacheManager.

I'm not saying that Cache.getCacheManager should return EmbeddedCacheManager, see the example below.

> 
> TBH, RemoteCache.getCacheManager() is a no-op anyway - so I don't see why Cache.getCacheManager() doesn't just return EmbeddedCacheManager.
> 
> Galder, did you create a JIRA for this?

Hmmm, RemoteCache.getCacheManager() is a no-op cos RemoteCache defines:

   RemoteCacheManager getRemoteCacheManager();

AFAIK covariant returns means: "What this means is that a method in a subclass may return an object whose type is a subclass of the type returned by the method with the same signature in the superclass."

So, we could define have this:

Cache defines:
CacheContainer getCacheManager();

RemoteCache defines:
RemoteCacheManager getCacheManager();

If you had created a new subinterface called EmbeddedCache that extends Cache, you could do:

EmbeddedCache defines:
EmbeddedCacheManager getCacheManager();

This is possible cos both EmbeddedCacheManager and RemoteCacheManager are subclasses of CacheContainer.

> 
> Cheers
> Manik
> --
> Manik Surtani
> manik at jboss.org
> twitter.com/maniksurtani
> 
> Lead, Infinispan
> http://www.infinispan.org
> 
> 
> 
> 
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev

--
Galder Zamarreño
Sr. Software Engineer
Infinispan, JBoss Cache




More information about the infinispan-dev mailing list