On 24 Feb 2012, at 14:22, Galder Zamarreño wrote: > Hi all, > > When are we gonna switch to JSR-107 listeners?
When 107 is ready. If you want, create an additional module for 107-compatible API and add it there, with the implementation delegating to our current API. > > As I mention in https://community.jboss.org/message/719245#719245, cache > entry created and modified notifications are not very intuitive if you want > to do something on cache entry created that you don't wanna do on cache > modified, and viceversa, and you want to do such thing when isPre=false (the > majority of times tbh). > > To give you an real example, Hot Rod remote notifications. I want to send a > different notification when a cache entry is created (=insert) as opposed to > when cache entry is modified (=update), and of course, I wanna do so *after* > the event. How do I code this? > > Option 1: > - Implement @CacheEntryCreated and in it send a notification for cache entry > created when isPre=false. > - Implement @CacheEntryModified and in it send a notification for cache entry > modified when isPre=false. > Problem? If the entry is created, this will generate two notifications (one > for created, and one for modified) and @CacheEntryModified can only > differentiate between cache entry created vs modified with isPre=true. Yes, you'd need to have this expectation in your listener. E.g., register that you saw a CEC event for key K, and don't fire an update for the subsequent CEM event for that same key. > Option 2: > - Implement @CacheEntryModified and in it, check whether value is null. If > null, entry was created, if not null, entry was modified. > Problem? Only works with isPre=true and this is not good cos you're sending > the remote notification before the actual event. > > Any other solution requires the listener to keep some state which is ugly to > say the least. > > If you have any simpler ideas I might have missed, I'm all ears. > > Btw, a similar problems happen with cache entry removed and cache entry > modified. How do you differentiate between them two when isPre=false? > > I haven't checked the JSR-107 listeners yet, but I hope they're more sane in > this area. Yes they will be more sane, but don't expect us to implement it natively for a while. At least 6.0, by when the JSR would be final. Cheers Manik -- Manik Surtani ma...@jboss.org twitter.com/maniksurtani Lead, Infinispan http://www.infinispan.org _______________________________________________ infinispan-dev mailing list infinispan-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/infinispan-dev