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)

Configuring Custom BackOff Policy for RetryTemplate (using RetryTemplateBuilder)

Hi everybody, in this post under Spring Retry I will show you with example how to configure custom BackOff policy using RetryTemplateBuilder. For the example we will use the below service class Service1 class public class Service1 { private int i = 0; private int j = 0; public void executeWithException() { i = i…… Continue reading Configuring Custom BackOff Policy for RetryTemplate (using RetryTemplateBuilder)

Configuring Custom Retry Policy for RetryTemplate (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure your own custom Retry Policy using RetryTemplateBuilder class. For this example, we will use modified version of Spring’s MaxAttemptsRetryPolicy, as shown below CustomMaxAttemptsRetryPolicy import org.springframework.retry.RetryContext; import org.springframework.retry.policy.MaxAttemptsRetryPolicy; public class CustomMaxAttemptsRetryPolicy extends MaxAttemptsRetryPolicy { private String name; public CustomMaxAttemptsRetryPolicy(String name) { this.name…… Continue reading Configuring Custom Retry Policy for RetryTemplate (using RetryTemplateBuilder)

Configuring ExponentialBackOffPolicy for RetryTemplate (using RetryTemplateBuilder)

In this post under Spring Retry, I will show with example how to configure ExponentialBackOffPolicy using RetryTemplateBuilder. First lets recap what is ExponentialBackOffPolicy is. ExponentialBackOffPolicy increases the backoff period at every retry attempt by a specified number. ExponentialBackOffPolicy requires three inputs for it to work, which are1) initialInterval –> the backoff period used at first…… Continue reading Configuring ExponentialBackOffPolicy for RetryTemplate (using RetryTemplateBuilder)