Return-Path: Delivered-To: apmail-incubator-directory-dev-archive@www.apache.org Received: (qmail 25756 invoked from network); 22 Sep 2004 09:47:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 22 Sep 2004 09:47:26 -0000 Received: (qmail 77255 invoked by uid 500); 22 Sep 2004 09:47:25 -0000 Delivered-To: apmail-incubator-directory-dev-archive@incubator.apache.org Received: (qmail 77168 invoked by uid 500); 22 Sep 2004 09:47:25 -0000 Mailing-List: contact directory-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list directory-dev@incubator.apache.org Received: (qmail 77152 invoked by uid 99); 22 Sep 2004 09:47:24 -0000 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=FROM_ENDS_IN_NUMS,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of aok123@bellsouth.net designates 205.152.59.70 as permitted sender) Received: from [205.152.59.70] (HELO imf22aec.mail.bellsouth.net) (205.152.59.70) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 22 Sep 2004 02:47:24 -0700 Received: from [172.16.1.8] ([65.80.200.112]) by imf22aec.mail.bellsouth.net (InterMail vM.5.01.06.11 201-253-122-130-111-20040605) with ESMTP id <20040922094722.OBHI219.imf22aec.mail.bellsouth.net@[172.16.1.8]>; Wed, 22 Sep 2004 05:47:22 -0400 Subject: Re: [seda] event notifier pattern clarification From: Alex Karasulu To: Trustin Lee Cc: Apache Directory Developers List In-Reply-To: <768dcb2e040922020516fe10d0@mail.gmail.com> References: <1095831302.8617.176.camel@fermi.trunk.joshua-tree.org> <768dcb2e040922020516fe10d0@mail.gmail.com> Content-Type: text/plain Message-Id: <1095846629.8617.188.camel@fermi.trunk.joshua-tree.org> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Wed, 22 Sep 2004 05:50:29 -0400 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hey before my lights go out here's the goods: http://svn.apache.org/viewcvs.cgi?rev=47040&root=Apache-SVN&view=rev Change it and patch at will :-). Cheers, Alex On Wed, 2004-09-22 at 05:05, Trustin Lee wrote: > Alex and I talked alot on IRC and I agree with his opinion completely. > > > interface Advice { > > ... > > Subscription[] getSubscriptions(Event, Subscriptions[]); > > Event getEvent(Event); > > } > > This API has two problems: > > 1. Using array implies very frequent allocation of arrays which occurs > whenever EventRouter gets an advice. So I suggest to use some > reusable object. > > 2. EventRouter must call two methods (getSubscriptions and getEvent) > for each event, and it can imply duplicate calculation on the same > event. For example, let's assume that there is an advice that > transforms the specific type of event and filters its subscriptions, > then the 'if' block which identifies the type of the event is executed > twice, and it is an wate of time. > > so.. I suggest this method: > > public class RouterAdvice { > // assume getters and setters exist > Event event; > List subscriptions; > } > > public interface RouterAdvisor { // RouterAdvice in Alex's code > void getAdvice(RouterAdvice); > } > > RouterAdvisor.getAdvice() gets both event and subscriptions and then > sets back the transformed (or not transformed) event and modifies the > subscription list. > > the advantage of this method is: > > 1. RouterAdvice is reused (using threadlocal? not sure about this), so > there is less overhead on GC. > > 2. Can get RouterAdvice in a single method invocation, so there is no > duplicate code. > > but don't you think the name 'getAdvice' is strange? It does not have > a return type. :) > > Trustin