Monitor Wicket page request using JAMon

For the Wicket webapplication I am currently working on, we build in JAMon for real time performance monitoring. As usual we intercept all calls to objects like Repositories and Services to monitor their performance. Because we use Spring we can easily intercept these Spring managed objects using Spring AOP. Besides these statistics we are also interested how long a certain page request takes. Since the Wicket components are not Spring managed we can not use Spring AOP. In this blog I´ll explain how you can put in JAMon monitoring for these page requests.

Read more →

Standarize on Java platform rather than Java language

In most organizations you often have the restriction that software needs to be implemented in one language (in our case Java). I think this is often based on certain assumptions like: "It saves money because the employees do not have to learn more than one language." or "We have invested a lot of money in these expensive commercial Application Servers and are afraid to loose our investments."

Although these arguments are valid at some point, I think standardizing on language is outdated.
Read more →

Wicket is.... Wicked!

Since a couple of weeks me and some colleagues are working on a project in which need to produce a fancy and flashy website. To achieve this we are teamed up with some html/css experts from lostboys. As we did not want to temper with the html code the lost boys (and girls) produce, our colleague Okke Harsta proposed wicket as web framework. This is the first time I ever used wicket and I must say I am amazed by how easy and natural it is to work with. We can leave all the html code to the specialists and only need to produce the Java code, which basically feels like programming Swing. I could give all kinds of examples in this blog on how easy wicket is in for instance adding Ajax behavior, but I think it better that you check it out yourself. I highly recommend you put it on top of your which-web-framework-do-I-need-to-choose-for-my-new-project list.

How to wire your FitNesse fixtures with Spring

For testing my applications I like to use FitNesse and for writing my applications I tend to use Spring a lot. Since there is no way in FitNesse to override the mechanism how the Fixtures are instantiated you need to somehow load the Spring context and get the beans you want to test from the Spring context. You can of course do this by hand and retrieve the beans from the application context, but this kind of clutters your fixture code. Better is to let Spring take care of the wiring.
Read more →

Keep your implementations hidden

Most Java applications I have worked on the last years embraced the "Program to Interfaces" principle. The name is rather self explanatory so I won't go into detail in the principle. As interfaces by itself are quite useless we need to have at least one implementation. In a typical application this is done by a defining a class such as:

public class JbcAddressDao implements AddressDao {
}

Nothing wrong here one might say, but I think that this code is in conflict with one of the main aspects of Object Orientation.
Read more →

Please close the resource behind you.

How to close resources is not rocket science. But still I see in many projects, including my own, that resources are not properly closed. Most of the time people tend to forget to close the resources in a finally block or forget that closing a resource might also throw an Exception what may cause Exception swallowing.
In Java 5 the Closable interface was introduced which enables some convenient ways to handle closing resources.

Let's take a look at an example that I will use throughout this blog to show what problems can occur when handling resources and how we can refactor the sample code so that it safely closes the used resource.

Read more →

out-of-the-box.... ?!?

Ah Monday morning, fresh start of the week. Today I am going to deploy the new version of our business process that we modeled using JBPM. Luckily JBPM provides a starter kit that enables you to deploy your process definitions. The readme promises me an out-of-the-box experience:

The enterprise archive can be deployed on JBoss out-of-the-box.

Let's see if my definition of out-of-the-box is the same as the JBoss one.
Read more →

Transactional unit test over multiple datasources

Recently I needed to write an integration test that covered a transaction over multiple SessionFactories and different datasources. I wanted it to be an outside-the-container-test and therefor I needed some ability to do transactions over multiple datasources without all the stuff a J2EE container would provide.
A good start for writing transactional tests can be found, as usual, in Spring. All you need to do is to extend the AbstractTransactionSpringContextTests class and the rest is a piece of cake. Now the question is how to wire this up for multiple datasources?

Read more →