eclipse, Java, REST, Spring, Spring Boot

Bypass SSL certification with Spring RestTemplate

Recently I wanted to try out a REST call on my local computer, running my microservice locally. The service calls another microservice, in the SIT environment, that required secure HTTP s connection. As I did not have the certificate installed on my workstation, but wanted to fast test the call anyway, I had to find… Continue reading Bypass SSL certification with Spring RestTemplate

Advertisement
Java, JPA, Spring, Spring Data

Create and modification date with Spring Data

Using created and last modified fields for an entity is considered general pattern and a good practice. It provides you the information about what and when happens in your database, therefore makes your life easier when the time of problem solving comes. As we love to automatize such boring tasks, using Hibernate it is common to… Continue reading Create and modification date with Spring Data

Docker, Java, Spring, Spring Boot

Using Docker in your development process

Recently I finished the Docker for Java Developers course from Spring Guru on Udemy. My goal was to learn and understand Docker so far, that I should be able to use it in my development and learning process. start a database for development and test purposes locally. Docker makes it possible to spare the installation process,… Continue reading Using Docker in your development process

Java, Spring, Spring Boot

Add your own Grafana metrics

Grafana is a great tool to visualize operational information regarding of a running service. Recently I implemented a function, that continuously sends information to the Influx database that backs our Grafana server.  It provides information about the number of clients, currently connected to our Spring Boot service, via WebSocket. As in the simplest case you… Continue reading Add your own Grafana metrics

Java, Spring, Spring Boot, Websocket

Using Spring Security with Websocket

  If you have a Spring Boot application, that already uses Spring Security, it can be tricky to set up the security for Websocket communication. The problem is, that in case of you need to protect your resources with basic authentication, it avoids the connection to your Websocket service, while Websocket can not work together… Continue reading Using Spring Security with Websocket

Java, Spring

My favorite Lombok features

I use the Lombok project with a great pleasure. It makes it easier to create a nice code without boilerplate code. My favorite features @Data Maybe the most used annotation. Generates all boilerplate code for a domain object. Getters, setters, equals, hashcode, toString. It is a very good feature to start with. You will never… Continue reading My favorite Lombok features

Java, Spring, Websocket

Restrict number of connected clients for Websocket

Recently I needed to implement a custom check for WebSocket connection of a Spring Boot application. The logic had to check if a configured connection limit has been reached, and reject opening further connections if so. The connections were opened by a mobile application client, and the developer wanted to get the error message in… Continue reading Restrict number of connected clients for Websocket

Java, Spring, Spring Boot

Setting up MDC context with AOP in Spring Boot application

In order to be able to analyse logs of complex processes for your application, it is useful to use Mapped Diagnostic Context (MDC) and put some process specific information into it. Currently I am implementing a Spring Boot application, with several services, and lots of calls between them. As there is a huge number of… Continue reading Setting up MDC context with AOP in Spring Boot application

Java, JUnit, Mockito, Unit test

Checking parameter of a mocked method call with Mockito

If you are using Mockito, it is sometimes useful to check the parameter state of a method passed to a mocked method call. I use it in the following cases DAO method, like create or update is called in the code. I  want to check, if the entity has been set correctly before writing into… Continue reading Checking parameter of a mocked method call with Mockito

Design pattern, Java, Spring

Using prototype in Spring singleton service

I wanted to use a Spring bean, with private fields in order to build an object. Previously the builder class was really as an example of the builder pattern implemented. It was able to build the required object based on the parameters, defined for the builder. Later on, after the requirement changed, the builder had… Continue reading Using prototype in Spring singleton service