25 Jun 2020
Host multiple Web sites from one S3 bucket using one CloudFront distribution
Here’s how you can host multiple Web sites with custom domain names from a single S3 bucket using a single CloudFront distribution. For example: x.foo.com > My CloudFront Distribution > s3://my-bucket/x.foo.com y.foo.com > My Cloud...
06 Jul 2019
Hello World
Hello World. This is the first post since I decided to cancel my Wordpress blog. This new blog solution is hosted on GitHub and generated with Jekyll. I hope that I get the time to import my old blog posts over the next weeks.
08 Sep 2018
Spring: Ignoring mocks
If you are using the core Spring Framework (that is, not Spring Boot), then you may have encountered a problem where Spring doesn’t seem to completely ignore mocked beans in your tests: Perhaps Spring attempts to inject beans into them or run your...
24 Jul 2017
Spring 4.3: Using a TaskDecorator to copy MDC data to @Async threads
In this post I am going to show how to copy MDC data from Web threads to @Async threads using a brand new Spring Framework 4.3 feature: ThreadPoolTaskExecutor#setTaskDecorator() [set-task-decorator]. This is the end result: Notice the third an...
26 Mar 2017
Kotlin: Understanding properties
In this post I am going to look into Kotlin properties [1] from a Java developers perspective. By a few examples and by looking into the generated code. I have created an example project on GitHub. You will find a few examples of how to declare p...
19 Mar 2017
Spring Boot: A bit more cool with Kotlin
In the context of my favorite framework, Spring Boot, I have recently started to explore the effect of using the Kotlin 1.1 programming language (as an alternative to Java 8). This post describes a few language features that may be interesting to ...
16 Mar 2017
Java EE: Hello World, Kotlin
Are you a savvy Java EE 7 application developer? My bet is then, that you are using Java 7/8 for developing your favorite components (EJBs, CDI beans etc). In this post I am going to show how you can develop a Java EE 7 application using Kotlin 1....
12 Mar 2017
Spring Boot: Hello World, Kotlin
In this post I show how you can create a Spring Boot 1.5 application using Kotlin 1.1 (as opposed to typically Java 8 in these times). The example I’ve created is a typical “Hello World” example. I have chosen to implement a Spring MVC controller...
06 Feb 2017
Spring Boot: Prometheus actuator endpoint
In this post I show how you can add support for Prometheus in Spring Boot applications. Step 1 of 2: Add the Prometheus Spring Boot Starter You can get Prometheus support in Spring Boot applications via a so-called “starter”. Here is how to get t...
09 Nov 2016
Spring Boot: Controlling timezones with Hibernate
In this post I show how you, from a Spring Boot application, can control the timezone used by Hibernate when it communicates timestamps with the database. This post is inspired by a very similar recent post by Vlad Mihalcea [1], Hibernate Develope...
23 Oct 2016
Spring: Bean qualification
In this post I present how you can control a situation in which there are multiple beans that qualifies for an injection point in Spring. The material here has been tested with Spring Framework 4.3. The problem Let’s first take a look at the pro...
22 Oct 2016
Spring Boot and Gradle: Separating tests
In this post I will present 4 different approaches to separating unit tests from integration tests, so that they can be run independently of each other. Here’s the 4 different approaches: Separation based on name patterns Separation based on...
15 Oct 2016
Spring Boot: Gherkin tests
In this post I show how you can implement Gherkin tests for Spring Boot 1.4.1. Here is an example of a Gherkin based test script: The Feature, Scenario, Scenario Outline, Given, When, Then and And constructs are part of the Gherkin test languag...
15 Oct 2016
Spring 4.3: Custom annotations
In this post I will show you how to bend the Spring Framework a little bit. In particular I will show you how you can make code like this: 1 2 3 4 5 6 7 8 9 10 11 @BusinessService public class GreeterService { @LocalizedMessage("greeterservice...
09 Oct 2016
Spring 4.3: Introducing the InjectionPoint class
Did you know that Spring Framework 4.3 comes with a ”hidden” gem: the InjectionPoint class? At the time of writing this post, InjectionPoint is nowhere to be found in the Spring Framework Reference Documentation [2]. About the InjectionPoint cla...
30 Aug 2016
Java: Custom logger factory that automatically infers the class name
In this post I show how you can declare loggers like this: 1 2 3 public class MyService { private static final Logger LOG = MyLoggerFactory.getLogger(); } There is no argument to the MyLoggerFactory::getLogger method. Contrast that to the n...
24 Aug 2016
Spring Boot: Show all logging events for one Web request only
In this post I show how you for a single Web request can make your Spring Boot application dump all log statements on all categories (TRACE, DEBUG, INFO, WARN, ERROR). Everything - but only for the specific Web request that you care about. I show ...
22 Aug 2016
Spring Boot: Sessions actuator endpoint
This post shows how you can implement a custom Spring Boot Actuator endpoint that prints information about all active HttpSessions: HttpSession meta data is prefixed with @ signs: id, creation time and last accessed time. The other values are a...
18 Aug 2016
Spring Boot: Introduce your own insight endpoints
In this post I show how you can develop custom Spring Boot Actuator HTTP endpoints for obtaining detailed insight into your Spring Boot application’s runtime behavior. Here’s an example: The above output is simple. Yet it can be useful to have...
16 Aug 2016
Spring Boot: Enhance your thread dumps
In this post I show how you can add extra information to your applications’ thread dumps. I will use Spring Boot as an example environment - but the idea is very generic: You can, for example, easily apply this technique to any other Java EE appl...
16 Aug 2016
Spring Boot: Enhance your logging
In this post I show how you can tune your Spring Boot application’s logging output - such that it has even more information when you need to troubleshoot. The method is actually so generic that you can apply it to other types of Java applications ...
14 Aug 2016
Spring Boot: Custom auto-configuration JARs
Custom auto-configuration JAR: A shared JAR module containing Spring beans that can be automatically activated in one or more Spring Boot applications. Auto-configuration JARs are extensively used by the official Spring Boot starter modules you a...
12 Aug 2016
Spring Boot: UI for the dump endpoint
I am really happy with the actuator functionality in Spring Boot applications. It offers some fantastic tools for gaining insight into your application. Some of the REST endpoints that you get - such as health and metrics - are easy to read. Despi...
12 Aug 2016
Arquillian: Testing legacy applications
This post describes a technique that my previous colleagues and I successfully used for integration testing a large and complex legacy Java EE 7 application (EAR file). The tests were successfully implemented using Arquillian along with a few Wild...
10 Aug 2016
Spring 5: Gets reactive
Spring 5 is going to include support for the reactive programming model [1]. Here’s an example: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import org.springframework.http.MediaType; import org.springframework.http.client.reactive.R...