Advanced AspectJ part III : non-kinded pointcuts

Today we will focus on non-kinded poincuts of AspectJ.

Unlike kinded pointcuts (method execution, field access, object initialization …), non-kinded pointcuts select join point on some criteria other than the join point signature (no kind). For example it is possible to select join points inside the source code(lexical structure) of a Java class or method.

Read more of this post

Advanced AspectJ Part II : Inter-type declaration

In this article, we discuss about another ApectJ advanced feature: inter-type declaration (ITD), or more commonly called member introduction.

In essence, this feature lets you “inject” new fields or methods into an existing class using an aspect.

With ITD you can for example achieve virtual multiple inheritance or mixin. It is extremely powerfull but also very bug-prone because it somehow breaks basic Java encapsulation rules.

Read more of this post

Advanced AspectJ Part I : Instanciation model

In this serie of articles we’ll talk about advanced features in AspectJ. This will exclude for sure popular AspectJ construct like method execution or within join points.

This first article deals with the instanciation model of AspectJ

As support for our talk, we’ll create a logger injection using annotation and AspectJ.

Read more of this post

ThreadLocal explained

Today we are going to look into the ThreadLocal internals, its usage and all the related pitfalls.

ThreadLocal, among other Java advanced features like volatile variables or nested classes, is rarely used.

The main reason is its relative complexity and mostly the very few cases where ThreadLocal is really required.

Yet, if its underlying mechanism is well understood, ThreadLocal can be very handy in some situations. No wonder it is at the heart of some framework features, Spring
TransactionSynchronizationManager for example.
Read more of this post

JPA/Hibernate Global Conversation with Spring AOP

The previous 2 articles were dedicated to the analysis of Spring @Transactional and @PersistenceContext internals.

In this article we will discuss about the JPA extended persistence context (Hibernate long session) pattern.  We’ll look at the pros and cosn and finally I will show a practical implementation using the TransactionSynchronizationManager class shown earlier in both articles
Read more of this post

Spring @PersistenceContext/@PersistenceUnit explained

This is the 2nd article of a serie on Spring code analysis.

Today we are going to dig into the @PersistenceContext annotation, widely used by JPA/Hibernate developers to inject an Entity Manager into their DAO classes.

Read more of this post

Spring @Transactional explained

Spring is a widely used framework today, bringing many powerfull features and extensions to the Java core stack. However most of people tend to use these features without understanding their underlying mechanism.

Since there is no “magic” in real life, we are going to dig into some Spring features related to Transaction and Database in this serie of articles.

This first article is dealing with the famous @Transactional annotation, saving the developers the burden of managing low level transaction code.
Read more of this post

Java, pass by value/reference or copy of value/reference ?

This basic question is in any Java 101 courses and the answer is quite obvious. But in fact things are a little bit trickier than they seem to be.
Read more of this post

Spring AOP advices on setters not trigged

A few days ago I had to enhance some text value injected into one of my bean


<bean id="myBean">
<property name="featureName" value="${global.properties.feature.name}" />
</bean>

The idea was to modify the injected “feature” value with an @Around AOP poincut:
Read more of this post

Advanced Regular Expressions: part 2 – greedy vs reluctant

In this post we will look at the greedy nature of common quantifiers (* and +).
Read more of this post