Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 96082 invoked from network); 3 Oct 2010 01:00:55 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Oct 2010 01:00:55 -0000 Received: (qmail 90930 invoked by uid 500); 3 Oct 2010 01:00:55 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 90835 invoked by uid 500); 3 Oct 2010 01:00:54 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 90827 invoked by uid 99); 3 Oct 2010 01:00:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Oct 2010 01:00:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Oct 2010 01:00:53 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o9310Wc7018826 for ; Sun, 3 Oct 2010 01:00:33 GMT Message-ID: <8602956.515071286067632961.JavaMail.jira@thor> Date: Sat, 2 Oct 2010 21:00:32 -0400 (EDT) From: "Phil Steitz (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (CHAIN-51) New Features for the project. In-Reply-To: <25999644.41931283791713418.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CHAIN-51?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917270#action_12917270 ] Phil Steitz commented on CHAIN-51: ---------------------------------- Sorry it has taken me a while to get back to this. I concur with Niall's suggestions. Santiago - does Niall's patch provide a workable framework for you? > New Features for the project. > ----------------------------- > > Key: CHAIN-51 > URL: https://issues.apache.org/jira/browse/CHAIN-51 > Project: Commons Chain > Issue Type: New Feature > Reporter: Santiago Basulto > Attachments: actions-src.rar, CHAIN-51-Alternative-Listener-proposal.patch > > Original Estimate: 240h > Remaining Estimate: 240h > > I'm proposing a change to the project. Did not know how to do it, so asked in the mailing list and told me to make the proposal here. > I'll comment a little about my changes. It needs a lot of refactoring and documenting, but i'd like to comment the main idea behind it, so you can give your opinion. I have faced some problems with names. I did not want to rename commons.chain classes, as a matter of respect, so some names can seem weird, it can change. > First of all, i needed more "control" over my commands. I like to have everything logged, and several commands were used in GUI apps, so i needed more User interaction. Then, i decide to provide the main Interface (Command) some other methods, just to can track what is it doing. I made a new interface called Action (i use the other name given to this pattern). I extend it from Command, just becouse i didn't want to change everything, and can keep using my old Commands. > This new Interface, Action, has two new methods: > void registerHandler(ActionHandler c); > boolean removeHandler(ActionHandler c); //true if the handler was present, false otherwise > The main idea behind this was to have a Handler object that can track the "moves and states" of the Action (or Command) class. It's something similar to the Observer Pattern. An action "can" (optionally, if doesn't want to register a handler, it's a simple Command) register a Handler, and comunicate things about itself. So, i have an Interface called ActionHandler. It has three methods: > > void start(Action a); > void done(Action a); > void fail(Action a,Exception e); > Then, for example, the action "can" invoke start method from its handler, to comunicate it that has started executing. It's really simple, but helped me big time. > Something great about the Action Interface, is that it only sais that you can register a handler, not the number of handlers. So, a Class implementing Action can register a number of handlers (file logger handler, GUI tool for comunicating the user, console logger, etc) and inform about the progress to all of them. If it's not needed to comunicate, this class can just execute silently. > So, this is the main change, but with this little change i needed to do something with the chain. So i just made the Chain interface extend the Action interface. Of course, can be another class, something like ActionChain that implements the Action Interface, and let Chain untouched. > I've attached a simpler version of my source code. With just the basic classes and a package for test it. I've developed some other classes, for example, Action implementations that register several ActionHandlers. I'm currently working on a "BlockingQueueChain", it's a chain that can execute all its Commands (or Actions) in parallel. Obviusly, there are not so many cases when this Chain can be used. If someone is interested i will can send the source code. > Ok, i think that's all. Hope you can tell me if this is a good idea, or not. Or simply, whether i should start a new "branch" of the project to no interfere with Commons Chain. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.