In this post under Spring Core, I will explain with example how to use “@Lookup” annotation with arguments. In the previous post under Spring Core, I showed the purpose and how to use “@Lookup” annotation without any arguments. Just for recap,1) “@Lookup” annotation is applied on the method level2) It tells Spring to create a…… Continue reading Using @Lookup annotation with arguments
Tag: Spring Framework
Using @Lookup annotation without arguments
In this post under Spring Core, I will explain with example the purpose of “@Lookup” annotation used without any arguments. “@Lookup” annotation is applied only on methods. “@Lookup” annotation can be used with or without arguments. In this post I will show how to use “@Lookup” annotation without arguments. In case of “@Lookup” annotation without…… Continue reading Using @Lookup annotation without arguments
Using @Conditional example
In this post under Spring Core, I will show with example the purpose of “@Conditional” annotation. Sometimes we want certain beans to be initialized based on a condition. If those conditions are not met we don’t want to initialize those beans. Say for example, we have two beans “bean1” and “bean2”. We want only “bean1″…… Continue reading Using @Conditional example
Internationalization in Spring
In this post under Spring Core, I will show with example how to achieve Internationalization using Spring framework. Internationalization in Spring is achieved using “MessageSource” interface and its default implementations. Whenever an “ApplicationContext” instance is created, Spring searches for bean definition with name “messageSource”, when found associate it with “ApplicationContext” instance. “ApplicationContext” interface implements “MessageSource”…… Continue reading Internationalization in Spring
Appling @Value on constructor parameter
In this post under Spring Core, I will show with example how to apply “@Value” annotation on a constructor parameter. In my previous post under Spring Core, I have showed how to apply “@Value” annotation on class instance variable. Below is the complete main class showing how to apply “@Value” annotation on a constructor parameter…… Continue reading Appling @Value on constructor parameter
Elvis operator
In this post under Spring SpEl, I will explain with example the purpose of Elvis operator. Lets say you have below statement written using ternary operator String result = (data != null) ? data : null; In the above statement “data” variable is of type String. So we are checking if “data” is not null,…… Continue reading Elvis operator
Safe navigation operator
In this post under Spring SpEl, I will explain with example the usage of safe navigation operator. Lets say we have below pojo class Employee package spel.package24; public class Employee { private Integer id; private String name; private int salary; public Employee() { } public Employee(Integer id, String name, int salary) { this.id = id;…… Continue reading Safe navigation operator
autoGrowCollections example
In this post under Spring SpEL, I will show with example the purpose of “autoGrowCollections” configuration. When evaluating a SpEL expression, containing collections, if we try to access an entry which doesn’t exist in collection. We get an exception. Lets say we have the below pojo class Employee package spel.package22; public class Employee { private…… Continue reading autoGrowCollections example
autoGrowNullReferences example
In this post under Spring SpEL, I will show with example the purpose of “autoGrowNullReferences” configuration. When evaluating a SpEL expression, containing chain of property references, if one of the property in the chain is null we get an exception. To prevent that we use the “autoGrowNullReferences” configuration. It’s data type is boolean. By default…… Continue reading autoGrowNullReferences example
Making Java objects available during sqel expression evaluation
In this post under Spring SpEL, I will explain with example how to make java objects available to SpElExpression during its evaluation. For our example we will use the below pojo class Employee package spel.package20; public class Employee { private int id; private String name; private int salary; public Employee(int id, String name, int salary)…… Continue reading Making Java objects available during sqel expression evaluation