Giter VIP home page Giter VIP logo

jug-saxony-camp's Introduction

JUG Saxony Camp 2017 Build Status

The JUG Saxony Camp 2017 was organized by the JUG Saxony e.V. and took place at the HTWK Leipzig University of Applied Sciences.

Prerequisites:

Caching for Java EE applications with JCache API

public class CacheDemo {

  @CacheResult
  public int someExpensiveCalculation(int argOne, String argTwo) {
    return new Random().nextInt();
  }
}

Our aim is to temporary store the return value of our business logic. Therefore we annotate the method with @CacheResult, which is part of the JCache API (JSR-107). The WildFly AS provides an out of the box JCache implementation called Infinispan.

Caching with JCache API and Infinispan

In the directory code/jug.saxony.camp.jcache you can find a prototype, which uses Infinispan's CacheResultInterceptor. The JAR contains the business logic of our application, the WAR a servlet, and the EAR unites both for deployment.

$ cd code/jug.saxony.camp.jcache
$ mvn clean install

Now you are able to deploy the EAR on WildFly AS.

This servlet demonstrates, that our cache works as expected.

But this solution brings some problems:

  1. This cache isn't resistent against redeployment of your EAR, in case you might edit your view component.

  2. The storage of this cache is not under control of WildFly, so two applications aren't able to scale their performance by using a common cache.

The following caching technique will show you, how to solve this problems.

Caching against JCache API, embedded Infinispan and custom CacheResultInterceptor

Under code/jug.saxony.camp.infinispan.embedded you find a prototype, that has a custom implementation of JCache's CacheResultInterceptor. This interceptor uses Infinispan's embedded caching framework, which is independent from JCache. Thus this technique is able to reference WildFly's preconfigured caches.

$ cd code/jug.saxony.camp.infinispan.embedded
$ mvn clean install

Deploy the EAR to your WildFly instance and again access it's servlet. Redeploy this application and you will see, that the returned values remain the same. When you deploy a second instance of the application with a customized servlet, you will observe, that both share the common cache instance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.