AdamBien / jc2

JCache Configurator for Java EE 7

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jc2

JCache Configurator for Java EE 7

Installation

<dependency>
  <groupId>com.airhacks</groupId>
  <artifactId>jc2</artifactId>
  <version>0.0.2</version>
</dependency>

Usage

package com.airhacks.jc2.boundary;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;

@Path("hello")
public class HelloResource {

    @Inject
    String greeting;
    
	@GET
    public String hello() {
        return greeting;
    }

}

The key com.airhacks.jc2.boundary.HelloResource.greeting is resolved in the cache named: configuration

Customization

An initial set of value can be preloaded and merged by exposing a Map<String,String> like e.g.:

import java.util.HashMap;
import java.util.Map;
import javax.enterprise.inject.Produces;

public class InitialConfiguration {

    @Produces
    public Map<String, String> get() {
        Map<String, String> cache = new HashMap<>();
        cache.put("com.airhacks.jc2.boundary.HelloResource.greeting", "hey duke");
        return cache;
    }
}

Administration

headlands exposes JCache API as a REST service and also uses Hazelcast as an SPI. Deploy headlands and use the cache with the name configuration to maintain the contents.

About

JCache Configurator for Java EE 7

License:Apache License 2.0


Languages

Language:Java 96.3%Language:HTML 2.3%Language:Shell 1.4%