Skip to main content


Showing posts from October, 2009

My first open source contribution

Few days ago popular Apache Commons Lang library gained new utility method in Validate class: notBlank(). This also happens to be my first contribution to the open source community (see: LANG-533 and commit 828310). Use notBlank when you want to check whether the given string is not null, not empty, and does contain anything apart from whitespaces:

Validate.notBlank(" a ");
Validate.notBlank(null); //will throw IllegalArgumentException
Validate.notBlank(""); //will throw IllegalArgumentException
Validate.notBlank(" ", "Should not be blank"); //will throw IllegalArgumentException
Validate.notBlank(" \n "); //will throw IllegalArgumentException

This handy method can be used to validate user input or configuration, where single space or newline characters should also be treated as invalid. It will be available in version 3.0 of Lang library.

I know this contribution is so tiny and n…

Compile- vs load-time weaving performance in Spring

Yesterday I had pleasure to participate in Java Developers’ Day in Kraków, Poland. It was a great experience to see Mark Richards (author of Java Message Service) and Scott Davis (Groovy Recipes) giving a talk. Also I really enjoyed Wojciech Seliga speak about code review. He works for Atlassian and shown a bit of Crucible, but his main point was that code review is not about looking for bugs made by other developers. It is rather an agile process of getting to know the code.

I could write much more about JDD, of course starting from "you should regret if you haven’t been there", but I am quite sure that you are already waiting for the main topic. Let’s just say, that there is a chance that JDD will take 2 days in the next year and I will do my best to be there.

After reading my previous post one of my friends asked about performance of creating objects marked as @Configurable. He wants to inject EntityManager or other custom dependencies to his JPA POJOs but is concerned abou…

DDD in Spring made easy with AspectJ

UPDATE: Over the years I learnt that the solution provided below is not really an example of domain-driven design. It's more like an active record implementation on top of Spring. But the technical part of the article is still relevant, so I keep it intact. Before I start the main topic, I would like you to think for a while about the best JEE application design you can imagine. No matter you use Spring or EJB3, as they are very similar, probably you would suggest similar approach. Starting from the back you have:

domain objects, which are simple POJOs mapped directly to database relations. POJOs are great because JavaBean-style properties are well understood be many frameworks. data access layer – typically stateless services, which wrap up database access code (JDBC, Hibernate, JPA, iBatis or whatever you want) hiding its complexity and providing some level of (leaky) abstraction. DAOs are great because they hide nasty and awkward JDBC logic (that is why some question the need f…