Archive for March, 2005

03.30.05

Abstract: Exception Management in J2EE

Posted in Articles, J2EE at 4:18 pm by kkj

Last week I proposed another article to JavaWorld, and got word today that they will accept it for publication. My deadline is June 1st. I plan to extend the last article with exception-handling mechanisms built for Copenhagen County within the scope of the Rampart framework.

Below is what I sent to JavaWorld:

The perpetual debate on exception handling in Java can at best be described as a religious war: On one side you have the proponents of checked exceptions arguing that callers should always deal with error situations arising in code they call. On the other side stand the followers of unchecked exceptions pointing out that checked exceptions clutter the code and often can’t be dealt with in immediate clients anyway, so why force it?

As a junior engineer I first sided with the proselytes of checked exceptions, but over the years and many many catch blocks later I have gradually converted to the order of the unchecked. Why? I have come to believe in a very simple set of rules for dealing with error situations:

1. If it makes sense to handle the exception, do so.
2. If you can’t handle it, throw it.
3. If you can’t throw it, wrap it in an unchecked base exception and then throw it.

But what about those exceptions that bubble all the way to the top, you ask? For those we install a last line of defense to ensure that error messages are always logged, and that the end user is notified in a proper fashion.

This article presents yet another framework for exception handling, which extends the enterprise-wide application session facility I presented in a previous installment. J2EE applications that use this framework will

a) Always present meaningful error messages to end users
b) Log unhandled error situations once and only once
c) Correlate exceptions with unique request IDs in log files for high-precision debugging
d) Have a powerful and extensible, yet simple strategy for exception handling at all tiers

To forge the framework we will wield Aspect Oriented Programming, Design Patterns, and code generation using XDoclet.

03.23.05

Welcome

Posted in Welcome at 11:07 pm by kkj

Like the frail icy crystals that make the curtail of a jet, online postings shine in the moment, then fade and loose their relevance, or disappear altogether in a mist of broken links. This site has sprung to life with the single intent of providing a trail for articles, presentations, general ramblings, and other stuff I’ve managed to force upon an unsuspecting online community.

In other words: this is the official, authoritative, one and only online bookshelf and collected musings of Kåre Kjelstrøm - faded and contemporary.

I’ve made a stab at publishing blog entries for historical content and dated them accordingly. So although this site was ignited on March 23rd 2005 you will find “older” posts as well. Please beware that some content is in Danish.

For details on professional services provided by me and my associates, please refer to The Silverbullets Website.

Disclaimer: The contents of this blog express my personal views of the world and not necessarily those of my clients or colleagues…

03.17.05

Presenting an application-wide user session for J2EE

Posted in J2EE, Presentations at 10:05 am by kkj

Java Erfa Gruppen is a group of IT professionals, working with Java and organized under DANSK IT. A couple of weeks back I was invited to give a presentation on a topic of my own choosing. With the Javaworld article How to create an EAR-wide user session in J2EE still fresh off the digital printing press, it was a natural choice.

The talk was supposed to have lasted for one and a half hours, but speedy Kåre finished in forty-five minutes. Guess I forgot to slow down.

03.14.05

Create an application-wide user session for J2EE

Posted in Articles, J2EE at 10:22 pm by kkj

My recent work with Copenhagen County’s Enterprise Architecture Team led to the definition of a framework for logging, errorhandling, session management and other non-functional aspects of J2EE applications. I was fortunate enough to get an article on the session part accepted by Javaworld, and had it published on March 14th.

Check out the online version of How to create an EAR-wide user session in J2EE at the Javaworld website.

Summary
Despite its comprehensive sets of APIs for writing distributed applications, J2EE does not provide an application-wide session. While Web applications can use the HttpSession facility, this context won’t automatically carry over to Enterprise JavaBeans or J2EE clients. By combining code generation with a mixture of aspect-oriented programming and a hint of design patterns, it is possible to provide such a context across components in an enterprise application and hide most of the complexity from the developer. This article shows you how.