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

Creating inline map in SpEL

In this post under Spring SpEL, I will show with example how to create an inline map. Below is the main class for your reference. Main class 1 package spel.package6; 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 import java.util.Map; 10 11 @Configuration 12 @ComponentScan(basePackages…… Continue reading Creating inline map in SpEL

Creating inline list in SpEL

In this post under Spring SpEL, I will show with example how to create and access inlist line. Below is the complete class file reference. 1 package spel.package5; 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 import java.util.List; 10 11 @Configuration 12 @ComponentScan(basePackages = “spel.package5”)…… Continue reading Creating inline list in SpEL

Overriding or providing new command at container startup

Some docker images will have “CMD” instruction in their DockerFile out of the box. In this post I will explain how to override that “CMD” instruction if present in DockerFile or provide our own instruction in the absence of “CMD” instruction in the DockerFile. For our example I will use the nginx image from DockerHub.…… Continue reading Overriding or providing new command at container startup

Mapping flat objects to hierarchical objects

In the previous post under MapStruct I showed how to map hierarchial objects to flat objects. In this post, I will show the reverse i.e., how to map flat objects to hierarchical objects. We are assuming the property names on source and destination objects are same. For our example I will use the below model…… Continue reading Mapping flat objects to hierarchical objects

Executing a command inside running container

In this post under TestContainer, I will show with example how to execute a command inside a running container and get the output. Below is the complete main code for your reference. Main Class 1 package package6; 2 3 import java.io.IOException; 4 5 import org.testcontainers.containers.Container; 6 import org.testcontainers.containers.GenericContainer; 7 import org.testcontainers.utility.DockerImageName; 8 9 public class…… Continue reading Executing a command inside running container

Retrieving selected attribute when doing basic search

In this post under Java LDAP, I will show with example how to retrieve specific attributes when doing basic search. For our example we will use the below ldap hierarchy. Now lets see the main code which actually does the search. Main class 1 package package11; 2 3 import javax.naming.Context; 4 import javax.naming.NamingEnumeration; 5 import…… Continue reading Retrieving selected attribute when doing basic search