Creating a custom expiry policy factory

This post explains how to create a custom expiry policy for the cache. Below is the example Custom Expiry Policy 1 import java.util.concurrent.TimeUnit; 2 3 import javax.cache.expiry.Duration; 4 import javax.cache.expiry.ExpiryPolicy; 5 6 public class CustomTouchedExpiryPolicy implements ExpiryPolicy { 7 @Override 8 public Duration getExpiryForAccess() { 9 Duration duration = new Duration(TimeUnit.MINUTES, 2); 10 return duration;…… Continue reading Creating a custom expiry policy factory

Stubbing void methods to do nothing

This post explains how to change the implementation of void methods to do nothing for testing purposes. Below is the example Classes to be tested package package13; public class Class2 { public void method2(String value) { value = value + ” World”; } } package package13; public class Class1 { private Class2 class2; public String…… Continue reading Stubbing void methods to do nothing

JCache TouchedExpiryPolicy

This post explains TouchedExpiryPolicy with simple example. TouchedExpiryPolicy is an expiry policy used to inform cache to remove entries which has exceeded its presence since last modification (which includes creation, access 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…… Continue reading JCache TouchedExpiryPolicy

Serialization of objects

This post explains how java objects can be serialized or deserialized in Spring framework Spring framework provides two interfaces and their default implementations as mentioned below Interfaces 1) Serializer 2) Deserializer Default Implementations 1) DefaultSerializer 2) DefaultDeserializer The default implementations internally uses java serialization to provide the serialization feature. In other words these implementations act…… Continue reading Serialization of objects