Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Add a simple rule engine to your Spring-based applications

Use Spring built-in facilities to capture business logic

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Any nontrivial software project contains a nontrivial amount of so-called business logic. What exactly constitutes business logic is debatable. In the mountains of code produced for a typical software application, bits and pieces here and there actually do the job the software was called for—process orders, control weapons systems, draw pictures, etc. Those bits contrast sharply with others that deal with persistence, logging, transactions, language oddities, framework quirks, and other tidbits of a modern enterprise application.

More often than not, the business logic is deeply intermixed with all those other pieces. When heavy, intrusive frameworks (such as Enterprise JavaBeans) are used, discerning where the business logic ends and framework-inspired code begins becomes especially difficult.

There is one software requirement rarely spelled out in the requirement definition documents yet has the power to make or break any software project: adaptability, the measure of how easy it is to change the software in response to business environment changes.

Modern companies are forced to be quick and flexible, and they want the same from their enterprise software. Business rules that were so painstakingly implemented in your classes' business logic today will become obsolete tomorrow and will need to be changed quickly and accurately. When your code has business logic buried deep inside tons and tons of those other bits, modification will quickly become slow, painful, and error-prone.

No wonder some of the trendiest fields in enterprise software today are rule engines and various business-process-management (BPM) systems. Once you look through the marketing-speak, those tools promise essentially the same thing: the Holy Grail of Business Logic captured in a repository, cleanly separated and existing by itself, ready to be called from any application you may have in your software house.

Though commercial rule engines and BPM systems have many advantages, they also include many shortcomings. The easy one to pick on is the price, which can sometimes easily reach into the seven digits. Another is the lack of practical standardization that continues today in spite of major industry efforts and multiple on-paper standards available. And, as more and more software shops adapt agile, lean, and quick development methodologies, those heavyweight tools find it difficult to fit in.

In this article, we build a simple rule engine that, on one hand, leverages the clear separation of business logic typical for such systems and, on the other hand—because it's piggy-backed on the popular and powerful J2EE framework—doesn't suffer from the complexity and "uncoolness" of the commercial offerings.

Spring time in the J2EE universe

After the complexity of enterprise software became unbearable and the business-logic problem entered the spotlight, the Spring Framework and others like it were born. Arguably, Spring is the best thing that happened to enterprise Java in a long time. Spring provides the long list of tools and small code conveniences that make J2EE programming more object-oriented, much easier, and, well, more fun.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (2)
Login
Forgot your account info?

We Review the Top Breast Enhancing Pills & tell you what really By Anonymous on September 6, 2009, 9:04 pmWe Review the Top Breast Enhancing Pills & tell you what really works.

Reply | Read entire comment

error while running the code.By Anonymous on January 1, 2009, 4:30 amHi. i tried running this code but got the following error while running the JUnit Test. thanks for any help. ********************************************* Error...

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources