Skip to main content


Showing posts from August, 2010

Creating prototype Spring beans on demand using lookup-method

The strength of the Spring Framework is its emphasis on stateless services. Being totally against OOP, this approach has many pragmatic advantages, with low memory consumption, no cost of pooling and multithreaded safety at the top of the list. But sometimes you really need the context and having non-singleton beans with different state attached to each instance makes your code a lot cleaner and easier to read. Let’s start from stateless code and do some consecutive refactorings.

Every time a new flight is entered into the system, we validate it with multiple business rules using FlightValidator class (please forgive my complete absence of domain knowledge):

public class FlightValidator { @Resource //Many services public boolean validate(Flight flight) { return validateSourceAndTarget(flight) && isAirplaneAvailable(flight) && isAirportFree(flight) && !buyerBlackListed(flight) && reservationLimitReached(flight); } //Many more methods }

There is someth…

Few words after Javarsovia 2010

It is never too late to mention about such a great event like Javarsovia 2010 conference. The conference was really successful, even though I was one of the speakers ;-). If you were near Warsaw on 26th of June and missed the conference I feel really sorry for you. But first things first.

I was really surprised not seeing long queues for the registration, so not wasting a lot of time, equipped with good-looking conference T-shirt, we went to see the first presentation. Tomasz Bujok with his From zero to jBPM hero! lecture did a great job introducing jBPM framework. I have seen quite a few presentations about this engine already, thankfully Tomasz made one step further in the topic and have shown some anti-patterns and other tips for jBPM developers. This was really interesting as anyone, after reading a book or two, can have a "How-to" talk. But having "How-not-to" talk requires knowledge and experience in the technology far beyond the typical tutorial-driven &quo…