开发者

writing a GridCacheStore implementation in scala with gridgain

Im trying to write a gridgain implementation for read-through and write-through for gridcache using scala. however im having trouble converting some of the method patterns using generics form java (which is what its written in) to scala.

java doc in question: http://www.gridgain.com/javadoc30C/org/gridgain/grid/cache/GridCacheStore.html

specifically

loadAll(String cacheName, GridCacheTx tx, Collection<? extends K> keys, GridInClosure2<K,V> c)

i'm having trouble with

开发者_如何学Go
Collection<? extends K> keys

since i dont know how to do that in scala. So if anyone can show me the best way to do this in scala, that would be awsome. Unfortunately the awesome gridgain javadocs dont have much in the way of scala examples yet. Also can I safely ignore the GridCacheTx tx since im not going to be using transactions in my application.


Existential types were created for this situation. See Combining Scala and Java in the now free online first edition of Programming in Scala.

So you may need to define:

def loadAll(cacheName: String, tx: GridCacheTx, 
  keys:Collection[T] forSome {T <: K}, 
  c: GridInClosure2[K,V])

I think Collection[_ <: K] may also work.

I also read somewhere that abstract types could be used to handle a similar situation too, but I can't find the link now, so I'm not sure whether it covered this case or not. edit: actually it's in the book too (the SetAndType example in the next paragraph).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜