Configuring RetryListener (using annotations)

In this post under Spring Retry, I will show with example how to configure RetryListener using annotations. For our example we will need the below “CustomRetryListener2” class CustomRetryListener2 import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; import org.springframework.retry.RetryListener; import org.springframework.stereotype.Component; @Component public class CustomRetryListener2 implements RetryListener { @Override public <T, E extends Throwable> void close(RetryContext arg0, RetryCallback<T, E> arg1,…… Continue reading Configuring RetryListener (using annotations)

Validating html documents against whitelist of html attributes

In one of my previous posts under Jsoup, I showed how to verify html documents against a whitelist of html tags. In this post I will show how to verify html documents against a whitelist of html attributes along with whitelist of html tags. Below is the complete main code for your reference Main class…… Continue reading Validating html documents against whitelist of html attributes

Getting all html elements in a document

In this post under Jsoup, I will show with example how to get a list of all html elements in a document. Below is the main class Main Class 1 import java.io.File; 2 import java.io.IOException; 3 import java.util.Iterator; 4 5 import org.jsoup.Jsoup; 6 import org.jsoup.nodes.Document; 7 import org.jsoup.nodes.Element; 8 import org.jsoup.select.Elements; 9 10 public class…… Continue reading Getting all html elements in a document

Spring Retry traversingCauses example (using RetryTemplateBuilder)

In my previous post under Spring Retry, I showed with example how to retry failed operations only for specific exceptions. So for example if we configure Spring Retry (as shown in the below code) to retry only when NullPointerException is thrown Code snippet 1 RetryTemplateBuilder retryTemplateBuilder = RetryTemplate.builder(); retryTemplateBuilder.retryOn(NullPointerException.class) Spring Retry will retry the failed…… Continue reading Spring Retry traversingCauses example (using RetryTemplateBuilder)

Spring Retry only for specific exceptions (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure Spring Retry to retry failed operations for specific exception only using RetryTemplateBuilder. For our example, we will use the below Service class Service Class import java.util.NoSuchElementException; public class Service4 { private int i = 0; private int j = 0; private…… Continue reading Spring Retry only for specific exceptions (using RetryTemplateBuilder)