OSWorkflow A guide for Java developers and architectsto integrating open-source Business Process Management Diego Adrian Naya Lazo BIRMINGHAM - MUMBAI OSWorkflow Copyright © 2007 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: August 2007 Production Reference: 1210807 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-847191-52-6 www.packtpub.com Cover Image by Vinayak Chittar ([email protected]) Credits Author Project Manager Diego Adrian Naya Lazo Patricia Weir Reviewers Project Coordinator Gabriel Bruno Abhijeet Deobhakta Hani Suleiman Juan Pedro Danculovic Indexer Mithil Kulkarni Development Editor Nanda Padmanabhan Proofreader Chris Smith Assistant Development Editor Rashmi Phadnis Production Coordinators Manjiri Nadkarni Technical Editors Shantanu Zagade Rashmi Phadnis Saurabh Singh Cover Designer Shantanu Zagade Editorial Manager Dipali Chittar About the Author Diego Naya Lazo is a Chief Enterprise Architect living in Buenos Aires, Argentina. He currently works for Argentina's biggest healthcare provider and has more than 10 years of experience in the IT industry. He has participated in several projects as a hands-on software architect and performed the technical lead role in many companies. His interest in computer programming began with his desire to create the most vivid 3D animations as a graphic designer at the age of 15. His interests range from Enterprise Architecture to SOA and BPM technology. He is a Sun Certified Enterprise Architect and holds other certifications such as: SCJP, SCWCD, MCSA, and Security+. He is also a member of the WWISA and GEAO enterprise architects' associations as well as an active developer of the OSWorkflow project. He holds a Bachelors degree in IT and is currently enrolled in an MBA program. Away from work, Diego enjoys traveling all around the world with his family. You can reach him at [email protected]. I want to thank Gustavo Aguirre, my role model and mentor, for giving me advice and my reviewers Juan Pedro Danculovic and Gabriel Bruno, for loving this as much as I do. Hani Suleiman, for your commitment to the project and the whole OSWorkflow team. This book is dedicated to Mariela and Mauro—You are the light that shines on my path through life. About the Reviewers Gabriel A. Bruno lives in Argentina and has been working since 1997 in the IT industry. Among his various activities are consulting services in many companies, mainly in the financial industry, and he also has performed activities as an instructor of OO analysis and design, and data structures. In 1998 he discovered the open-source world through the GNU Linux operating system, which he adopted to perform his duties. Two years later, he began to use Java and subsequently the J2EE platform professionally. He's currently working as a Java Architect for an important health insurance company in Argentina. I greatly thank Diego Naya for including me in this endeavor. Hani Suleiman is the CTO of Formicary, a company specializing in integration and portal solutions for financial firms. He also is an elected individual member of the JCP Executive Committee, as well as serving on a number of enterprise-related Expert Groups. Juan Pedro Danculovic received his Computer Science Analyst degree at the UNLP-La Plata, Argentina in 2001. He has researched in several areas such as object-oriented and web applications design, and also web personalization aspects in web services and applications. He has also taught web application architecture aspects courses at the UNLP. He is currently working in the IT Architecture department at the biggest health care services company in Argentina. Table of Contents Introduction 1 Chapter 1: BPM and Workflow Basics 5 Business Process Orientation 5 BPR and BPM 6 Business Process Improvement 7 What's a BPMS? 8 Traceability and Auditing 10 Different Kinds of BPMS 11 System Orchestration with System-Oriented BPMS 12 System Orchestration 13 Enabling Workgroup Collaboration with People-Oriented BPMS 15 Components of a BPM Solution 16 The Workflow Management Coalition 17 How Components Map to the BPM Lifecycle 19 Open-Source BPMS 20 Summary 20 Chapter 2: OSWorkflow Introduction and Basics 21 Downloading and Installing OSWorkflow 21 Getting a Taste from the Distribution 22 Navigating the Sample User Interface 22 OSWorkflow Basics 27 XML Definition Files 27 An Example Workflow 28 Steps, Actions, and Results: The Workflow Building Blocks 29 Testing the Workflow Definition 33 Splits and Joins 34 Setting Status and Old Status Values 37 Sending an Email Automatically 38 Table of Contents Visual Process Modeling 43 Visually Creating the Holiday Example 43 Looking at the End Result 47 Ways to Implement OSWorkflow 48 OSWorkflow as a Workflow Layer 48 OSWorkflow as a Centralized Workflow Server 48 Adding the SOAP Bindings 49 Summary 50 Chapter 3: Adding Code to our Definitions 51 How to Deal with Transient Data 51 Variable Interpolation in the Definition 52 PropertySet and Transient Variables 53 Exploring PropertySet 53 Using the PropertySet to Store Variable Data 54 Using the PropertySet to Retrieve Stored Data 54 Cleaning the PropertySet 55 Configuring the PropertySet 55 Adding Code to our Definition 56 FunctionProviders 56 Creating our first FunctionProvider 56 FunctionProvider Types 58 Defining a Custom Function Provider 58 BeanShell Scripting 60 Built-in Functions 60 Conditions 61 Creating our own Condition 62 Registers 64 Using the LogRegister 64 Implementing a Register 65 Validators 65 Creating a Customer Identifier Validator 66 BeanShell Validators 66 Other Useful Descriptor Concepts 67 Finish Actions 67 Auto Actions 68 Summary 68 Chapter 4: Using OSWorkflow in your Application 69 OSWorkflow Configuration 69 Registering our Process Descriptors 69 Embedding OSWorkflow into your Application 71 Starting a Workflow 71 Executing Actions 72 [ ii ] Table of Contents What's the Status? 72 What can I Do? 73 The Useful Abstract States 73 Querying the Workflow Store 74 Querying the Workflow Factory 75 Inspecting the Workflow Descriptor from Code 76 Using the Workflow Configuration Object 76 Workflow Interface Implementations 77 Loading the Descriptors—the Workflow Factory 77 Loading Descriptors from a Database 78 Persisting Instance Information 79 Persistence Choices 79 Configuring the JDBC Store 80 PropertySet Persistence 81 Configuring the JDBC PropertySet 81 Unit Testing your Workflow 82 What is JUnit? 82 Running the Tests 85 Integrating with Spring 85 The Object Registry—BeanFactory 86 Using our BeanFactory 89 Transaction Support in Spring 90 The SpringTypeResolver 92 Workflow Security 93 Step Permissions 93 Action Restrictions 94 Step Ownership 95 Extending User and Group Authentication and Authorization 95 Summary 97 Chapter 5: Integrating Business Rules with JBoss Rules 99 Incorporating Business Logic into Business Processes 99 Simple Logic with Conditional Results 100 Complex Business Logic 104 What is "JBoss Rules"? 104 Creating a Rule 105 Executing a Rule 106 Integrating with OSWorkflow 107 RulesCondition 107 RulesFunctionProvider 112 Summary 113 [ iii ]
Description: