Posts

How to Create Custom Namespaces and Handlers in Spring

Image
Custom namespaces in spring are a way to replace the complex bean definitions with a more user-friendly configuration. Spring itself provides several namespaces out of the box. e.g.

Localization with Spring

Image
Localization enables applications to cater to users of different locations and languages. Spring, as usual, has support for this aspect as well. Before jumping into what Spring has to offer, let's explore what we get from Java itself.

Spring Boot - How to Create a Deployable War

Image
Spring boot , by default, enables you to create standalone applications through simple, minimal configurations. And due to its self-contained nature, it naturally enables building microservices. Spring starters are poms (if using maven) that

Spring Cache - Part 5 - CacheEvict

Image
In the Spring Cache series so far ( Part1 , Part2 , Part3 , Part4 ), we have seen examples where the data is getting added to the cache through the use of @Cacheable and @CachePut . But, what about removing data from cache? Consider a call to delete the record from Service or DB, in which case, we would also want to delete that record from the cache.

Deep Copy Java Objects through Serialization

When it comes to deep copy or cloning an object, the first thing that comes to mind is to override the clone() method and set each field manually. This can be pretty cumbersome to implement for complex objects or if you have to do this for a lot of them.

Spring Cache - Part 1 - Introduction

Image
Caching is an extremely important aspect of applications that care about lower latencies. There are a multitude of rules one has to adhere to while setting up a cache, in order to optimize the performance; but not overdo it. We will not get into those details in this post. Our focus would be on what Spring provides to enable caching in your applications.

JSON Property Name Customization in Jackson using PropertyNamingStrategy

Image
Jackson is one of the most popular java libraries for serialization/deserialization of POJOs to/from JSON. By default, Jackson derives the JSON element names from the getter/setter method names of the POJO. e.g. getActorName() is translated to actorName in the resulting JSON.

How to Timeout JDBC Queries

Image
JDBC queries by default do not have any timeout, which means that a query can block the thread for an unlimited amount time; of course, depending upon the DB load and the cost of the query. It is a good practice to timeout these queries if they can take longer than a certain amount of time.