Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 16116 invoked from network); 19 Oct 2004 17:14:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 19 Oct 2004 17:14:24 -0000 Received: (qmail 90675 invoked by uid 500); 19 Oct 2004 17:14:03 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 90524 invoked by uid 500); 19 Oct 2004 17:14:02 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 90375 invoked by uid 99); 19 Oct 2004 17:14:00 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of craigmcc@gmail.com designates 64.233.170.201 as permitted sender) Received: from [64.233.170.201] (HELO mproxy.gmail.com) (64.233.170.201) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 19 Oct 2004 10:13:58 -0700 Received: by mproxy.gmail.com with SMTP id 75so609803rnk for ; Tue, 19 Oct 2004 10:13:55 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=mf+j1++ikutcU8JaPYkhVeJAZJCCHHD6HCI6wC3uIRJFrCTuGb1sagFMV9vNlfxpHtMU3K9ziLRCinfsuvE55f/X7QUVJUkRdxR0x6IelYE14r92Qku/4J2QLP6PODHFABMqKOv1AX1yLyrMbesMRSFgt45ZFdRRqrS+8imW8T4 Received: by 10.38.152.39 with SMTP id z39mr2077967rnd; Tue, 19 Oct 2004 10:13:55 -0700 (PDT) Received: by 10.38.72.39 with HTTP; Tue, 19 Oct 2004 10:13:55 -0700 (PDT) Message-ID: Date: Tue, 19 Oct 2004 10:13:55 -0700 From: Craig McClanahan Reply-To: Craig McClanahan To: Jakarta Commons Users List Subject: Re: [chain] Is anybody out there using chain in a production system? In-Reply-To: <417528E3.60101@schof.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <41751DD5.2030607@indra.es> <417528E3.60101@schof.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Tue, 19 Oct 2004 10:46:59 -0400, Sean Schofield wrote: > [snip] > 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. > This is indeed a key consideration ... the price of making the method signature of a Command be generic is that the state of the computation is encapsulated in a "context". However, you do have an architectural choice in how you actually implement this, thanks to the fact that the base implementation of Context provided in [chain] supplies "attribute-property transparency": * Command implementations may treat the Context argument as an opaque Map, calling get() and put() operations with casts in the usual way. * The application architecture may supply subclasses of Context that include typesafe properties for application specific "well known" properties, but allows the use of generic accessors for everything else. The Command would have to cast the Context instance, but from there on gains type safety for the well known things. Indeed, [chain] supplies examples of the latter technique in the org.apache.commons.chain.web package, where predefined slots for things specific to using [chain] in a web environment are provided. My sense is that, no matter how generic we try to make our commands, we're always building in *some* level of assumptions about the contents of the Context (if nothing else, you have to agree on keys, for example). Therefore, I will tend to write application specific context classes for the most commonly shared attributes. It's also possible to think about Context items being used in more than one application specific context -- for that, you can define the typesafe properties contract for each application domain in an interface that extends Context, and then build an implementation that implements all of the interfaces. It's not perfect, but to me this approach seems like a reasonable tradeoff for the flexibility that [chain] gives you in composing the processing that will actually happen. Craig --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org