Phil 4.3.12

8:00 – 1:30, 3:30 -6:00  CSIP

  • Ok ,now that we have working(?) code, I have something to walk through while reading the book.
  • The Drools team suggests that you use the joda DateTime library. It looks pretty nice, too – They also have a bunch of other interesting libraries at
  • Setting a global value in a rule
    • Java
      // Import the class
      // create the session
      static StatelessKnowledgeSession session;
      // create rule engine
      KnowledgeBaseConfiguration configuration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
      KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(configuration);
      // declare our global
      BankingInquiryService inquiryService = new BankingInquiryServiceImpl();
      // make a session
      session = knowledgeBase.newStatelessKnowledgeSession();
      // add the global to the session
      session.setGlobal("inquiryService", inquiryService);
    • Drools rule (.drl file)
      // import
      // declare
      global BankingInquiryService inquiryService;
      // use the global in a rule (note the surrounding eval(), which can evaluate any code that returns a TRUE or FALSE).
      rule "accountNumberUnique"
              $account : Account(eval(!inquiryService.isAccountNumberUnique($account)))
              error(kcontext, $account);
  • Chapter 4
  • Nice data visualization using webGL

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s