Building the JCache Java EE 8 Bridge...One Brick at a Time

DZone 's Guide to

Building the JCache Java EE 8 Bridge...One Brick at a Time

All in all it's just another brick in the JCache Java EE 8 bridge.

· Java Zone ·
Free Resource

Let’s quickly look at the Java EE 8-JCache bridge project. This is another concrete step as far as Java EE 8 integration efforts are concerned...


Details on the general idea behind this can be picked up from one of my recent posts on this topic.

A Bridge?? What For?

  • Serve as the integration point for JCache & Java EE 8
  • Provide decoupling: the Java EE 8 platform and the JCache API can be allowed to evolve separately and the bridge would provide a much-needed cushion. Think of it as a regular Bridge Pattern (from the GoF) – just implemented in the form of a JSR ;-)


  • Derive from existing (and popular) specifications like JPA which can make it easier to adopt and use
  • Standardise a JCache descriptor (configuration)
  • Implement Cache injection
  • Look at support for custom cache properties (which vary across different providers)
  • etc…

Crossing the Bridge

Here is a rather simple example. It's a Java EE 7 Maven project on GitHub. You should be able to pull in into any IDE (Netbeans recommended) and get going

All it Does is

  • Defines a named cache in cache.xml placed in WEB-INF/classes/META-INF (this is a pre-requisite for WAR based artifacts)
  • Inject the cache in a JAX-RS resource
  • Save the JSR info in the cache for future use (if it already does not exist there)
  • It provides you JSR information e.g. http://localhost:9000/jcachejavaee8bridge/370 and also scolds you if you ask for it again and again since it has to access the cache of course ;-)
public class JavaEE8Resource {

    Cache<String, String> cache;

    public Response getinfo(@PathParam("jsrNum") String jsrNum) {
       String resp = null;
            //do something !
            //use the cache.... !

        return Response.ok(resp).build(); 


Other Notable Points

  • The cache bridge API source has been included directly into the sample project to make dependency management easier (since it's not in Maven yet). You might want to have the latest fork for your experiments
  • The JCache RI is being used by internally by the bridge. Experiment with another JCache provider (Hazelcast, Infinispan etc.), include its dependency and include it in the cache.xml configuration
    <cache name="jsrinfocache">
            <property name="store.by.value" value="true"/>
            <property name="management.enabled" value="false"/>
            <property name="statistics.enabled" value="true"/>
    <cache name="anotherone">
            <property name="store.by.value" value="false"/>
            <property name="management.enabled" value="true"/>
            <property name="statistics.enabled" value="false"/>

How can You Contribute?

  • Explore the project
  • Provide ideas, files issues
  • Write tests, break stuff, file some more issues!
  • Get in touch with Adam Bien, translate your ideas into code and submit a PR…


java, javaee, jcache

Published at DZone with permission of Abhishek Gupta , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}