Docker for Java Developers: Test on Docker

1. Introduction If we think about the areas of software engineering where the impact of the Docker and container-based virtualization is most noticeable, testing and test automation is certainly one of those. As the software systems become more and more complex, so do the software stacks they are built upon, with many moving parts involved. In this section of the ...

Read More »

Converting Collections to Maps with JDK 8

I have run into the situation several times where it is desirable to store multiple objects in a Map instead of a Set or List because there are some advantages from using a Map of unique identifying information to the objects. Java 8 has made this translation easier than ever with streams and the Collectors.toMap(…) methods. One situation in which ...

Read More »

Spring, Reactor and ElasticSearch: bechmarking with fake test data

spring-interview-questions-answers

In the previous article we created a simple adapter from ElasticSearch’s API to Reactor’s Mono, that looks like this: import reactor.core.publisher.Mono; private Mono indexDoc(Doc doc) { //... } Now we would like to run this method at controlled concurrency level, millions of times. Basically, we want to see how our indexing code behaves under load, benchmark it. Fake data with jFairy First, we ...

Read More »

Spring, Reactor and ElasticSearch: from callbacks to reactive streams

spring-interview-questions-answers

Spring 5 (and Boot 2, when it arrives in a couple of weeks) is a revolution. Not the “annotations over XML” or “Java classes over annotations” type of revolution. It’s truly a revolutionary framework that enables writing a brand new class of applications. Over the recent years, I became a little bit intimidated by this framework. “Spring Cloud being framework that ...

Read More »

Reactive Web Applications Using SpringWebFlux

spring-interview-questions-answers

1. Introduction to Reactive Programming Reactive programming is a term coined for the applications that has the following characteristics: Non-blocking applications Event-driven and asynchronous Require a small number of threads to scale vertically (i.e. within the JVM) Just like object-oriented programming, functional programming, or procedural programming, reactive programming is just another programming paradigm. It makes our program: Responsive, Resilient, Elastic. ...

Read More »

Java Reflection, but much faster

What is the fastest way to read a getter from a Java class without knowing the class at compilation time? Java frameworks often do this. A lot. And it can directly influence their performance. So let’s benchmark different approaches, such as reflection, method handles and code generation. The use case Presume we have a simple Person class with a name ...

Read More »

The Highly Useful Java ChronoUnit Enum

Several years ago, I published the blog post “The Highly Useful Java TimeUnit Enum” that looked at the TimeUnit enum introduced with JDK 5. JDK 8 introduced a newer enum, ChronoUnit, that is better suited than TimeUnit for contexts other than concurrency such as date/time manipulations. Located in the java.time.temporal package, the ChronoUnit class implements the TemporalUnit interface, an interface ...

Read More »

Bootstrap CDI 2.0 in Java SE

Abstract This is a quick reference for bootstrapping CDI 2.0 in a Java SE application. CDI 2.0 (JSR 365) Maven Dependency <dependency> <groupId>org.jboss.weld.se</groupId> <artifactId>weld-se-core</artifactId> <version>3.0.2.Final</version> </dependency> beans.xml File location is /META-INF/beans.xml. This file is optional, though I’ve found it’s still good to have. <beans version="2.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" bean-discovery-mode="all" > <scan> <exclude name="org.jboss.weld.**" /> </scan> </beans> Java SE ...

Read More »

Java 9 Module Services

Wiring and Finding Java has a ServiceLoader class for long time. It was introduced in 1.6 but a similar technology was in use since around Java 1.2. Some software components used it, but the use was not widespread. It can be used to modularize the application (even more) and to provide a mean to extend an application using some kind ...

Read More »