Chain - Apache Commons - Apache Software Foundation
DUE TO SPAM, SIGN-UP IS DISABLED. Goto
Selfserve wiki signup
and request an account.
Apache Commons
Pages
Blog
Page tree
Browse pages
tachments (0)
Page History
Resolved comments
Page Information
View in Hierarchy
View Source
Export to PDF
Export to Word
Copy Page Tree
Jira links
Chain
Created by
ASF Infrabot
, last modified on
Sep 20, 2009
The Gang of Four's Chain of Responsibility (COR) behavioral design pattern is interesting and commonly used to model a set of operations. Each operation needs to be modeled as a command object and linked to others to form a chain. The command objects act upon some data and indicate whether the control should get passed to the next command in the chain. The benefit is that an operation can be added or removed easily without changing code. Jakarta Commons Chain models this design pattern as a reusable library.
You only need to provide individual objects which implement the Command interface and which make use of a Context object passed to each command in order to access shared data between commands. You can use a XML file to describe sequences of commands (i.e. a Chain) and assign them a name in order to invoke them easily or use them as individual commands within other chains.
Note: Chain is not a full workflow system. It does not have sophisticated flow of control between branches of chains or looping. However, it is also easier to get started with than most workflow systems and you can easily refactor existing code to fit within it. Editing the XML file to change the sequence of commands or alter the parameters passed to a command is also well within the realm of what many end users can do themselves without minimal instruction.
A Devx article with a simple one page overview of Chain is available here:
A fairly comprehensive pair of articles which focus
only
on the Commons Chain are at O'Reilly's
OnJava
site:
ONJava.com – A Look at Commons Chain, Part 1
ONJava.com – A Look at Commons Chain, Part 2
No labels
Overview
Content Tools
Atlassian Confluence Open Source Project License
granted to Apache Software Foundation.
Evaluate Confluence today
Atlassian Confluence
8.5.31
Printed by Atlassian Confluence 8.5.31
Report a bug
Atlassian News
Atlassian
{"serverDuration": 93, "requestCorrelationId": "8f41305a76dbb1b8"}
US