Hi Galder,<br><br><div class="gmail_quote">On 24 October 2011 15:15, Galder Zamarreño <span dir="ltr">&lt;<a href="mailto:galder@redhat.com" target="_blank">galder@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Pete/Kevin,<br>
<br>
Looking at the Infinispan CDI quickstart, I see:<br>
<br>
   @GreetingCache<br>
   private Cache&lt;CacheKey, String&gt; cache;<br>
<br>
The key that the user really uses here is String. So, could that be defined like this?<br>
<br>
   @GreetingCache<br>
   private Cache&lt;String, String&gt; cache;<br>
<br>
Btw, I&#39;ve just tried this and when using the key I get:<br>
<br>
Caused by: java.lang.ClassCastException: org.infinispan.cdi.interceptor.DefaultCacheKey cannot be cast to java.lang.String<br>
<br>
Are we forcing the user to dephicer what&#39;s in CacheKey? Related to this, looking at org.infinispan.cdi.interceptor.DefaultCacheKey I see no way to retrieve individual elements of a key.<br></blockquote><div><br></div>


<div>That&#39;s how it&#39;s defined in JSR-107 specification &quot;<span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Arial; white-space: pre-wrap; ">All generated cache keys must implement the CacheKey interface.</span>&quot;</div>

<div><br></div><div>If you look at the <a href="https://github.com/kevinpollet/jsr107spec/blob/master/src/main/java/javax/cache/annotation/CacheKey.java">CacheKey </a>contract there is no methods defined to retrieve the content of the key. Here we could provide our own methods but the user will be implementation dependent. Maybe you could raise this point on JSR-107 mailing list, an unwrap method could be defined in the <i>CacheKey </i>contract to use specific implementation features.</div>

<div><br></div><div>Pete, Manik?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
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.</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


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.<br></blockquote><div><br></div><div>I&#39;m not sure we can avoid the use of CacheKey since it&#39;s defined like that in the spec. As said before we can provide at least our own methods in the <i>DefaultCacheKey </i>implementation (open an issue and I&#39;ll do it).</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
<font color="#888888">--<br>
Galder Zamarreño<br>
Sr. Software Engineer<br>
Infinispan, JBoss Cache<br>
<br>
</font></blockquote></div><br><div>--Kevin</div>