commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Schofield" <>
Subject Re: [chain] Is anybody out there using chain in a production system?
Date Tue, 19 Oct 2004 14:46:59 GMT

We are getting ready to use commons-chain in a production system.  I 
think it works quite well for certain problems.  You'll want to make 
sure you have the latest build because we just added a few things to it 
yesterday (also the javadoc on the commons-lang site does not mention 
these new classes.)

I think the main drawback to the chain of responsibility (COR) pattern 
is the lack of type safety (and transparency) that pops up in a typical 
implementation.  As you mentioned, commons-chain requires everything to 
be "jammed" into a context.

I have a few thoughts on how I plan to use commons-chain after 
considering the pros and cons.  You can take 'em or leave em.

I think chain is most appropriate when you can use it with only a 
limited number of objects in the context.  My application deals with 
documents (which are beans with lots of properties, some of which are 
beans themselves.)  So when a user wants to save changes to a document, 
I  have a chain for "saving".  Each command in the chain can check the 
part of the document that it is interested in and handle changes as it 
sees fit.  I've got one or two other objects in the context (such as 
"user") but its mostly just document.  None of my commands add anything 
or remove anything to the context because there is no assumption about 
what command is next in the chain.

I also have a chain for reading a document from the database.  I create 
an empty document object and put it into my context and then kick off 
the chain.  Each command populates the portion of the document its 
concerned with.  I don't really like the idea of my commands "returning" 
information through the context.  I limit myself to modifying at most 
one object in the context and make it clear that the chains only 
function is to modify that document (in the read case) or to read that 
document and perform some function (in the save case.)

Well there's some ideas for you. 


José Antonio Pérez Testa wrote:

> Hello all,
> I'm evaluating commons-chain to implement some sort of components.
> The idea is to have components fire events and those events be 
> processed in a xml configurable chain of execution.
> This schema allows me to insert processing commands in the flow of 
> execution dinamically and change from SimulatorExecutor to 
> RealExecutor, for example, or to insert a LoggerCommand that writes a 
> detailed log of the current event.
> In order to give flexibility to the system I have to put almost 
> everything in the Context of the Command Chain, that is implemented as 
> a Map. This way leads to a lack of robustness and ellegance in the 
> overall implementation.
> Anybody has faced the same dilema ??
> -------------------------------------------------------------------------------------------------------------------

> Este correo electrónico y, en su caso, cualquier fichero anexo al 
> mismo, contiene información de carácter confidencial exclusivamente 
> dirigida a su destinatario o destinatarios. Queda prohibida su 
> divulgación, copia o distribución a terceros sin la previa 
> autorización escrita de Indra. En el caso de haber recibido este 
> correo electrónico por error, se ruega notificar inmediatamente esta 
> circunstancia mediante reenvío a la dirección electrónica del remitente.
> The information in this e-mail and in any attachments is confidential 
> and solely for the attention and use of the named addressee(s). You 
> are hereby notified that any dissemination, distribution or copy of 
> this communication is prohibited without the prior written consent of 
> Indra. If you have received this communication in error, please, 
> notify the sender by reply e-mail
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message