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
Month: April 2024
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
RepeatCharactersRule example
In this post under Passy, I will explain with example, the purpose of “RepeatCharactersRule” class. Sometimes user entered password will have “n” characters (i.e., number of characters) with each character being repeated equal to or more than “m” times. For example in case of this password “11a22b333xyz”1) n is 3 which are 1, 2, and…… Continue reading RepeatCharactersRule example
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
Spring @Order annotation
In this post under Spring Core, I will explain with example the purpose of “@Order” annotation. In one of my previous posts under Spring Core, I have explained how to autowire collections, array, and map. For the purpose of recap, lets assume we have a class “Dao” which we want to inject in class “Example22″…… Continue reading Spring @Order annotation
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 map
In this post under Spring Core, I will show with example how to autowire a map. For this example I will use the below “Dao” class Dao class package package23; public class Dao { } Below is the main class that shows how to autowire a map Main class 1 package package23; 2 3 import…… Continue reading Autowiring a map
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