RulePoint 20091014 Developer's Guide · PREFACE This guide describes how to use or extend th e...

130
RELEASE 20091014

Transcript of RulePoint 20091014 Developer's Guide · PREFACE This guide describes how to use or extend th e...

  • RELEASE 20091014

  • ii Agent Logic RulePoint Developer’s Guide Release 20091014

    RULEPOINT DEVELOPER’S GUIDE

    AGENT LOGIC, INC.8603 WESTWOOD CENTER DRIVE

    4TH FLOORVIENNA, VA 22182

    PHONE - (703) 744-7700FAX - (703) 744-7701

    Copyright © 2003-2009 Agent Logic / Agent Logic, Inc. and/or its suppliers, 8603 Westwood Center Drive, 4th Floor, Vienna, VA, U.S.A. All rights reserved.

    This document contains information that is the property of Agent Logic and is furnished for the sole purpose of the operation and maintenance of Agent Logic products. No part of this publication is to be used for any other purpose, nor is it to be reproduced, copied, disclosed, transmitted, stored in a retrieval system or translated into any human or computer language, in any form, by any means, in whole or in part, without the express written consent of Agent Logic.

    Except as otherwise explicitly agreed to in writing, Agent Logic makes no representation that equipment, software programs, and practices described herein will not infringe on existing or future patent rights, copyrights, trademarks, trade secrets, or other proprietary rights of third parties. The descriptions contained herein do not imply the granting of the right to make, use, sell, license, or otherwise transfer Agent Logic products described herein. Agent Logic disclaims responsibility for errors that appear in this document, and it reserves the right, at its sole discretion and without notice, to make substitutions and modifications in the products and practices described in this document.

    Trademarks

    Agent Logic, Event Detection and Response, User-Driven Complex Event Processing, “To Detect and Respond,” “CEP for Humans,” RulePoint, Real-Time Alert Manager, RTAM, RuleCast, L2H, Low-to-High, High-to-Low, Enterprise Agent Server, and other Agent Logic products and solutions referenced herein are either trademarks or registered trademarks of Agent Logic/Agent Logic, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners.

    Certain product and company names mentioned herein are protected as follows:

    • Firefox is a trademark of the Mozilla Foundation.• Intel and Pentium are registered trademarks of Intel Corporation in the United States, other countries, or both.• Microsoft, Active Directory, Internet Explorer, NetMeeting, PowerPoint, SQL Server, Windows 98, Windows 2000,

    Windows 2003, Windows NT, and WordPad are either registered trademarks or trademarks of Microsoft Corporation in the United States, other countries, or both.

    • Sun Microsystems, Sun, AnswerBook, Java, JVM, Solaris, Solaris JumpStart, StarOffice, Sun Ray, SunForum, Ultra, and Trusted Solaris are either registered trademarks or trademarks of Sun Microsystems, Inc., in the United States, other countries, or both.

    • UNIX is a registered trademark of The Open Group in the United States, other countries, or both.• Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.• Apache Tomcat and Tomcat are trademarks of the Apache Software Foundation in the United States, other countries, or

    both.• BEA WebLogic is a registered trademark of BEA Systems, Inc., in the United States, other countries, or both.• IBM and WebSphere are registered trademarks of International Business Machines Corporation in the United States,

    other countries, or both.Other product and company names mentioned herein may be the trademarks of their respective owners.

    FILE NAME: RULEPOINTDEVELOPERGUIDE_20091014.PDFDOC ID: RPDG4020091014

  • Agent Logic RulePoint Developer’s Guide Release 20091014 iii

    CONTENTS

    PREFACE

    Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii

    How to Use this Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii

    Document Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

    Customer Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

    INTRODUCTION

    What’s New? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10RulePoint REST Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    Prerequisite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10RulePoint Java API Adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Determining the Versions of the REST Extension and the Java API Adapter . . . . . 11

    What’s Changed? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11RulePoint 4.0 Changes and Custom Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    RuleContext Class Refactored . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Session Recoverability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Deprecated HTML REST API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    CHAPTER 1 UNDERSTANDING SERVICES, INTERFACES, AND CLASSES

    Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    Understanding the Life Cycle of Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    Common Generic Interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14Session Recoverability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    Understanding RulePoint Services and Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Source Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    Schedulable Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Listener Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    Analytic Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Responder Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    Using RulePoint Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

  • CONTENTS

    iv Agent Logic RulePoint Developer’s Guide Release 20091014

    Schedulable Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17execute( ) Method. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    Listener Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18EventPublisher Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Analytic Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    analyze( ) Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Responder Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    respond( ) Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20newResponse( ) Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    Response Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20Alert Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21MapResponse Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    Using RulePoint Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21AbstractService Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22ObjectAnalytic and ValueAnalytic Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    ObjectAnalytic Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22ValueAnalytic Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    Various Response Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22AbstractAlert Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22AbstractMapResponse Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23AbstractResponse Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    CHAPTER 2 CREATING NEW SERVICES

    Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    Determining the Purpose and Actions of a Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Determining the Purpose. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25Determining the Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    Creating the Services and Responses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    Creating Corresponding BeanInfoBase Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    CHAPTER 3 DEPLOYING NEW SERVICES

    Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    Creating a .jar File from the New Class Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    Adding the Bean Entries for Each New Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    CHAPTER 4 RULEPOINT REST EXTENSION

    Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    Installing the RulePoint REST Extension. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Establishing an Authenticated Session with the RulePoint Server . . . . . . . . . . . . . . 36

  • Agent Logic RulePoint Developer’s Guide Release 20091014 v

    CONTENTS

    Executing the HTTP GET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Executing the HTTP POST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Examining the Headers of the Response. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    CHAPTER 5 RULEPOINT JAVA API ADAPTER

    Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    Using the Java API Adapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39What’s in the Zipped Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    Creating Your First RulePoint Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Setting Your Classpath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Editing the Configuration Property File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    Sample Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    APPENDIX A CHANGES AND CUSTOM SERVICES

    Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

    Enhancements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Session Recoverability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45Batch Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

    Batch Completion Listener . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    APPENDIX B SAMPLE XML REQUESTS

    General Request Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Common Request Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

    Paging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Topic Restriction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Creating a User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Schema for Creating or Updating Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54Updating a User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55Updating a Current User Profile. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

    Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Creating an Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56Schema for Creating Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

    Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Creating a Response for a Specific Service Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58Schema for Creating or Updating Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59Updating a Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

    Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

  • CONTENTS

    vi Agent Logic RulePoint Developer’s Guide Release 20091014

    Creating a Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62Schema for Creating or Updating Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62Updating a Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64Updating a Template Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

    Service Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66Creating a Service Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66Schema for Creating or Updating a Service Instance . . . . . . . . . . . . . . . . . . . . . . . . . . 66Updating a Service Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68Creating a Schedule for a Specific Service Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69Schema for Creating a Schedule for a Specific Service Instance. . . . . . . . . . . . . . . . . 69

    Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71Creating a Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71Schema for Creating or Updating Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72Updating a Template. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

    Template Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Creating a Template Rule. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Schema for Creating or Updating Template Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

    Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Creating a Topic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78Schema for Creating or Updating Topics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79Updating a Topic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

    Watchlists. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83Creating a ‘List’ Watchlist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83Schema for Creating or Updating Watchlists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84Updating a ‘List’ Watchlist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

    Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88Creating a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88Schema for Creating or Updating Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Updating a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

    Wizard Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Creating a Wizard Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Schema for Creating or Updating Wizard Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93Updating a Wizard Rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97Schema for Condition Operand and Analytic Argument for Wizard Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

    Viewing the List of Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100Viewing a Sorted List of Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101With Pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102Filtered by Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103Filtered by Contains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103Filtered by Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103Filtered by Topic Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104Filtered by Service Type Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

  • Agent Logic RulePoint Developer’s Guide Release 20091014 vii

    CONTENTS

    Viewing an Entity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Viewing the Dependency List of an Entity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106Viewing the Auto-Complete List of an Entity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106Viewing Administrative Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

    Deleting Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107Sample Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

  • PREFACE

    This guide describes how to use or extend the services, interfaces and the classes that are used in RulePoint®. It also helps you to create, deploy, and use new services.

    Audience This guide is primarily intended for developers who would like to extend the existing services of RulePoint or to create new ones for the product. Users should be familiar with J2EE applications and have working knowledge of the REST API semantics.

    RulePoint SDK Compatibility

    Matrix

    The RulePoint SDK supports different versions of the product. Below is a matrix that maps each version of the REST Extension and JAVA API to the corresponding version of RulePoint.

    RulePoint 4.0 RulePoint 5.0

    REST Extension 1.0 Yes NoREST Extension 1.1 No.

    This release exposes RulePoint 4.0 functionalities for RulePoint 5.0

    Yes.This release exposes RulePoint 4.0 functionalities for RulePoint 5.0.

    JAVA API 1.0 Yes.Must be used with REST Extension 1.0.

    Yes.Access RulePoint 4.0 functionlities. Must be used with REST Extension 1.1.

    JAVA API 1.1 Must be used with REST Extension 1.0.

    Yes.Access RulePoint 4.0 functionlities. Must be used with REST Extension 1.1.

  • PREFACE HOW TO USE THIS GUIDE

    ix Agent Logic RulePoint Developer’s Guide Release 20090511

    How to Use this Guide

    This guide is organized as follows:

    Introduction

    This chapter introduces you to the SDK-related changes and enhancements that have been implemented for the RulePoint 5.0 release.

    Chapter 1: Understanding Services, Interfaces, and Classes

    This chapter describes how the RulePoint services, interfaces, and classes interact.

    Chapter 2: Creating New Services

    This chapter describes how to create new services in RulePoint.

    Chapter 3: Deploying New Services

    This chapter describes how to deploy new services in RulePoint.

    Chapter 4: RulePoint REST Extension

    This chapter describes how you can install and use the RulePoint REST Extension.

    Chapter 5: RulePoint Java API Adapter

    This chapter describes how you can deploy and use the Java API Adapter to communicate with the RulePoint server.

    Appendix A: Changes and Custom Services

    This appendix describes changes and enhancements introduced in the RulePoint SDK that impact all custom services currently installed.

    Appendix B: Sample XML Requests

    This appendix provides reference information about the XML messages and requests that are used by the RulePoint REST Extension.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 x

    DOCUMENT CONVENTIONS ,

    Document Conventions

    Table 1 describes the typographic conventions used in this guide.

    Table 1 - Conventions

    Font or Symbol Use ExampleBold font Table and Figure captions Figure 3

    Table 1Italic font Book titles, new words or

    terms, and words to be emphasized

    Read the Administrator’s GuideThe service is a producerYou must complete this step

    Courier bold font Text to type exactly as shown

    Type Exit.

    Courier italic font Names of variables. Replace with a real value

    server name

    IP addressVerdana font Names of screens and

    parts of screens.In the Time fieldThe Login screen appears.

    Verdana bold font Names of commands, button, and selections

    Click EditSelect Rules > View All

    Non-printing characters and keyboard characters

    Press

    Simultaneous key strokes Press

    Customer Support

    If you have followed the instructions in this guide and need further assistance, please send an email to [email protected] or call 703-744-7799. To help us assist you, please provide the following information:

    • Your contact information• Version number of the product• If reporting a defect, steps to reproduce

  • INTRODUCTION

    This chapter introduces you to the SDK-related changes that have been implemented for the RulePoint® 5.0 release. It provides a broad overview of what is new, what has changed since the last release of RulePoint, and current enhancements to the SDK.

    What’s New? RulePoint REST Extension 1.1

    The REST Extension is intended to enable remote communication between the RulePoint server, another third party application or the RulePoint Java API Adapter. The REST Extension facilitates the creation and exchange of XML data between the server and the RulePoint Java API Adapter.

    Prerequisite

    The RulePoint REST Extension 1.1 requires that you have installed RulePoint 5.0 or RulePoint 4.0 Service Pack 1 .

    RulePoint Java API Adapter 1.1

    The RulePoint Java API Adapter is a software module that simplifies the task of interacting with the RulePoint REST Extension. This Java API Adapter offers the following benefits:

    • It provides XML parsers and generators that are compatible with the XML Schema exposed by the RulePoint REST Extension.

    • It includes an entire suite of Java Objects that model all of the entities that exist within RulePoint.

    • It has a single API class (com.agentlogic.rulepoint.wrapper.api.RulePointAPI) that provides a simple programmatic interface for accessing RulePoint functionality.

    • It provides a simple, structured, localizable error handling module.

  • INTRODUCTION WHAT’S CHANGED?

    10 Agent Logic RulePoint Developer’s Guide Release 20090511

    Prerequisites

    The RulePoint Java API Adapter 1.1 requires that you have a running instance of RulePoint 5.0 or RulePoint 4.0 SP1 that has the RulePoint REST Extension 1.1 also installed. You can verify the installation of these applications by following these steps:

    • Login to RulePoint as a user with administrative permissions.• Click the Administration link (top-right).• Select System Information from the Administration menu.• Verify that the REST Extension is listed in Installed Extensions.

    For more information on installing the RulePoint Java API Adapter, and to review sample code, see Chapter 5‚ “RulePoint Java API Adapter,” starting on page 41.

    Determining the Versions of the REST Extension and the Java API Adapter

    To obtain the version of your RulePoint REST Extension, use the following command:

    • java -jar rulepoint-restapi.jarTo obtain the version of your RulePoint Java API Adapter, use the following command:

    • java -jar RulePointJavaAPIAdapter.jar

    What’s Changed?

    RulePoint 4.0 Changes and Custom Services

    A number of significant changes and enhancements were made in this release of the SDK. The key changes are as follows:

    RuleContext Class Refactored

    The RuleContext class has been refactored into a new package. The new package name is: com.agentlogic.rulepoint.engine.RuleContext.

    Session Recoverability

    RulePoint 4.0 provides enhanced support for session recoverability. When a connection error occurs, RulePoint automatically tries to reconnect to the remote server. The user can specify how many times, and how frequently RulePoint should attempt to reconnect by specifying new bean properties. The properties are:

    • retryCount – The number of times RulePoint will attempt to reconnect to the remote server.

    • retryDelay – The number of milliseconds that RulePoint will wait between attempts to reconnect.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 11

    WHAT’S CHANGED? INTRODUCTION

    Batch Processing

    RulePoint 4.0 provides support for batch processing of Events. This means that a Service can indicate that multiple Events should be considered as a single unit of work. A ‘batch’ is considered to be completed when all Events in the batch have been completely processed, including all rule activations.

    Deprecated HTML REST API

    Prior to RulePoint 4.0 Service Pack 1, RulePoint offered an HTML-based REST API for customer use. This HTML-based REST API has been deprecated in favor of an XML-based REST API that is available via the RulePoint REST Extension software module.

  • INTRODUCTION WHAT’S CHANGED?

    12 Agent Logic RulePoint Developer’s Guide Release 20090511

  • Agent Logic RulePoint Developer’s Guide Release 20090511 13

    CHAPTER 1 UNDERSTANDING SERVICES, INTERFACES, AND CLASSES

    This chapter describes how the RulePoint® services, interfaces, and classes interact. This chapter includes the following topics:

    • Overview (on page 14)• Understanding the Life Cycle of Services (on page 14)• Understanding RulePoint Services and Interfaces (on page 15)• Using RulePoint Interfaces (on page 17)• Using RulePoint Classes (on page 21)

  • CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES OVERVIEW

    14 Agent Logic RulePoint Developer’s Guide Release 20090511

    Overview RulePoint uses services to connect to various internal and external sources and applications to produce and respond to events. These services are configurable interfaces that can link to other software systems, such as IM, email, Real-Time Alert Manager™ (RTAM™), a web page, a database, or a news feed.

    RulePoint provides many useful built-in services, such as JMS, email, URL monitoring, Web services, and so on. However, you can also build your own services that can connect to other systems or use different protocols.

    Understanding the Life Cycle

    of Services

    Before developing your new service, you should become familiar with the life cycle of a service from a user perspective. The following steps provide a high-level overview of how RulePoint uses services:

    1. The system administrator deploys a new service class by editing the services-custom.xml file and copying the service’s jar file to the ..\lib directory. You must restart RulePoint to recognize the new services. (For more information, see “Adding the Bean Entries for Each New Class” on page 34.)

    2. In the RulePoint user interface, a user browses the available services on the New Service page.

    3. The user selects a service. If the selected service is new, the prototype in the services-custom.xml file is used to instantiate a new service.

    4. The user edits the service fields, which correspond to the JavaBean properties for the service and the JavaBean’s sibling BeanInfoBase class. (For more information, see Chapter 2‚ “Creating New Services,” starting on page 25.)

    5. The user clicks Save. The service is then serialized as XML and saved in the database.

    6. If the service is not already running, the service Manager starts the service and calls the init() method. After every execution of the service, the service manager calls the destroy() method.

    7. The user can repeat Steps 4-6 as it is possible to view, edit, or save a service any number of times.

    8. The user then can use the service to create an event, evaluate whether to trigger a rule, or execute a response.

    9. At any time, the user can disable or delete a service in the user interface, at which time RulePoint updates the service status and the service Manager stops the service and calls the destroy() method.

    Common Generic

    Interfaces

    These generic common interfaces are available to all services. For more information on these interfaces and to review a sample of the code, see Appendix A, “Changes and Custom Services,” starting on page 47

  • Agent Logic RulePoint Developer’s Guide Release 20090511 15

    UNDERSTANDING RULEPOINT SERVICES AND INTERFACES CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES

    Session Recoverability

    RulePoint 4.0 provides enhanced support for session recoverability. When a connection error occurs, RulePoint will automatically try to reconnect to the remote server. The user can specify how many times, and how frequently RulePoint should attempt to reconnect by specifying new bean properties. The properties are:

    • retryCount – The number of times RulePoint will attempt to reconnect to the remote server.

    • retryDelay – The number of milliseconds that RulePoint will wait between attempts to reconnect.

    To utilize this enhancement, a custom service must extend ees.io.AbstractService. Also, the custom service must invoke the retryController() method as part of its connection process.

    Batch Processing

    RulePoint 4.0 provides support for batch processing of Events. This means that a custom service can indicate that multiple Events should be considered a single unit of work. A ‘batch’ is considered to be completed when all Events in the batch have been completely processed, including all rule activations and response actions.

    Understanding RulePoint

    Services and Interfaces

    Three different types of services enable you to manipulate these various internal and external software systems in different ways:

    • Source Services gather and return information from a system.• Analytic Services analyze data within a system. • Responder Services execute a response through a system.

    Source Services

    Source services can be of the following types:

    • Schedulable• Listener

    Schedulable Services

    Schedulable services generate events on a schedule that you set. A schedulable service contains a configurable topic and can be scheduled to run at specific times (for example, 1 time every 30 minutes).

    An example of a schedulable service is an RSS /Atom News Reader Service that extracts events from an RSS news feed every hour.

    You create schedulable services using the Schedulable interface. For more information about this interface, see “Schedulable Interface” on page 17.

  • CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES UNDERSTANDING RULEPOINT SERVICES AND INTERFACES

    16 Agent Logic RulePoint Developer’s Guide Release 20090511

    Listener Services

    Listener services generate events at any time based on particular occurrences, not on a scheduled basis.

    An example of a Listener service is an Instant Messenger service that “listens” for instant messages that meet certain criteria and then publishes an event when an appropriate message is received.

    You create Listener services using the Listener interface. For more information about this interface, see “Listener Interface” on page 18.

    Analytic Services

    Analytic services implement a data processing function and can be referenced in Rules to determine whether a rule should be triggered. Analytic services can provide simple functions such as an API, or more advanced functions such as connecting to a remote server and performing data processing before returning.

    Two types of analytic services are available:

    • Value analytics execute by calling the analyze() method and return a single value (for example, string or number) within a List for use by other analytics.

    • Object analytics execute by calling the analyze() method and return an Object or a collection of Objects (for example, XPath nodes) for use by other analytics.

    You create analytic services using the Analytic interface. For more information about this interface, see “Analytic Interface” on page 18.

    Responder Services

    Responder services enable you to define the action to be taken when a rule triggers. From a single Responder service, you can create multiple responses.

    An example of a Responder service is an email service that defines the mail server and account used to send an email in response to a rule being triggered. You then can create multiple email responses from this service in which you define different recipients and contents of the emails to be sent when a particular rule triggers.

    You create Responder services using the Responder interface. For more information about this interface, see “Responder Interface” on page 19.

    You create the response associated with the service using the response interface. For more information about this interface, see “Response Interface” on page 20.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 17

    USING RULEPOINT INTERFACES CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES

    Using RulePointInterfaces

    This section describes the interfaces and classes used to develop new service types in RulePoint. services essentially act as adapters, allowing you to access the appropriate remote systems or provide the functionality.

    The RulePoint service interface contains the following sub-interfaces, which enable you to create the Source, Responder, and Analytic service types:

    • Schedulable Interface (on page 17)• Listener Interface (on page 18)• Analytic Interface (on page 18)• Responder Interface (on page 19)

    You can implement a single interface or any combination of these (for example, Schedulable and Responder).

    If you create a Responder service, you then should create a corresponding response using the response interface (see “Response Interface” on page 20). You can extend the response interface using the Alert interface (see “Alert Interface” on page 21) or the MapResponse interface (see “MapResponse Interface” on page 21).

    Schedulable Interface

    The Schedulable interface extends the Source interface and enables you to create instances of Schedulable Source services.

    When a Schedulable Source service executes, RulePoint invokes its execute() method (see “execute( ) Method” on page 17). If the Schedulable Source service has events to publish into RulePoint, it can use the EventPublisher interface (see “EventPublisher Interface” on page 18).

    The Schedulable interface has a configurable topic and is suited to polling for events. Polling services, such as the RSS /Atom News Reader service, should be created as scheduled services.

    The following is the Schedulable interface:

    execute( ) Method

    This method allows a service to run at its scheduled time to check whether events need to be published. If so, the service then can publish the events using the EventPublisher interface (see “EventPublisher Interface” on page 18).

    NOTEFor more detailed information about the interfaces and classes that are provided here, see the RulePoint javadocs located in the javadocs folder of the AL_RulePoint_SDK_20090128.zip file.

    public interface Schedulable extends Service { public void execute() throws Exception;}

  • CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES USING RULEPOINT INTERFACES

    18 Agent Logic RulePoint Developer’s Guide Release 20090511

    The service can generate events as individual Map objects or as a collection of Map objects. You can call the publishEvent() method for individual events, or you can call it once for a collection of events.

    Related InformationThe Schedulable interface is implemented most often using the AbstractService class (see “AbstractService Class” on page 22).

    Listener Interface

    The Listener interface extends the Source interface and enables you to create instances of Listener source services.

    Listener services “listen” for a particular occurrence at any time and then use the EventPublisher class (see “EventPublisher Interface” on page 18) to publish the event into RulePoint.

    The following is the Listener interface:

    Related InformationThe Listener interface is most often implemented using the AbstractService class (see “AbstractService Class” on page 22).

    EventPublisher Interface

    This is not an interface that you implement. RulePoint passes the EventPublisher interface into the service interface using the setEventPublisher method. This interface enables you to publish events into RulePoint.

    If using the AbstractService class (see “AbstractService Class” on page 22), you can use its publishEvent() method or its eventPublisher field.

    Analytic Interface

    The Analytic interface extends the Service interface and enables you to create instances of analytic services.

    Analytics that need to establish or verify a connection with a remote service might require initialization. For example, a SQL analytic must establish a connection to the database that it will use for subsequent requests. If the analytic requires initialization, this should be implemented in the analytic’s init() method.

    public interface Listener extends Source{}

    NOTEThis interface does not contain any methods to invoke because each implementation specifies when to publish events.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 19

    USING RULEPOINT INTERFACES CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES

    For value analytics, extend from the ValueAnalytic class. For object analytics, extend from the ObjectAnalytic class. For more information, see “ObjectAnalytic and ValueAnalytic Classes” on page 22.

    analyze( ) Method

    The analyze() method receives event properties as arguments, performs analysis using those arguments (perhaps even connecting to remote systems), and returns an Object or collection of Objects.

    In the following example, the analytic is passed a collection of three headline strings, which are the values of the headline property from three news events.

    The first item in the collection might be a search string, regular expression, or something similar, depending on the analytic. For example, the first item in the XPath analytic in the collection is the XPath expression itself. You can extract this item and then use it to analyze the rest of the items in the collection.

    The return type is Object, but analyze() might return a collection of Objects as a result of the analytic’s processing. For example, if you apply an XPath analytic to an XML document, the return value is a collection of nodes in the document that match the XPath expression. Value analytics return a collection with a single item. Object analytics return an Object or a collection of Objects.

    To be nested, analytics need to return a collection—when you have nested analytics, the inner one returns a collection of items that becomes the argument for the outer one.

    In the example above, the result of the inner XPath analytic becomes the argument for the outer count analytic.

    Related InformationThe Analytic interface is most often implemented for Object Analytics using the ObjectAnalytic class (see “ObjectAnalytic Class” on page 22) and for Value Analytics using the ValueAnalytic class (see “ValueAnalytic Class” on page 22).

    Responder Interface

    The Responder interface extends the Service interface and enables you to create instances of Responder services.

    A response executes a defined action by passing the response class into the respond() method of the Responder service that created it.

    The Responder interface enables a response to be propagated to an underlying service. A bi-directional service, which is a service that implements both Schedulable and Responder interfaces, enables the single service to publish as well as respond to events.

    when 3 news n with myAnalytic(n.headline) = "true"

    when news with count(xpath(articles, '/items/item/@headline')) > 0

  • CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES USING RULEPOINT INTERFACES

    20 Agent Logic RulePoint Developer’s Guide Release 20090511

    The following is the Responder interface:

    respond( ) Method

    The respond() method receives a response as input and processes/executes the response. For example, the respond() method receives an EmailResponse as input, creates an email message using the properties in EmailResponse, and then sends the message.

    newResponse( ) Method

    The newResponse() method returns a response of the type that this Responder service can understand and process in its respond() method. For example, EmailResponse has the following configurable properties:

    • from • to • subject • message

    When newResponse() is called, EmailService returns a new instance of that class, which can be configured in the RulePoint user interface and saved for later use. Later it can be executed by passing it into the respond() method of the EmailService.

    Related InformationThe Responder interface is most often paired with the response interface (see “Response Interface” on page 20) and implemented using the AbstractService class (“AbstractService Class” on page 22).

    Response Interface

    The Response interface enables you to create responses to be processed by a Responder service. It is the implementation of each response that is associated with a Responder (responder service) in the RulePoint user interface.

    The following is the Response interface:

    public interface Responder extends Service{ public Response newResponse();}

    public interface Response { String getTarget(); void setTarget(String target);}

  • Agent Logic RulePoint Developer’s Guide Release 20090511 21

    USING RULEPOINT CLASSES CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES

    Alert Interface

    The Alert interface extends the Response interface and supports message-oriented responses.

    The following is the Response interface:

    MapResponse Interface

    The MapResponse interface extends the Response interface and enables you to support dynamically-mapped parameters. For example, this interface enables users to enter parameters in the RulePoint user interface as comma-separated key=value pairs, such as name=bob jones, age=30, born=9/22/1976.

    Examples of responses that use dynamic parameters include the Java and JMS responses, where you would not know beforehand what the parameters are going to be.

    The following is the MapResponse interface:

    Related InformationTo create a concrete response class, pick an abstract base class to extend:

    • Use AbstractAlert if the response includes to, subject, and body properties (that is, it is a message-oriented response).

    • Use AbstractMapResponse if the response includes dynamically-mapped parameters (for example, comma-separated key=value pairs, such as name=bob jones, age=30, born=9/22/1976). Otherwise, extend the AbstractResponse class.

    Using RulePoint

    Classes

    You can extend the following default classes:

    • AbstractService Class (on page 22)• ObjectAnalytic and ValueAnalytic Classes (on page 22)

    public interface Alert extends Response { String getSubject(); void setSubject(String subject); String getBody(); void setBody(String body);}

    public interface MapResponse extends Response { Map getParams(); void setParams(Map params);}

  • CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES USING RULEPOINT CLASSES

    22 Agent Logic RulePoint Developer’s Guide Release 20090511

    • Various Response Classes (on page 22)

    AbstractService Class

    The AbstractService class includes most of the basic functionality for implementing services and publishing events. When developing new service types, you can simply extend AbstractService and call the provided publishEvent() method to feed events into RulePoint. Nonetheless, use of the AbstractService class is optional.

    Generally, Source and Responder services should extend the AbstractService class. Object Analytics and Value Analytics should extend the ObjectAnalytic and ValueAnalytic classes, respectively.

    ObjectAnalytic and ValueAnalytic Classes

    Analytics that extend the ObjectAnalytic class or the ValueAnalytic class must return a result, which then can be used by another top-level analytic.

    The implementation is placed within the analyze() method, which receives the values in scope when the analytic is called, with a list of these values passed as the argument.

    ObjectAnalytic Class

    The ObjectAnalytic class returns an Object or list of Objects as opposed to returning a value. Examples of these Analytics include Regex, SQL, Web, and XPath.

    ValueAnalytic Class

    A ValueAnalytic class returns a list containing a reference to a single value as opposed to returning a reference to the actual value. Examples of these Analytics include Count, Sum, and Average.

    Various Response Classes

    AbstractAlert Class

    The AbstractAlert class implements the Alert interface. AbstractAlert should be extended for message-like responses, such as emails and instant messages.

    TIPTo reduce the amount of data stored when saving objects, variables can be marked as transient to indicate that they are not part of the persistent state of an object. If the object is saved to disk, that variable will be excluded, and it will be empty when the object is loaded back into memory.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 23

    USING RULEPOINT CLASSES CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES

    AbstractMapResponse Class

    The AbstractMapResponse class implements the MapResponse interface. AbstractMapResponse should be extended for responses that are using dynamically-mapped parameters.

    AbstractResponse Class

    The AbstractResponse class implements the response interface. AbstractResponse should be extended for all other types of responses.

  • CHAPTER 1, UNDERSTANDING SERVICES, INTERFACES, AND CLASSES USING RULEPOINT CLASSES

    24 Agent Logic RulePoint Developer’s Guide Release 20090511

  • Agent Logic RulePoint Developer’s Guide Release 20090511 25

    CHAPTER 2 CREATING NEW SERVICES

    This chapter describes how to create new Services in RulePoint® and includes the following topics:

    • Overview (on page 26)• Determining the Purpose and Actions of a Service (on page 26)• Creating the Services and Responses (on page 27)• Creating Corresponding BeanInfoBase Classes (on page 28)

  • CHAPTER 2, CREATING NEW SERVICES OVERVIEW

    26 Agent Logic RulePoint Developer’s Guide Release 20090511

    Overview To create Services in RulePoint, you must complete the following steps:

    I. Determine the purpose and actions of the Services.II. Create the Services (see page 27).III. Create corresponding BeanInfoBase classes (see page 28).

    After you have created the Services and their BeanInfoBase classes, you must deploy the Services as described in Chapter 3‚ “Deploying New Services,” starting on page 33.

    You can start and stop Services at any time using the RulePoint user interface.

    A Service implementation should also expose all configurable properties using the JavaBean setter/getter methods. The Service Manager then can configure those properties as described in “Understanding the Life Cycle of Services” on page 14. After a Service has been initialized, any calls to JavaBean setters must make appropriate configuration changes immediately, without requiring a subsequent init() call.

    Determining the Purpose

    and Actions of a Service

    Before creating new Services, you must determine the purpose and usage of each.

    Determining the Purpose

    You must decide the purpose of each Service:

    • Publishing Events into RulePoint. This requires you to implement either the Schedulable or Listener sub-interface of the Source interface.

    • Providing analysis for evaluating conditions within Rules. This requires you to implement the Analytic interface.

    • Carrying out a response to a successful rule activation. This requires you to implement the Responder interface. In addition, you must create a response using the response interface.

    Each Service can provide one, two, or all three activities in a single class. To do so, it must implement all of the appropriate interfaces.

    NOTEThe RulePoint SDK provides you with examples of various Services and Responses (and their corresponding BeanInfoBase classes) in the samples directory of the SDK.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 27

    CREATING THE SERVICES AND RESPONSES CHAPTER 2, CREATING NEW SERVICES

    Determining the Actions

    You also must make some decisions related to the type of Service you are creating:

    Creating the Services and

    Responses

    After determining the purpose and action of your Service, you can create the Services. For Responder Services, you can also create the associated Responses using these steps.

    TO CREATE NEW SERVICES AND RESPONSES:

    1. Implement or override the interface methods necessary to achieve the desired functionality for each Service and response as described in the previous sections. For more information, see the RulePoint javadocs located in the javadocs folder of the AL_RulePoint_SDK 20090128.zip file.

    2. For Services only, override the getType() method in the Service interface to return a new distinct type represented as a String. This string will display in the Type column on the All Services page of the RulePoint user interface.

    3. Decide which properties you want to display in the RulePoint user interface for each Service or response, and then provide the appropriate getter/setter methods.

    4. Create corresponding BeanInfoBase classes for each Service. For Responder Services, also create a corresponding BeanInfoBase class for

    If a Service is publishing Events, you need to decide the mechanism for doing so:

    • If a Service is publishing Events according to a particular schedule, it needs to implement the Schedulable interface to enable the user to schedule the Service.

    • If a Service is publishing Events whenever it detects a system event of interest, it needs to implement the Listener interface.

    event publishing Services should extend from the AbstractService class.

    If a Service is acting as an analytic, you need to decide what kind of analytic you are providing:

    • If a Service is returning a value (for example, string or number), it is a Value Analytic and should extend from the ValueAnalytic class.

    • If a Service is returning an Object or a collection of Objects (for example, XPath nodes), it is an Object Analytic and should extend from the ObjectAnalytic class.

    Both ValueAnalytic and ObjectAnalytic extend from the AbstractService class. So if your Service implements multiple interfaces including Analytic, it is safe to use one of these two classes.

    If a Service is acting as a Responder, you must do the following:

    • The class must implement the Responder interface and extend from the AbstractService class.

    • Create a corresponding response. For more information about the response interface, see “Response Interface” on page 20. The following section, “Creating the Services and Responses,” includes the steps that you need to take to create a response.

  • CHAPTER 2, CREATING NEW SERVICES CREATING CORRESPONDING BEANINFOBASE CLASSES

    28 Agent Logic RulePoint Developer’s Guide Release 20090511

    each response. For steps to do so, see “Creating Corresponding BeanInfoBase Classes” on page 28.

    5. (Optional) If using Apache Ant™, update your build.properties file to specify the following: • The location of the container that houses the rulepoint folder

    ([RulePointHome]). This allows the build.xml file to locate the rulepoint.jar file that you are using, as well as to deploy the new classes that you created.

    • The location of your source directory (unless you are using the default directory folder provided in the SDK).

    6. Compile the classes against the rulepoint.jar file and any other necessary libraries, such as those associated with any remote servers to which you need to connect.

    7. Compress the classes into a .jar file and deploy your solution to RulePoint.

    Creating Corresponding BeanInfoBase

    Classes

    To display your new Services or Responses in the RulePoint user interface, you must create BeanInfoBase classes that corresponds to each Service and response. This class provides the metadata needed to display these properties.

    TO CREATE NEW BEANINFOBASE CLASSES:

    1. For each Service and response, create a corresponding BeanInfoBase class named [yourService]/[ResponseName]BeanInfo. For example, if a Service is named com.yourcompany.foo. MyService.java, you would create a sibling class named com.yourcompany.foo.MyServiceBeanInfo.java.

    2. For Services, extend ServiceBeanInfoBase, and for Responses, extend ResponseBeanInfoBase.

    3. Implement a no-arg constructor that throws IntrospectionException. This constructor must invoke the initBean() method.

    4. The createBeanDescriptor method must return the class for the sibling Service it is describing, as in the following example:

    NOTEIf using Apache Ant, you can place the additional libraries in the SDK’s lib directory, or update the build.xml file to reference them.

    NOTEIf using Apache Ant, you can use the ant build_all command to compile, compress, and deploy your solution to RulePoint in a single step. Ant creates a rulepoint3rdParty.jar file and places it in the [RulePointHome]\WEB-INF\lib folder.

    return new BeanDescriptor(com.agentlogic.sdk.sample. TemperatureSourceService.class);

  • Agent Logic RulePoint Developer’s Guide Release 20090511 29

    CREATING CORRESPONDING BEANINFOBASE CLASSES CHAPTER 2, CREATING NEW SERVICES

    5. The getClassName method must return the class of the sibling, as in the following example:

    6. The getDisplayName method must return the name for the Service or response that should be shown in the user interface, as in the following example:

    7. The getName method needs to return a unique name for the Service or response, as in the following example:

    8. The getShortDescription method must return the description string that will be shown in the user interface, as in the following example:

    9. The setupPropertyDescriptors method needs to return individual property descriptors for each property, which affects how those properties are displayed in the RulePoint user interface. The parent method must be invoked, as in the following example:

    10.In this method, define a PropertyDescriptor for each property in each Service or response, and then return the descriptors, as in the following example.

    return "com.agentlogic.sdk.sample.TemperatureSourceService";

    return "City Temperature";

    return "temperature";

    return "Provides the current temperature for a given city";

    descriptors = super.setupPropertyDescriptors(descriptors);

    try{ PropertyDescriptor descriptor = new PropertyDescriptor("[uniqueName]", [className], "get[uniqueName]", "set[uniqueName]"); descriptor.setDisplayName("[displayName]"); descriptor.setShortDescription("[description]"); // make it a required property (i.e., show a red asterisk next to it) descriptor.setPreferred(true); // show in the UI descriptor.setBound(true); descriptors.add(descriptor); descriptor.setValue("order", "10"); descriptors.add(descriptor);}catch (Exception ex){ ex.printStackTrace();}return descriptors;

  • CHAPTER 2, CREATING NEW SERVICES CREATING CORRESPONDING BEANINFOBASE CLASSES

    30 Agent Logic RulePoint Developer’s Guide Release 20090511

    In this location... Specify the following...

    [uniqueName] The unique name for the property. This is not the name that will display in the user interface.

    [className] The name of the sibling class, appended with .classget[uniqueName] The unique name for the property. This identifies the

    getter method for the entity’s bean property.set[uniqueName] The unique name for the property. This identifies the

    setter method for the entity’s bean property.[displayName] The name of the property as you want it to display in

    the RulePoint user interface.[description] The description of this property as you want it to

    display in the RulePoint user interface.descriptor.set Preferred

    Whether this property is required. If you set this to true, the user will be required to specify a value. This will be indicated by a red asterisk next to the property name in the user interface.

    descriptor.set Bound

    Set this to true to display this property in the user interface.

    descriptor.set Value

    The order in which you want this property to display in the RulePoint user interface.Lower values will display first on the user interface. For example, if you want this property to display first, you would set this value to 1. If you wanted it to display last, but were unsure of the exact number to set, you could specify a much higher number so that it would always display last.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 31

    CREATING CORRESPONDING BEANINFOBASE CLASSES CHAPTER 2, CREATING NEW SERVICES

    The following code is an example of a PropertyDescriptor for the City property of the TemperatureSourceService:

    The descriptors List adds each PropertyDescriptor to its collection of PropertyDescriptors for this Service or response.

    You now are ready to deploy the Services and Responses. For steps to do so, see Chapter 3‚ “Deploying New Services,” starting on page 33.

    try{ PropertyDescriptor descriptor = new PropertyDescriptor("city", com.agentlogic.sdk.sample.TemperatureSourceService. class, "getCity", "setCity"); descriptor.setDisplayName("City"); descriptor.setShortDescription("Enter the city whose temperature should be looked up"); // make it a required property (i.e., show a red asterisk next to it) descriptor.setPreferred(true); // show in the UI descriptor.setBound(true); descriptors.add(descriptor);}catch (Exception ex){ ex.printStackTrace();}

  • CHAPTER 2, CREATING NEW SERVICES CREATING CORRESPONDING BEANINFOBASE CLASSES

    32 Agent Logic RulePoint Developer’s Guide Release 20090511

  • Agent Logic RulePoint Developer’s Guide Release 20090511 33

    CHAPTER 3 DEPLOYING NEW SERVICES

    This chapter describes how to deploy a new Service in RulePoint®. This chapter includes the following topics:

    • Overview (on page 34)• Creating a .jar File from the New Class Files (on page 34)• Adding the Bean Entries for Each New Class (on page 34)

  • CHAPTER 3, DEPLOYING NEW SERVICES OVERVIEW

    34 Agent Logic RulePoint Developer’s Guide Release 20090511

    Overview After creating new Services and responses, you must deploy them into RulePoint using the steps provided in this chapter.

    To deploy your newly created Services and responses, you need to complete the following steps:

    I. Create a .jar file from the new class files.II. Add the bean entries for each new class.

    Creating a .jar File from the

    New Class Files

    To deploy your Service and response classes to RulePoint, you must create a .jar file from your new class files.

    1. Create a .jar file containing all of the Service and response classes that you have created.

    2. If a Service or response requires additional third-party libraries to function in RulePoint, you must place those libraries in the following directory:

    3. Place the .jar file in the following directory:

    Adding the Bean Entries

    for Each New Class

    To make RulePoint aware of your new Service and response classes and have the classes reflected in the user interface, you must update the services-custom.xml file by adding the bean entries for each new class.

    TO UPDATE THE SERVICES-CUSTOM.XML FILE:

    1. Locate and open the services-custom.xml file in the following directory.

    [RulePointHome]\WEB-INF\lib

    [RulePointHome]\WEB-INF\lib

    NOTEIf you are using the provided build.xml file in conjunction with Apache Ant, compiling, creating, and deploying the .jar file will be taken care of for you.

    NOTEIf you are creating a new services-custom.xml file, you can use the sample services custom template (sample-services-custom.xml), located in the AL_RulePoint-Custom-Services folder and add your beans.

    [RulePointHome]\WEBINF\spring

  • Agent Logic RulePoint Developer’s Guide Release 20090511 35

    ADDING THE BEAN ENTRIES FOR EACH NEW CLASS CHAPTER 3, DEPLOYING NEW SERVICES

    2. For each new class, add a bean entry to the file using the following entry as a template:

    For example, adding a new class for the sample TemperatureSourceService requires the following entry:

    3. Restart your web application server to restart RulePoint.

    For this value... Specify...

    bean id (required) The return value of the getName () method in the BeanInfoBase class or sub-class for the Service or response.

    class (required) The package name and class name for the Service or response

    singleton (required) Options: true or false. The option false indicates that multiple instances of this Service can be created. true indicates that only one instance of this Service can be created.In most cases, this value should be set to false. For example, if you create an email Service, you would want to allow users to create more than one instance of that Service, so this value would be false.

    property name The name of a property for which you want to pre-populate a default value for this Service in the user interface.You can specify multiple properties.

    value The value of the property name property.

  • CHAPTER 3, DEPLOYING NEW SERVICES ADDING THE BEAN ENTRIES FOR EACH NEW CLASS

    36 Agent Logic RulePoint Developer’s Guide Release 20090511

  • Agent Logic RulePoint Developer’s Guide Release 20090511 37

    CHAPTER 4 RULEPOINT REST EXTENSION

    This chapter describes how you can install and use the RulePoint® REST Extension. The REST extension is intended to enable remote communications between the RulePoint Java API Adapter and the RulePoint server. This chapter contains the following topics:

    • Overview (on page 38)• Installing the RulePoint REST Extension (on page 38)• Authentication (on page 39)

  • CHAPTER 4, RULEPOINT REST EXTENSION OVERVIEW

    38 Agent Logic RulePoint Developer’s Guide Release 20090511

    Overview RulePoint REST Extension facilitates the creation and exchange of XML files between the RulePoint server and the RulePoint Java API Adapter. However, connections to the RulePoint server require authentication. For more information on authentication, see Authentication (on page 39).

    Installing the RulePoint REST

    Extension

    Installing the RulePoint REST Extension requires the following three simple steps:

    1) Install the RulePoint 4.0 Service Pack 1 if it is not already installed.

    2) Unzip the file: "AL_RulePoint-REST-Extension_1.0.zip" to the directory location where your existing RulePoint 4.0 product is installed.

    As an example, for Tomcat (Windows), the path is as follows:

    %CATALINA_HOME%\webapps\

    As an example, for WebLogic server (assuming RulePoint is installed in a WebLogic server domain named: agentlogic), the path is as follows:

    C:\bea\user_projects\domains\agentlogic\

    3) Enable the REST API Extension in RulePoint:

    a) Edit RulePoint's ..\rulepoint\WEB-INF\web.xml file and ensure that the following section is uncommented:

    spring/api-dispatcher com.agentlogic.web.DispatcherFilter servlet-class com.agentlogic.web.ShyDispatcherServlet spring/api-dispatcher /api/* REQUEST FORWARD INCLUDE

    NOTEYou must ensure that you employ the "Overwrite" option within the unzip utility you are using in order to properly replace all existing files of the same name.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 39

    AUTHENTICATION CHAPTER 4, RULEPOINT REST EXTENSION

    A sample file named "web.xml.restapi.sample" is provided within the package and should be REMOVED from the WEB-INF directory once the web.xml file update is complete.

    b) Ensure the value ees.extensions.RESTAPIExtensionInfo appears in the comma-separated list of class names associated with the property key rulepoint.extensions in the file WEB-INF\extension.properties: rulepoint.extensions=ees.extensions.RESTAPIExtensionInfo

    Authentication Before you can begin executing the RulePoint REST Extension functions, you must establish an authenticated session with the RulePoint server.

    Establishing an Authenticated Session with the RulePoint Server

    To establish an authenticated session with the RulePoint server, follow these steps:

    Executing the HTTP GET

    Run the following HTTP GET:

    URL: http://[hostname][:port]/rulepoint/login.jsp

    Comment: Load the form. You can expect a 200 HTTP response code.

    Executing the HTTP POST

    Run the following HTTP POST:

    URL: http://[hostname][:port]/rulepoint/

    Content-Type: application/x-www-form-urlencoded

    Arguments to post:

    • j_username: enter a valid user name• j_password: enter a valid password

    Examining the Headers of the response

    If authentication failed, examine the following headers:

    • RULEPOINT_AUTHENTICATION_ERROR_CODE (an error code identifying the cause of failure)

    • RULEPOINT_AUTHENTICATION_ERROR_MSG (an error message identifying the cause of failure)

    Ensure that you retain the jsessionid cookie that is returned by step 1, and resubmit it with every subsequent request. This is used by RulePoint to validate your session. If

    NOTEExpect a 302 HTTP response code and a redirect url of http://[hostname][:port]/rulepoint/

  • CHAPTER 4, RULEPOINT REST EXTENSION AUTHENTICATION

    40 Agent Logic RulePoint Developer’s Guide Release 20090511

    your client does not support cookies, try including the cookie in the URL. See the following example:

    http://[server]/rulepoint/api/rules; jsessionid=B19AE18712FA4D8E687BEA7B70681343;?status=favorite

  • Agent Logic RulePoint Developer’s Guide Release 20090511 41

    CHAPTER 5 RULEPOINT JAVA API ADAPTER

    This chapter describes the benefits of RulePoint® Java API Adapter. It shows you how to install and use the Java API Adapter. The chapter covers the following topics:

    • Overview (on page 42)• Using the Java API Adapter (on page 42)• Creating Your First RulePoint Application (on page 43)• Sample Code (on page 44)

  • CHAPTER 5, RULEPOINT JAVA API ADAPTER OVERVIEW

    42 Agent Logic RulePoint Developer’s Guide Release 20090511

    Overview The RulePoint® Java API Adapter is a Java software module that simplifies the task of interacting with the RulePoint REST Extension. This Java API Adapter offers the following benefits:

    • Includes XML parsers and generators that are compatible with the XML Schema exposed by the RulePoint REST Extension.

    • Includes an entire suite of Java that model all of the entities that exist within RulePoint.

    • Includes a single API class (com.agentlogic.rulepoint.wrapper.api .RulePointAPI) that provides a simple programmatic interface for accessing RulePoint functionality.

    • Provides simple, structured, localizable error handling.

    Using the Java API Adapter

    Before you install the RulePoint Java API Adapter 1.0, there are few things you are required to have in place.

    Prerequisites

    The RulePoint Java Connector requires that you have a running instance of RulePoint 4.0, and have installed the RulePoint REST Extension 1.0. You can verify this by performing the following steps:

    • Login to RulePoint as a user with administrative permissions.• Click on the Administration option (top-right).• Select System Information from the Administration menu.• Verify that the RulePoint REST Extension is listed in Installed Extensions.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 43

    CREATING YOUR FIRST RULEPOINT APPLICATION CHAPTER 5, RULEPOINT JAVA API ADAPTER

    What’s in the Zipped Package

    Unzip the contents of RulePoint-JavaAPI-Adapter_1.0.zip to your work folder (for example, C:\api). This zip file includes the following files:

    RulePointJavaAPIAdapterJavaDoc.zip The JavaDoc for the API.bin/config.properties A sample configuration file for the Java API

    Adapter.lib/RulePointJavaAPIAdapter.jar The RulePoint Java API Adapter classes.lib/commons-codec-1.3.jar The Apache Commons Codec library required by

    the RulePoint Java API Adapter.lib/commons-httpclient-3.0.1.jar The Apache HttpClient library required by the

    RulePoint Java API Adapter.lib/commons-logging-1.0.4.jar The Apache logging library required by the

    RulePoint Java API Adapter.

    Creating Your First RulePoint

    Application

    Creating your first RulePoint application requires two basic steps: setting your classpath and editing your configuration property file.

    Setting Your Classpath

    When creating your Java project, ensure that the following files are included in your classpath:

    Editing the Configuration Property File

    Edit the configuration property file bin/config.properties by ensuring that the following element is configured with the correct URL to communicate with RulePoint. Also, ensure that the URL includes a trailing slash ‘/’ character:

    RulePoint.Base.URL=http://[localhost]:[port]/rulepoint/

    bin/config.properties

    lib/RulePointJavaAPIAdapter.jar

    lib/commons-codec-1.3.jar

    lib/commons-logging-1.0.4.jar

  • CHAPTER 5, RULEPOINT JAVA API ADAPTER SAMPLE CODE

    44 Agent Logic RulePoint Developer’s Guide Release 20090511

    Sample Code The following source code demonstrates how to login to RulePoint, create a rule, list all rules and then log out.

    You must create a response named “RTAM Alert” in RulePoint before attempting to execute this code; otherwise, a RulePointException will be thrown at run time.

    import java.util.ArrayList;import java.util.List;import com.agentlogic.rulepoint.wrapper.api.RulePointAPI;import com.agentlogic.rulepoint.wrapper.dao.query.EntityQuery;import com.agentlogic.rulepoint.wrapper.dao.query.SortDirection;import com.agentlogic.rulepoint.wrapper.error.RulePointException;import com.agentlogic.rulepoint.wrapper.vo.AccessControlListVO;import com.agentlogic.rulepoint.wrapper.vo.AccessControlListVOImpl;import com.agentlogic.rulepoint.wrapper.vo.AccessControlVO;import com.agentlogic.rulepoint.wrapper.vo.AccessControlVOImpl;import com.agentlogic.rulepoint.wrapper.vo.Permission;import com.agentlogic.rulepoint.wrapper.vo.RuleVO;import com.agentlogic.rulepoint.wrapper.vo.RuleVOImpl;import com.agentlogic.rulepoint.wrapper.vo.Status;import com.agentlogic.rulepoint.wrapper.vo.attribute.RuleVOAttribute;/**

    * A simple application that performs the following steps:

    *

    * 1) Login to RulePoint

    * 2) Create a rule

    * 3) Load a list of rules

    * 4) Logout of RulePoint

    */

    public class HelloRulePoint {public static void main (String[] args) {

    // Construct a new RulePointAPI that will be initialized with a default configura-tion that can be overridden by the contents of config.properties.

    RulePointAPI api = new RulePointAPI();try {

    // login user=admin, password=admin, locale=en_US

    api.login("admin", "admin", "en_US");

  • Agent Logic RulePoint Developer’s Guide Release 20090511 45

    SAMPLE CODE CHAPTER 5, RULEPOINT JAVA API ADAPTER

    // build a rule to create in RulePoint

    RuleVO rule = new RuleVOImpl();// generate a unique name for the rule

    rule.setName("Hello World rule "+System.currentTimeMil-lis());

    rule.setDescription("This is the first RulePoint rule that I have "

    +"created using Java");

    // IMPORTANT NOTE: The following rule references the "RTAM Alert" response. Therefore, the RTAM Alert response must exist in RulePoint before we attempt to create this rule; otherwise, a RulePointException will be thrown.

    rule.setDrql("when 1 news then \"RTAM Alert\"");

    // Build the access control list for this rule.This access control grants adminis-tration rights to the current user

    AccessControlVO myAccess = new AccessControlVOImpl();myAccess.setPermission(Permission.ADMIN);

    myAccess.setGranted(true);myAccess.setPrincipal(api.getCurrentUser().getUnique-

    Name());

    // This access control grants read permission to the user identified by the unique name 'demo'.

    AccessControlVO demoAccess = new AccessControlVOImpl();demoAccess.setPermission(Permission.READ);

    demoAccess.setGranted(true);demoAccess.setPrincipal("demo");

    // Build the access control list

    AccessControlListVO acl = new AccessControlListVOImpl();List list = new ArrayList();

    list.add(myAccess);

    list.add(demoAccess);

    acl.setEntries(list);

    rule.setACL(acl);

    // Add this rule to the list of favorites

    rule.setStatus(Status.FAVORITE);

    // Create the rule

    RuleVO savedRule = api.createAdvancedRule(rule);

    System.out.println("Created rule with ID "+savedRule.getId());

  • CHAPTER 5, RULEPOINT JAVA API ADAPTER SAMPLE CODE

    46 Agent Logic RulePoint Developer’s Guide Release 20090511

    // list up to the first 10 rules, sorted by ascending name.

    int page = 1;int pageSize = 10;EntityQuery query = new Entity-

    Query(

    Status.ALL,

    page,

    pageSize,

    RuleVOAttribute.NAME,

    SortDirection.ASCENDING);

    System.out.println("Loading rules");

    RuleVO[] allRules = api.getRuleList(query);

    System.out.println("Loaded "+allRules.length+" rule(s)");

    for (RuleVO r : allRules) {System.out.println("id="+r.getId()

    +" name="+r.getName()

    +" description="+r.getDescription()

    +" drql="+r.getDrql()); }

    // logout RulePoint

    api.logout();

    } catch (RulePointException ex) {ex.printStackTrace(System.err);

    }

    }

    }

  • Agent Logic RulePoint Developer’s Guide Release 20090511 47

    APPENDIX A CHANGES AND CUSTOM SERVICES

    This appendix describes changes and enhancements introduced in the RulePoint® 4.0 SDK that impact all custom services currently installed.

    This appendix covers the following topics:

    • Changes (on page 48)• Enhancements (on page 48)

  • APPENDIX A, CHANGES AND CUSTOM SERVICES CHANGES

    48 Agent Logic RulePoint Developer’s Guide Release 20090511

    Changes The RuleContext class has been refactored into a new package. The new package name is:

    com.agentlogic.rulepoint.engine.RuleContext

    As a result, any class that imports the RuleContext object must be modified to import from this new package. It is important to note that any class that extends ValueAnalytic, ObjectAnalytic, BooleanAnalytic, or AbstractService must be recompiled.

    Enhancements One major enhancement was implemented in the current release of RulePoint. The session recoverability capability was built to allow RulePoint to automatically reconnect to a remote server in case of an error.

    Session Recoverability

    RulePoint 4.0 provides enhanced support for session recoverability. When a connection error occurs, RulePoint will automatically try to reconnect to the remote server. The user can specify how many times, and how frequently RulePoint should attempt to reconnect by specifying new bean properties. The properties are:

    • retryCount – The number of times RulePoint will attempt to reconnect to the remote server.

    • retryDelay – The number of milliseconds that RulePoint will wait between attempts to reconnect.

  • Agent Logic RulePoint Developer’s Guide Release 20090511 49

    ENHANCEMENTS APPENDIX A, CHANGES AND CUSTOM SERVICES

    To utilize this enhancement, a custom service must extend ees.io.AbstractService. Also, the custom service must invoke the retryController() method as part of its connection process. For example, the following code snippet implements the session recoverability feature:

    The retryController() method will compare the loopCount value to the retryCount value specified in the custom service’s bean properties. As long as the retryCount has not been reached, a warning message (prefixed with the “continuation error code”) will be logged. The method will then sleep for the number of milliseconds specified in the retryDelay property, and then return normally. When the retryCount is reached, a RuntimeException (prefixed with the “fatal error code”) is thrown.

    int loopCount = 0;while( true ) { loopCount++;

    try {connectToRemoveServer();

    break;

    } catch (Exception e) { if ((e.getCause() != null) &&

    (e.getCause() instanceof InterruptedException)) throw (InterruptedException)e.getCause(); retryController(loopCount,

    "MyService - " + getInstanceName(),

    “MyService0100”,

    //Continuation error code

    “MyService0101”,

    //Fatal error code

    e);

    }

    }

    NOTEThis code snippet bypasses the recoverability process if RulePoint is terminating (indicated by an InterruptedException).

  • APPENDIX A, CHANGES AND CUSTOM SERVICES ENHANCEMENTS

    50 Agent Logic RulePoint Developer’s Guide Release 20090511

    Batch Processing

    RulePoint 4.0 provides support for batch processing of Events. This means that a custom service can indicate that multiple Events should be considered a single unit of work. A ‘batch’ is considered to be completed when all Events in the batch have been completely processed, including all rule activations. To indicate that multiple Events should be considered a single unit of work, the custom service must do the following tasks:

    1. Create a new batch or join an existing batch

    You do so by invoking the BatchEventListener.createBatch() method with these parameters:

    batchName – the unique name of the batch

    batchListener – a reference to a class that implements the BatchCompletionListener or null if you do not wish to receive a batch com-pletion notification.

    UNIQUE | JOIN | FAIL

    UNIQUE – Create a unique batch instance for this batchName

    JOIN – Join an existing batch instance if one exists for this batchName. Create a new batch instance if none exist. FAIL – Throws a BatchProcessingException if a batch instance exists for this batchName

    The createBatch() method returns a String containing the unique batchId that must be provided on all subsequent method calls.

    2. Invoke the batchPublish() method of the BatchEventPublisher class

    The custom service’s eventPublisher object must be cast to a BatchEventPublisher object. The BatchEventPublisher class provides several batchPublish() methods whose signatures match the signatures of the publish() methods of the EventPublisher class. The unique batchId returned by the createBatch() method must be supplied here.

    3. Notify the BatchEventPublisher when it has published its last event

    Invoke the setBatchComplete() method of the BatchEventPublisher object. (The custom service’s eventPublisher object must be cast to a Batch-EventPublisher object.) The unique batchId returned by the

  • Agent Logic RulePoint Developer’s Guide Release 20090511 51

    ENHANCEMENTS APPENDIX A, CHANGES AND CUSTOM SERVICES

    createBatch() method must be supplied here.

    The custom service can be notified when the batch has completed by implementing the BatchCompletionListener interface. The onBatchCompletion() method from the custom service is invoked when the batch completes. The unique batchId is passed into this method. The onBatchCompletion() method can perform any cleanup tasks at this time.

    Batch Co