Java 8 introduces a new feature called Default Interface. This feature allows interface creator to provide default implementations for methods, so that concrete classes that implementing the interface don’t have to provide implementations for those methods. The below code gives you an example of how to create default interface and how to use them. Interface…… Continue reading Default Interface Example
Month: December 2016
Creating and Writing JSON object model to a file
This post explains how to create and save json object model to a file. In the example we build the below json object model representing person information. { “ssn” : “111111111”, “name” : { “firstName” : “Ronald”, “lastName” : “Childs” }, “phoneNumbers” : [ “1112223333”, “4445556666” ] } The main code is as shown below…… Continue reading Creating and Writing JSON object model to a file
Different ways to add entry in cache
This post explains the different ways provided by JCache to add entries in a cache. The api’s are as mentioned below 1) void put(K key, V value) –> Takes key and value as argument 2) void putAll(Map map) –> Takes a map as an argument 3) boolean putIfAbsent(K key, V value) –> Takes a key…… Continue reading Different ways to add entry in cache
JCache ModifiedExpiryPolicy
This post explains ModifiedExpiryPolicy with simple example. ModifiedExpiryPolicy is an expiry policy used to inform cache to remove entries which has exceeded its presence since last modification (which includes creation and update) Main Code 1 import java.util.Iterator; 2 3 import javax.cache.Cache; 4 import javax.cache.Cache.Entry; 5 import javax.cache.CacheManager; 6 import javax.cache.Caching; 7 import javax.cache.configuration.Factory; 8 import…… Continue reading JCache ModifiedExpiryPolicy