Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 44585 invoked from network); 4 Oct 2004 16:38:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 4 Oct 2004 16:38:49 -0000 Received: (qmail 4515 invoked by uid 500); 4 Oct 2004 16:38:46 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 4412 invoked by uid 500); 4 Oct 2004 16:38:44 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 4399 invoked by uid 99); 4 Oct 2004 16:38:44 -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.200 as permitted sender) Received: from [64.233.170.200] (HELO mproxy.gmail.com) (64.233.170.200) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 04 Oct 2004 09:38:42 -0700 Received: by mproxy.gmail.com with SMTP id 74so624340rnl for ; Mon, 04 Oct 2004 09:38:40 -0700 (PDT) Received: by 10.38.208.76 with SMTP id f76mr2558033rng; Mon, 04 Oct 2004 09:38:39 -0700 (PDT) Received: by 10.38.72.39 with HTTP; Mon, 4 Oct 2004 09:38:37 -0700 (PDT) Message-ID: Date: Mon, 4 Oct 2004 09:38:37 -0700 From: Craig McClanahan Reply-To: Craig McClanahan To: Jakarta Commons Developers List , mstanley@mstanley.net Subject: Re: sandbox proposal. Events In-Reply-To: <1096903155.17783.142.camel@godel.cauldronsolutions.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <1096903155.17783.142.camel@godel.cauldronsolutions.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Mike, This pattern does indeed sound interesting. You might also want to take a look at the [pipeline] sandbox package (contributed by Kris Nuttycombe) that I checked in over the weekend. It offers a different tack on handling asynchronous events, and is also investigating how an interaction with [chain] might be beneficial. >From a practical perspective, there exists already a sandbox package named [events], originally extracted from [collections]. I haven't been tracking whether this is actually active or not; if so, we'd need to use some different top level name for the package itself. Craig On Mon, 04 Oct 2004 11:19:15 -0400, Mike Stanley wrote: > I've implemented a pattern, somewhat based off the .NET event and > delegate pattern, however the pattern is also commonly seen in > frameworks (to some extent). > > At a high level, the pattern is made up of two objects: > - Event > - DelegateMethod > > The Event is a container for DelegateMethods. Delegate Methods are > registered with the Event (added to the container). The first delegate > method added to the container determines the contract for that event. > I.e. each method added must have similar signatures (take the same > number and types of parameters and return the same type). At any time > the event can be fired. When an event is fired it invokes the delegate > methods in the order they were added. The event can be configured to > fail on first exception, or continue without failing. If the delegate > methods return a value, the last value would be returned (this is the > behavior of the .NET approach. I'm open to other suggestions). > > A Delegate Method gets created with an instance of an object and the > name of the method (optionally when instantiating the Delegate Method > you may specify the signature - or actual Method, in the case that there > are multiple methods with the same name but different signatures). This > method will be invoked using reflection (delegateMethod.invoke(args)) > when the event is fired. > > At it's core this is the basic idea. Above this, there are (*plans*) to > create Asynchronous Delegate Methods and events, providing simple > support for multi-threaded events. This will use the same concepts from > .NET (callbacks, begin invokes, end invokes, async results, etc). > > I'm also investigating migrating the pattern to utilize "commons-chain". > > Currently this does not exist as a stand-alone library. However, if > there is interest, I will begin to pull it out and contribute it to the > commons-sandbox. > > - Mike > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org