Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8CE272009F9 for ; Mon, 23 May 2016 14:34:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 8B58D160A0F; Mon, 23 May 2016 12:34:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AD5991609A8 for ; Mon, 23 May 2016 14:34:51 +0200 (CEST) Received: (qmail 91670 invoked by uid 500); 23 May 2016 12:34:50 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 91658 invoked by uid 99); 23 May 2016 12:34:50 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 May 2016 12:34:50 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1A4A8C0713 for ; Mon, 23 May 2016 12:34:50 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.179 X-Spam-Level: X-Spam-Status: No, score=0.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id mO1kWr_QTlvp for ; Mon, 23 May 2016 12:34:47 +0000 (UTC) Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 5AC385F396 for ; Mon, 23 May 2016 12:34:47 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id a136so19897819wme.0 for ; Mon, 23 May 2016 05:34:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=UNe9vZpz3c0TQGHuKUKMuULyg9fG7e213X9TiNws6Yk=; b=FuqoB7JdK2tQg+L4Nf0idbOm3X6JZ3DoQDpc29zwXVURBuCtZPKLk9itoVRTbfRrA7 ZyO9XvDZJ4Rkdx+irM7/zUXn9P7pJ27NZvRdbW8ln/XVvnwNUjZcQLDCC2DFvqUHMRn0 r00sSQdTxMmXndt0x79fp/+wMItbiPaCEucC03/n6k+ayBKUDLtJ80wQ4s96OmScNIJm MD517sXP4gZFW/bGwD47FRa9Dz0pOGk4pGylazqAew61crmUIjWak2qPOvCK0Mcan/aR bXglP8nFU3KdU8f7NYMqRnZTnSGxXkH9RXqRtC7jx4z7MBKzzCCPHbBmOjDoCt0DyK+b zprQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=UNe9vZpz3c0TQGHuKUKMuULyg9fG7e213X9TiNws6Yk=; b=KYppqKL5JXDxwJA4tSuHJ6ggVz1jUb6vwflzkjXSZi2FX6DeblQge8O/Bg3LprK7RH VgFqgStbBKeXAG7c4F8guPF2lF2izSsTW0g/53ri8iPYX4DEQQlPldaExn1wuorm03kN v3vnZMfZiOT9SrA1rJeNIeHSanweNPqslw8NXGytp7haL3U3Qfq7ttknEQdCM9O7NDXJ hCSbm9nwoUcEVeAcBA6Dd1grhkJxBI45o1zOO5udNMLGL1qfpd4/X89B7Lchz0IQUjCa VCrdOMjfLkfR7kXeS0OlsvJHNLJ/BV9zG3Tatfghvag5XrnzJO4MborsXdH8JFLiQv/g h3HQ== X-Gm-Message-State: AOPr4FXJ3WzZ5wrQ4hIRy3hrhj8++gfbGf0HSHKtYa/QlwSTwCtSsHlEj1TiNmvZi4rgl20u4Ynghy5ZDwEp+A== MIME-Version: 1.0 X-Received: by 10.28.154.73 with SMTP id c70mr17913651wme.12.1464006880989; Mon, 23 May 2016 05:34:40 -0700 (PDT) Received: by 10.194.227.161 with HTTP; Mon, 23 May 2016 05:34:40 -0700 (PDT) In-Reply-To: <1853430256.1023642.1464006583789.JavaMail.yahoo@mail.yahoo.com> References: <1853430256.1023642.1464006583789.JavaMail.yahoo@mail.yahoo.com> Date: Mon, 23 May 2016 14:34:40 +0200 Message-ID: Subject: Re: Annotation based DefaultProducer From: Luca Burgazzoli To: dev@camel.apache.org, Andrea Cosentino Content-Type: text/plain; charset=UTF-8 archived-at: Mon, 23 May 2016 12:34:52 -0000 I definitively need to improve my class name generator skills :-) I'll go with: - BaseSelectorProducer (abstract) - HeaderSelectorProducer (implementation) Thx guys. --- Luca Burgazzoli On Mon, May 23, 2016 at 2:29 PM, Andrea Cosentino wrote: > IMO the solution with > > BaseSelectorProducer (abstract) > HeaderSelectorProducer (implementation) > . > . > . > > is the best one. > -- > Andrea Cosentino > ---------------------------------- > Apache Camel PMC Member > Apache Karaf Committer > Apache Servicemix Committer > Email: ancosen1985@yahoo.com > Twitter: @oscerd2 > Github: oscerd > > > > On Monday, May 23, 2016 2:26 PM, Claus Ibsen wrote: > On Mon, May 23, 2016 at 2:19 PM, Luca Burgazzoli wrote: >> What would be a nice name for this new producer ? >> > > Yeah naming ;) > > Brain storming > > SelectorProducer > HeaderBasedSelectorProducer > SwitchProducer > SwitchByHeaderProducer > > > > We could also generalize it and have a base class and then a header > based implementation, in case we get other "selectors" in the future > that select by something else than a header. > > BaseSelectorProducer (abstract) > HeaderSelectorProducer (implementation) > > > But yeah naming is not so easy. > > > >> --- >> Luca Burgazzoli >> >> >> On Fri, May 13, 2016 at 2:21 PM, Luca Burgazzoli wrote: >>> Yep, Handler was added just as placeholder as you know, naming is hard :-) >>> Unless we want to use it also in bean binding, I think a new >>> annotation would be better to avoid confusion so I'd vote for >>> @InvokeOnHeader >>> --- >>> Luca Burgazzoli >>> >>> >>> On Fri, May 13, 2016 at 2:08 PM, Claus Ibsen wrote: >>>> Hi >>>> >>>> Yeah that can help with those kind of components. You may want to use >>>> a different name than @Handler as there is a @Handler already in >>>> org.apache.camel for bean binding. >>>> >>>> maybe @SwitchByHeader (if people really think of the java switch >>>> statement) or @InvokeFromHeader, @InvokeOnHeader or something? >>>> Or if in the handler game then use @HandleOnHeader >>>> >>>> The existing @Handler in org.apache.camel does not have a value, and >>>> its maybe confusing if we reuse it? And add an empty value to it? >>>> >>>> >>>> >>>> >>>> On Mon, May 9, 2016 at 4:16 PM, Luca Burgazzoli wrote: >>>>> Hello, >>>>> >>>>> I'm working on some camel components (consul, ehcache, chronicle) and >>>>> most of the time the process to write a Producer is: >>>>> >>>>> - extending DefaultProducer >>>>> - write a - sometime big - switch/case to invoke the right method for an action >>>>> >>>>> So I'm wondering if it would make sense to have an annotation based >>>>> processor, so we can write something like: >>>>> >>>>> @Handler(EhcacheConstants.PUT) >>>>> protected void put(Message message) throws Exception { >>>>> ... >>>>> } >>>>> @Handler(EhcacheConstants.GET) >>>>> protected void get(Message message) throws Exception { >>>>> ... >>>>> } >>>>> >>>>> Or also using lambda >>>>> >>>>> bind( >>>>> EhcacheConstants.GET, >>>>> e -> e.getIn().setBody(cache.get(e.getIn().getHeader(EhcacheConstants.KEY))) >>>>> ) >>>>> >>>>> >>>>> I wrote a basic implementation here: >>>>> >>>>> https://github.com/lburgazzoli/lb-camel/blob/master/camel-common/src/main/java/org/apache/camel/common/EnhancedDefaultProducer.java >>>>> >>>>> >>>>> What do you think ? >>>>> >>>>> >>>>> --- >>>>> Luca Burgazzoli >>>> >>>> >>>> >>>> -- >>>> Claus Ibsen >>>> ----------------- >>>> http://davsclaus.com @davsclaus >>>> Camel in Action 2: https://www.manning.com/ibsen2 > > > > > -- > Claus Ibsen > ----------------- > http://davsclaus.com @davsclaus > Camel in Action 2: https://www.manning.com/ibsen2