Java articles

Primary key strategies in Hibernate

Almost every time we use auto increment keys (or serial in PostgreSQL). But Hibernate allows three more choices to handle primary key generation of entity objects. This article will show it.

Continue Reading →

Design patterns in Spring Framework - part 3

In two previous articles we saw some of design patterns implemented in Spring framework. This time we'll discover 3 new patterns used by this popular framework.

Continue Reading →

Design patterns in Spring Framework - part 2

The last time we talked about design patterns in Spring, we discovered 3 creational and 1 behavioral patterns. This time we'll focus more on structural and behavioral ones.

Continue Reading →

Session crawler valve in Tomcat

When a website is liked by search engine crawlers, it has more chances to be liked (or only known) by real users. However, some server configurations doesn't work well with crawlers activity. And it's the case of Tomcat 7 and its sessions. But one solution exists - crawler session manager valve.

Continue Reading →

Completion service in Java

Producer-consumer services can be very quickly realized with native Java features. One of them, arrived with the 7th version of Java, is CompletionService.

Continue Reading →

Objects locking

Synchronized blocks are only one of methods to handle concurrent access to Java's objects. Another one are the implementation of classes included in java.util.concurrent.locks package.

Continue Reading →

Introduction to Spring Integration

Spring integration is a Spring-family project illustrating well the idea of enterprise integration patterns. To understand better this Spring project, we'll write some test cases to show how they work. This article will introduce the basic concepts of Spring Integration.

Continue Reading →

Design patterns in Spring Framework - part 1

Design patterns help to follow good practices of programming. Spring framework, as one of the most popular web frameworks, also uses some of them.

Continue Reading →

Properties placeholder in Spring Framework

Sometimes you will need to share properties values through multiple configuration files. They can, for example, have the same authentication information about database user, but, they can use different databases. In Spring we can resolve this problem with properties placeholders.

Continue Reading →

Events and listeners in Spring Framework

Events, and generally callback idea, are very popular in technologies associated to GUI (JavaScript, Swing). On the server side of web applications they're less popular. However it doesn't mean that we can't implement one event-oriented architecture on it. Above all when we're working with Spring.

Continue Reading →

Handling annotations with Spring AnnotationUtils

Annotations in Java let us, programmers, to transfer some of configuration from configuration files into Java classes. For example, in Spring, we can configure URL mapping directly inside the controllers thanks to @RequestMapping annotation. But it couldn't be possible without several utilitary classes, like AnnotationUtils, described here.

Continue Reading →

Google Guava : concurrency

Google Guava as a set of libraries used in Google projects couldn't not contain some worries about concurrency.

Continue Reading →

Google Guava : String utilitary classes

One of most "speaking" objects in Java is String. However, to achieve some operations we need to implement own methods. With Google Guava String support, operations on chain of characters are easier.

Continue Reading →

Hibernate with JPA

In the previous articles we were working with Hibernate's specific elements as Session or SessionFactory. But they are not the only possible choices. We can too opt for working with Hibernate's implementation of JPA specification.

Continue Reading →

Batch processing in Hibernate

When multiple operations must be processed at once, it's better to do it automatically. This type of operations is called batch (do not confuse with bash which is a command language).

Continue Reading →

Object monitor pattern

Classes synchronization in Java multi-threading environment can be done thanks to many classes from java.util.concurrent package. But it can also be achieved thanks to some traditional methods, as monitors.

Continue Reading →

Java memory model

In multi-threading languages as Java, a memory model is mandatory to be able to determine correctly code behavior on concurrent tasks execution.

Continue Reading →

@With annotation in Play Framework

If you're following well the article about authentication and authorization in Play Framework, you could see that @Authorize annotation is accompanied by another annotation, @With. Thanks to it, the @Authorized is evaluated with the class specified inside @With annotation.

Continue Reading →

Bean post processors in Spring

We've already discovered the bean post processor factory in Spring. However, they left one similar concept to explain, bean post processors.

Continue Reading →

Bean factory post processors in Spring

Spring allows us to make a lot of operations with beans. We can decide if they should be unique instance on container (singleton) or not (prototype). We can also make some of operations "in the fly", thanks to bean factory post processors.

Continue Reading →