Spring @Primary annotation

In this post under Spring Core, I will explain with example the purpose of “@Primary” annotation. When doing autowiring by type, there may be scenarios where two bean definitions can be considered for injection. For example if we have below DAO class package package26; public class Dao { private String daoName; public Dao(String daoName) {…… Continue reading Spring @Primary annotation

InitialDirContext lookup method

In this post under Java LDAP, I will show how to lookup for an entry in LDAP directory tree using ldap distinguished name. Below is the complete main class for your reference Main class 1 package package2; 2 3 import java.util.Hashtable; 4 5 import javax.naming.Context; 6 import javax.naming.NamingException; 7 import javax.naming.directory.DirContext; 8 import javax.naming.directory.InitialDirContext; 9…… Continue reading InitialDirContext lookup method

Connecting to LDAP server

In this post under Java LDAP, I will explain how to connect to LDAP server with an example. Below is the complete code Main Code 1 import java.util.Hashtable; 2 3 import javax.naming.Context; 4 import javax.naming.NamingException; 5 import javax.naming.directory.DirContext; 6 import javax.naming.directory.InitialDirContext; 7 8 public class LDAPDemo1 { 9 public static void main(String[] args) { 10…… Continue reading Connecting to LDAP server

NumberRangeRule example

In this post under Passay, I will explain with example the purpose of “NumberRangeRule” class. NumberRangeRule takes a range of numbers and verifies whether the user entered password doesn’t contain numbers in that range. So “NumberRangeRule” constructor takes two arguments1) starting number (inclusive)2) ending number (exclusive) Below is the complete Main class for your reference…… Continue reading NumberRangeRule example

Autowiring Optional beans

In this post under Spring Core, I will show with example how to use Java’s Optional class to declare a bean (to be injected) as optional. In one of my previous post under Spring Core, I showed you about “required” attribute in “@Autowired” annotation. For recap, “@Autowired” annotation has only one attribute named “required” whose…… Continue reading Autowiring Optional beans

Autowiring a collection and array of beans

In this post under Spring Core, I will explain with example how to autowire a collection and array of beans. For our example I will use the below “Dao” class Dao class package package22; public class Dao { private String daoName; public Dao(String daoName) { this.daoName = daoName; } @Override public String toString() { return…… Continue reading Autowiring a collection and array of beans