Filtering maps in SpEL

In this post I will explain with example how to filter maps in SpEL expression. For our example we will use the below main class Main class package spel.package12; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import java.util.HashMap; import java.util.Map; @Configuration @ComponentScan(basePackages = “spel.package12”) public class Example12 { @Value(“#{maps.?[key >=…… Continue reading Filtering maps in SpEL

Filtering collections in SpEL

In this post, I will explain with example how to filter collections in SpEL. For our example we will use the below model class Student package spel.package11; public class Employee { private int id; private String name; private int salary; public Employee(int id, String name, int salary) { this.id = id; this.name = name; this.salary…… Continue reading Filtering collections in SpEL

Refering User Defined Classes in SpEL

In all my previous post, I used classes provided by Java. In this post, I will explain how to refer user defined classes. For our example I will create a user defined class “Student” with below class structure. Student package spel.package10; public class Student { private int id; private String name; public Student(int id, String…… Continue reading Refering User Defined Classes in SpEL

Invoking Constructors in SpEL

In this post under Spring SpEL, I will show with example how to invoke constructors. Below is the complete code for your reference Main class 1 package spel.package9; 2 3 import org.springframework.beans.factory.annotation.Value; 4 import org.springframework.context.ApplicationContext; 5 import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 import org.springframework.context.annotation.ComponentScan; 7 import org.springframework.context.annotation.Configuration; 8 import java.util.List; 9 10 @Configuration 11 @ComponentScan(basePackages = “spel.package9”) 12…… Continue reading Invoking Constructors in SpEL

Invoking static methods in SpEL

In this post under Spring SpEL, I will show with example how to invoke static method in SpEL. In SpEL expression, to inform Spring that we are calling static method of class, we use T operator. T operator followed by class name within paranthesis informs the Spring to use Class object of the specified class.…… Continue reading Invoking static methods in SpEL

Invoking object’s non-static methods in SpEL

In this post under Spring SpEL, I will show with example how to call an instance’s non-static method. Below is the complete code for your reference. Main class 1 package spel.package7; 2 3 import org.springframework.beans.factory.annotation.Value; 4 import org.springframework.context.ApplicationContext; 5 import org.springframework.context.annotation.AnnotationConfigApplicationContext; 6 import org.springframework.context.annotation.ComponentScan; 7 import org.springframework.stereotype.Component; 8 9 @Configuration 10 @ComponentScan(basePackages = “spel.package7”) 11…… Continue reading Invoking object’s non-static methods in SpEL

Creating a store by reference cache

In this post under JCache, I will explain with example how to create store by reference cache. We create a store by reference cache by calling “setStoreByValue” available in “MutableConfiguration” and we need to pass “false” as method argument. Below is the complete main code for your reference. Main Class 1 package defaultPackage; 2 3…… Continue reading Creating a store by reference cache

Creating a store by value cache

In this post under JCache, I will explain with example how to create store by value cache. We create a store by value cache by calling “setStoreByValue” available in “MutableConfiguration” and we need to pass “true” as method argument. Below is the complete main code for your reference. Main Class 1 package defaultPackage; 2 3…… Continue reading Creating a store by value cache

JCache AccessedExpiryPolicy Example

In this post under JCache, I will explain with example the purpose of “AccessedExpiryPolicy” and how to use it AccessedExpiryPolicy is an expiry policy used to inform cache to remove entries which has exceeded its presence based on last accessed. Access involves creation and access of cache entries but not update. Below the main code…… Continue reading JCache AccessedExpiryPolicy Example