[infinispan-dev] Abstracting javax.cache.annotation.CacheKey away from the user?

Galder Zamarreño galder at redhat.com
Mon Oct 24 10:15:30 EDT 2011


Pete/Kevin,

Looking at the Infinispan CDI quickstart, I see:

   @GreetingCache
   private Cache<CacheKey, String> cache;

The key that the user really uses here is String. So, could that be defined like this?

   @GreetingCache
   private Cache<String, String> cache;

Btw, I've just tried this and when using the key I get:

Caused by: java.lang.ClassCastException: org.infinispan.cdi.interceptor.DefaultCacheKey cannot be cast to java.lang.String

Are we forcing the user to dephicer what's in CacheKey? Related to this, looking at org.infinispan.cdi.interceptor.DefaultCacheKey I see no way to retrieve individual elements of a key. 

My point here is whether we can avoid leaking javax.cache.annotation.CacheKey to the user cos it can do little with it without being able to get its contents.

I see there;s a way to define a custom key, but that should not be necessary for a simple key based on a String for example.

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




More information about the infinispan-dev mailing list