Book Image

Drools JBoss Rules 5.0 Developer's Guide

By : Michal Bali
Book Image

Drools JBoss Rules 5.0 Developer's Guide

By: Michal Bali

Overview of this book

<p>Business rules can help your business by providing a level of agility and flexibility. As a developer, you will be largely responsible for implementing these business rules effectively, but implementing them systematically can often be difficult due to their complexity. Drools, or JBoss Rules, makes the process of implementing these rules quicker and handles the complexity, making your life a lot easier!<br /><br />This book guides you through all of the features of Drools, such as dynamic rules, the event model, and Rete implementation with high performance indexing. It will help you to set up the JBoss Rules platform and start creating your own business. It's easy to start developing with Drools if you follow its real-world examples that are intended to make your life easier.<br /><br />Starting with an introduction to the basic syntax that is essential for writing rules, the book will guide you through validation and human-readable rules that define, maintain, and support your business agility. As a developer, you will be expected to represent policies, procedures and. constraints regarding how an enterprise conducts its business; this book makes it easier by showing you it can be done.<br /><br />A real-life example of a banking domain allows you to see how the internal workings of the rules engine operate. A loan approval process example shows the use of the Drools Flow module. Parts of a banking fraud detection system are implemented with Drools Fusion module, which is the Complex Event Processing part of Drools. This in turn, will help developers to work on preventing fraudulent users from accessing systems in an illegal way.<br /><br />Finally, more technical details are shown on the inner workings of Drools, the implementation of the ReteOO algorithm, indexing, node sharing, and partitioning.</p>
Table of Contents (22 chapters)
Drools JBoss Rules 5.0 Developer's Guide
Credits
Foreword
About the Author
About the Reviewers
Preface
Development Environment Setup
Custom Operator
Dependencies of Sample Application
Index

Implementation


In this section, we'll define the implementation for various interfaces that we've defined in this chapter. You can skip this section if you like. It is here for completeness.

First, let's look at an implementation of the Message interface, which is shown in the following code. The message is essentially another POJO, so it will basically have get and set methods, and it will also override the equals, hashCode, and toString methods.

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
//... other imports

public class DefaultMessage implements Message, Serializable {
  private Message.Type type;
  private String messageKey;
  private List<Object> context;

  public DefaultMessage(Message.Type type, String messageKey,
      List<Object> context) {
    if (type == null || messageKey == null) {
      throw new IllegalArgumentException(
          "Type and...