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
Author: sumanthprabhakar
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
CollectionUtils getCardinalityMap method
In this post under Apache Collections, I will explain with example, the purpose of CollectionUtils “getCardinalityMap” method. This method takes a collection as an argument and returns a map. A map where key is an element from the collection, and value will be the number of times the element is repeated in the collection. So…… Continue reading CollectionUtils getCardinalityMap method
CollectionUtils intersection method
In this post under Apache Collections, I will explain with example the purpose of CollectionUtils “intersection” method. The “intersection” method compares two collections and return a new list containing items that are common in both of them. Below is the complete main code for your reference. Main class 1 package defaultPackage; 2 3 import org.apache.commons.collections4.CollectionUtils;…… Continue reading CollectionUtils intersection method
“required” attribute of @Autowired annotation
In this post under Spring Core, I will explain with example the purpose of “required” attribute of “@Autowired” annotation. When we tell Spring framework to wire two beans say “Bean2” to “Bean1” as shown below package package20;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Component;@Componentpublic class Bean1 { @Autowired private Bean2 bean2; public Bean2 getBean2() { return bean2; } public void…… Continue reading “required” attribute of @Autowired annotation