Skip to content
JCache bridge for JavaEE 7 applications
Branch: master
Clone or download
Latest commit 492dd3b Feb 21, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
.travis.yml
LICENSE
README.adoc
pom.xml

README.adoc

JCache JEE 7

Build Status

The project is under license [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0).

Main goal

This jar module is made to be embbeded as a Java EE 7 Web application library.

It enables support for JSR 107 a.k.a "JCache" based on Hazelcast implementation provider. This JSR is the future of Java EE caching API currently targeted in Java EE 8 release.

Using this module in a Web app will automatically expose a REST API to help dealing with Cache Managing features.

This module relies on others Java EE API : CDI, JAX-RS and JSP

Requirements

  • Java 8

  • Java EE 7

  • JAX-RS application for REST API support

Quick start

First step is adding maven dependency into your WEB-INF\lib (for a WAR packaging)

<dependency>
    <groupId>io.github.gpein</groupId>
    <artifactId>jcache-jee7</artifactId>
    <version>1.1.0</version>
</dependency>

Then enable JCache interceptors in your beans.xml CDI descriptor

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
		http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
       bean-discovery-mode="all">

    <interceptors>
        <class>org.jsr107.ri.annotations.cdi.CacheResultInterceptor</class>
        <class>org.jsr107.ri.annotations.cdi.CacheRemoveEntryInterceptor</class>
        <class>org.jsr107.ri.annotations.cdi.CacheRemoveAllInterceptor</class>
        <class>org.jsr107.ri.annotations.cdi.CachePutInterceptor</class>
    </interceptors>
</beans>

Your are now able to use JSR 107 API ! For more information, please check the GitHub repository : https://github.com/jsr107/jsr107spec

Hazelcast manual can be found here : http://docs.hazelcast.org/docs/3.6/manual/html-single

Releases

  • 1.1.1 : aligned with hazelcast 3.6

  • 1.1.0 : added basic UI to manage cache statistics and export them as CSV file

  • 1.0.0 : initial release including JSR 107 support and REST API for handling cache statistics

Next features

  • Basic UI to interact directly with REST API

REST API documentation

/caches

GET

Get a basic representation of all running caches

Request

Header

Accept : application/json

Body

N/A

Response

Status

  • 200 OK

Header

Content-Type : application/json

Body

[
  {
    "name": "book.cache",
    "managementEnabled": true,
    "statisticsEnabled": false
  },
  {
    "name": "disk.cache",
    "managementEnabled": true,
    "statisticsEnabled": true
  }
]

/caches/{cacheName}

PUT

Change cache attributes

Pattern matching

  • {cacheName} is the unique name of a running cache

Request

Parameters :

N/A

Header

Accept : application/json

Body

[
  {
    "managementEnabled": true,
    "statisticsEnabled": false
  }
]

Response

Status

  • 200 OK

  • 404 Not Found

/caches/{cacheName}/statistics

Pattern matching

  • {cacheName} is the unique name of a running cache

GET

Read all statistics values for a named cache

Request

Header

N/A

Body

N/A

Response

Status

  • 200 OK

  • 404 Not Found

Body

{
    "hits": 560,
    "misses": 9,
    "hitPercentage": 98.418274,
    "missPercentage": 1.5817223,
    "gets": 569,
    "puts": 9,
    "removals": 0,
    "evictions": 0,
    "averageGetTime": 0,
    "averagePutTime": 52.27778,
    "averageRemoveTime": 0
}

/caches-statistics

PUT

Enable/Disable statistics for all caches

Request

Header

Accept : application/json

Body

{
    "enabled": true
}

Response

Status

  • 200 OK

You can’t perform that action at this time.