Book Review – Drools JBoss Rules 5.X Developer’s Guide by Micahal Bali (Packt Publishing)

Packt Publishing – Drools JBoss Rules 5x Developer’s Guide by Michael Bali

See This Book in Publishers Website | Amazon

I had an opportunity to take a look at this book in a different way – I was a Java and Drools developer for years already and wanted to see what I was missing. When I found this book, like all other books, I just turned over the pages quickly to find out what was in it or is it even worth spending your time in. I was surprised to see the amount of real world coding examples this book contained – something most developers would be happy to just copy and run as a part of their quick learning. It had a nicely structured chapters, clean format, explanations as needed, charts and diagrams to make your learning easy.As I started cruising through the chapters, I saw many alternate styles that I could have used while writing the rules.

I must tell you The content in this book is huge – it has over 300 pages – but the reading flows very well. You could be reading 3,4,5 chapters in one seating and feel that pride of having learnt something. Apparently the author has done a great job in presenting the book in a style that would definitely lower the learning curve. I bet the new developers or the developers who have had used this Drools with JBoss in the past would equally find this book worth looking at.

There are 12 chapters in this book. Most developers would be able to learn in a short amount of time what Drools is, how to write the basic rules, how business rules are validated, ho you can do a transformation of complex data using Drools. There is even a chapter that focuses on making the rules Human Readable. I was surprised with this chapter, because most of the coding book don’t normally talk about coding in a way business people can understand if they had opportunity to look at.

Definitely a thumbs up from me !

List of valid @suppresswarning annotation parameters in Java for Eclipse and IBM RAD IDE

The following is a list of most of the valid @suppresswarning annotation parameters in Java for Eclipse and IBM RAD IDE. The right column shows what those java annotation parameters are used for.

Annotation Param

Usage

intfNonInherited interface non-inherited method compatibility
javadoc invalid javadoc
localHiding local variable hiding another variable
maskedCatchBlocks hidden catch block
nls to suppress warnings relative to non-nls string literals
noEffectAssign assignment with no effect
null to suppress warnings relative to null analysis
nullDereference missing null check
over-ann missing @Override annotation
paramAssign assignment to a parameter
pkgDefaultMethod attempt to override package-default method
raw usage a of raw type (instead of a parametrized type)
restriction to suppress warnings relative to usage of discouraged or forbidden references
semicolon unnecessary semicolon or empty statement
serial to suppress warnings relative to missing serialVersionUID field for a serializable class
specialParamHiding constructor or setter parameter hiding another field
static-access to suppress warnings relative to incorrect static access
staticReceiver if a non static receiver is used to get a static field or call a static method
super overriding a method without making a super invocation
suppress enable @SuppressWarnings
synthetic-access to suppress warnings relative to unoptimized access from inner classes
tasks enable support for tasks tags in source code
typeHiding type parameter hiding another type
unchecked to suppress warnings relative to unchecked operations
unnecessaryElse unnecessary else clause
unqualified-field-access to suppress warnings relative to field access unqualified
unused to suppress warnings relative to unused code
unusedArgument unused method argument
unusedImport unused import reference
unusedLabel unused label
unusedLocal unused local variable
unusedPrivate unused private member declaration
unusedThrown unused declared thrown exception
uselessTypeCheck unnecessary cast/instanceof operation
varargsCast varargs argument need explicit cast
warningToken unhandled warning token in @SuppressWarnings

 

Here is an usage example. As you can see, the piece of code below does not use any annotations and the code has a yellow underline in the method signature. If you hover around the icon on the left bar of the IDE where there will be warning sign, you will notice that the Eclipse IDE has issued warning saying that this method is never called in the class.

 

But if you put the annotation @SuppressWarning(“unused”), we specifically tell the IDE to ignore the usused methods by suppressing the warnigns. Here is the code after the annotation has been added. Code looks clean, no more annoying warning underline !

Finding Java System Properties

// File: io/properties/SysPropList.java
// Description: Shows system properties.  This must be an application.
//              An applet can't get this information.
// Author: Fred Swartz
// Date:   2 Feb 2005

import java.awt.*;
import javax.swing.*;
import java.util.*;

/** Generic main program. */
public class SysPropList {
    public static void main(String[] args) {
        JFrame window = new JFrame("System Properties");
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setContentPane(new SysPropListGUI());
        window.pack();
        window.setVisible(true);
    }
}

/** Panel to display the (limited) GUI intereface. */
class SysPropListGUI extends JPanel {
    JTextArea m_propertiesTA = new JTextArea(20, 40);

    /** Constructor sets layout, adds component(s), sets values*/
    public SysPropListGUI() {
        this.setLayout(new BorderLayout());
        this.add(new JScrollPane(m_propertiesTA), BorderLayout.CENTER);

        //... Add property list data to text area.
        Properties pr = System.getProperties();

	// TreeSet sorts keys
        TreeSet propKeys = new TreeSet(pr.keySet());  
        for (Iterator it = propKeys.iterator(); it.hasNext(); ) {
            String key = (String)it.next();
            m_propertiesTA.append("" + key + "=" + pr.get(key) + "n");
        }
    }
}