Home > Articles > Programming > Java

Nonlinear Code Management in EJB3

  • Print
  • + Share This
Are you trying to get your EJB3 project on wheels? Having problems getting your interceptor logic working? If so, then look no further! Stephen B. Morris walks you through a working EJB3 example in conjunction with interceptors, all running on JBoss 5.
Like this article? We recommend

Loose Coupling and Cross-Cutting Concerns

If there's one core theme that dominates modern software, it has to be loose coupling! Gone are the single-vendor days of monolithic software. A key concern now is the ability to mix-and-match vendors; that is, use a database product from vendor X and an application server from vendor Y in conjunction with a pile of open source products. The achievement of this level of loose coupling is praiseworthy, though it perhaps isn't always as smooth as it might be.

The difficulty is the large number of separate and distinct organizations involved. For example, if I write a piece of software that runs on JBoss 4, I might expect this same code to run on JBoss 5. Not an unreasonable expectation, I hear you thinking. However, if I also decide to upgrade my JDK, it's entirely likely that a Java package may have been renamed. This has the effect of requiring me to modify and recompile my Java code. Portable it isn't!

However, this issue of migration is generally one that isn't taken lightly by end users. A change of application server (or some similar environment change, such as a database upgrade) is generally considered what might be called a "forklift upgrade"—an upgrade that's treated as a mini project in its own right. So the intention of loose coupling is excellent, but the execution may not be without challenges.

Another important and related topic is that of cross-cutting concerns. I've written a number of articles about this issue, and it's also highly relevant in the context of EJB3. In fact, EJB3's interesting interceptor mechanism is the topic of this article.

Cross-cutting concerns are those macroscopic features that affect your application as a whole; for example, security, data translation, vendor-specific feature support, and so on. Rather than being one component part of your code, cross-cutting concerns may affect your entire application code, without necessarily being a part of it. You might say that a cross-cutting concern is part of everything and part of nothing.

In this context, a cross-cutting concern is a nonlinear code element. Interceptor technology provides a compelling reason to do more with your cross-cutting concerns in a less intrusive fashion.

  • + Share This
  • 🔖 Save To Your Account