Return-Path: Delivered-To: apmail-incubator-directory-dev-archive@www.apache.org Received: (qmail 99780 invoked from network); 22 Sep 2004 09:06:05 -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:06:05 -0000 Received: (qmail 16027 invoked by uid 500); 22 Sep 2004 09:06:04 -0000 Delivered-To: apmail-incubator-directory-dev-archive@incubator.apache.org Received: (qmail 15984 invoked by uid 500); 22 Sep 2004 09:06:03 -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 15968 invoked by uid 99); 22 Sep 2004 09:06:03 -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 trustin@gmail.com designates 64.233.170.204 as permitted sender) Received: from [64.233.170.204] (HELO mproxy.gmail.com) (64.233.170.204) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 22 Sep 2004 02:06:02 -0700 Received: by mproxy.gmail.com with SMTP id 80so1525235rnk for ; Wed, 22 Sep 2004 02:05:55 -0700 (PDT) Received: by 10.38.11.80 with SMTP id 80mr151146rnk; Wed, 22 Sep 2004 02:05:55 -0700 (PDT) Received: by 10.38.8.17 with HTTP; Wed, 22 Sep 2004 02:05:55 -0700 (PDT) Message-ID: <768dcb2e040922020516fe10d0@mail.gmail.com> Date: Wed, 22 Sep 2004 18:05:55 +0900 From: Trustin Lee Reply-To: Trustin Lee To: Apache Directory Developers List Subject: Re: [seda] event notifier pattern clarification In-Reply-To: <1095831302.8617.176.camel@fermi.trunk.joshua-tree.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <1095831302.8617.176.camel@fermi.trunk.joshua-tree.org> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 -- what we call human nature in actually is human habit -- http://gleamynode.net/