Java Reference
In-Depth Information
ar to the java.util.ConcurrentMap Java SE, with some modifications for distrib-
uted environments. In particular, it adds the ability to register, deregister, and list event
listeners. Also, it defines a CacheLoader interface to load/store cached data. Cache in-
stances can be retrieved using an appropriate CacheManager interface, which repres-
ents a collection of caches.
So here's our singleton TheatreBox class rewritten using the Infinispan API:
@AccessTimeout(value = 5, unit = TimeUnit.MINUTES)
public class TheatreBox {
private static final Logger logger =
private Map<Integer, Seat> seats;
@Resource(lookup = "java:jboss/infinispan/tickets")
private EmbeddedCacheManager container;
public void setupTheatre() {
try {
this.cache = container.getCache();"Got Infinispan cache");
int id = 0;
for (int i = 0; i < 5; i++) {
addSeat(new Seat(++id, "Stalls", 40));
addSeat(new Seat(++id, "Circle", 20));
addSeat(new Seat(++id, "Balcony", 10));
}"Seat Map constructed.");
} catch (Exception e) {"Error! " + e.getMessage());
private void addSeat(Seat seat) {
Search WWH ::

Custom Search