JavaOne 2012: Any news on the Java Caching Standard (JSR 107)?
Lucas Jellema already mentioned in his excellent overview of JavaOne 2012 that the Java Caching API (JSR 107) will be part of JEE 7. “Cool! Does that mean that this JSR (the longest running JSR ever!) is finally complete?” – No, not really. – “That’s ok, I guess the draft review process is going quite well, eh?” – Ehh, not really, the first draft has yet to be released. – “?!?!”
The draft is ready though, it has been ready since February 2012. It turns out that the ‘performance issues’ of this caching JSR are caused by the legal departments of Oracle and Terracotta. I heard that the release is expected any moment now. Next, a quick reminder of the features of the Java Caching Standard (the current status).
- Map-like interface
A cache in JSR 107 (i.e. an implementation of javax.cache.Cache) is based on java.util.Map, with some modifications (mainly for performance reasons). For example, the values() method has been removed and several methods that return a value are modified to return a boolean or void instead (s.a. remove(K key) and put(K key, V value)).
- By-Value and By-Reference caching
By-Value storing of keys and values is default behavior in JSR 107 caches. It provides the most consistent behavior in distributed caches and prevents problems with mutable objects. Optionally, a cache implementation can support By-Reference caching, this can dramatically increase performance in standalone caches.
- Read-through and write-through caching
A CacheReader and/or a CacheWriter can be attached to a cache to implement read-through, write-through and write-behind caching.
- Atomic operations
Most operations on javax.cache.Cache are atomic (similar to java.util.ConcurrentMap) including methods like getAndReplace(K key, V value) and putIfAbsent(K key, V value).
Cache events can be monitored with listeners. There used to be a way to indicate the NotificationScopeof the listeners, i.e. a registered listener would either receive events from the same JVM or events from another JVM (in case of a distributed cache), but this has been removed in the latest version. I’m not sure why. The possible listeners are:
Caches provide access to a CacheStatistics object. These can be used to measure cache use and efficiency.
The easiest way to cache is by using annotations on regular objects in combination with Spring or CDI. Common cache operations include: @CacheResult, @CachePut, @CacheRemoveEntry and @CacheRemoveAll.
The caches can participate in (XA and Local) transactions following the rules and API of the Java Transaction API. Transaction support is optional in JSR 107 and therefore implementation dependent.
Several implementations of the API are expected, including:
- Terracotta – Ehcache
- Oracle – Coherence
- JBoss – Infinispan
- IBM – eXtreme Scale
- Google App Engine memcache service
Look at https://github.com/jsr107/jsr107spec/ for more information.
- JavaOne 2012: Thinking Through Java Enterprise Performance (BOF 4712)
- JMX – Java Management Extension – paving the way for manageable applications (JavaOne 2007)
- JavaOne 2012: Strategy and Technical Keynote
- JavaOne 2010 presentation: Why and how to engage a Complex Event Processor from a Java Web Application
- JavaOne 2012: The Big Stories
- AMIS vat Oracle OpenWorld samen in speciale whitepaper
- OOW 2012: BPM is this year’s Fusion Middleware star
- OOW 2012: The yearly AMIS Review from Oracle Open World and JavaOne – slides available
- OOW 2012: Little things make me happy
- OOW 12: The Oracle Cloud strategy – explosive stuff or vaporware?
- JavaOne 2012: The Big Stories
- OOW 2012: Data Visualizations with ADF DVT – continuous evolution demonstrated
- JavaOne 2012: What’s new in Servlet3.1: An Overview
- OOW 2012 – The Big Stories
- OOW 2012: The Very Very Latest in Database Development (CON4792)