Micronaut Dependency Injection - The stand-alone Setup

In this post, let's explore how to use Micronaut as the Dependency Injection container in a stand-alone Java application. Let's start by creating a stand-alone Java application. I make use of the initialisers provided by Gradle (gradle init command). The application structure looks as follows. ➜ microdemo tree . ├── build.gradle ├── gradle…

Groovy Scripts - Reusable Code

Let's start with the following Groovy script which reads and prints all the properties from a file. import java.nio.file.Path Properties loadProperties() { Properties properties = new Properties() Path propertyFilePath = Path.of('my.properties') propertyFilePath.withInputStream { properties.load(it) } properties } Properties properties = loadProperties() properties.each { println it } The script needs…

Continuous Delivery vs Continuous Deployment

There is a good chance that you would have had several debates on what is the difference between 'Continuous delivery' and 'Continuous Deployment'. I have spent several hours discussing this with different groups. Usually, 'Continuous Delivery' implies keeping your software in the releasable state for every commit so that you…

Effective Java with Groovy - Immutability

It would seem like mutability is the default design approach when it comes to Java. However, reading "Effective Java" makes you change your mind. The book suggests - 'minimise mutability'. Also, what is highly useful is the reason for favouring immutability - "immutability is simple". Did you get surprised? Now,…

Micronaut as Dependency Injection Provider

If you are already familiar with Micronaut, most probably you know it as a framework for developing microservices-based applications. Micronaut support JVM languages Groovy and Kotlin in addition to Java. One of the less known facts about Micronaut is that it can also be used as a dependency injection capability…

Effective Java with Groovy - The (in)famous null

If you have seen some of the enterprise applications written in Java, you know the amount of code goes into performing null checks. The 'null reference' feature of Java for sure is the #1 contributor to employment generation. The creator of null reference has already admitted that it was a…

Java - end of the road for Paths

Java introduced NIO 2 APIs with version 1.7. I wrote an article several years ago, after seeing not many developers make use of the new API. With this API, you would use java.nio.file.Path instead of java.io.File to represent a file. To get an instance…

Micronaut HTTP Client - Error Flow

We have seen Micronaut BlockingHttpClient in action and how to use exchange and retrieve methods to interact with an HTTP endpoint. What happens if your endpoint returns HTTP status code greater than or equal to 400 (they indicate that it's an error)? To explore this, let's create an endpoint that…

Groovy Scripts - Exploring Binding

In a previous post exploring scripting basics, we saw how binding was used to supply command-line arguments to scripts. In this post, let's explore the design of binding further. class BindingDemo { static void main(String[] args) { Binding sampleBinding = new Binding() println sampleBinding.variables sampleBinding.message = "Hello" println sampleBinding.variables println…