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 761AB2009F9 for ; Mon, 23 May 2016 14:29:57 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 73D5C160A0F; Mon, 23 May 2016 12:29:57 +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 BDCA31609A8 for ; Mon, 23 May 2016 14:29:56 +0200 (CEST) Received: (qmail 80061 invoked by uid 500); 23 May 2016 12:29:56 -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 80048 invoked by uid 99); 23 May 2016 12:29:55 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 May 2016 12:29:55 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 3444CCB325 for ; Mon, 23 May 2016 12:29:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.747 X-Spam-Level: X-Spam-Status: No, score=-1.747 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_REPLYTO_END_DIGIT=0.25, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id WDyrSCCAswJI for ; Mon, 23 May 2016 12:29:52 +0000 (UTC) Received: from nm20.bullet.mail.bf1.yahoo.com (nm20.bullet.mail.bf1.yahoo.com [98.139.212.179]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 4EF615FB15 for ; Mon, 23 May 2016 12:29:51 +0000 (UTC) Received: from [66.196.81.170] by nm20.bullet.mail.bf1.yahoo.com with NNFMP; 23 May 2016 12:29:44 -0000 Received: from [98.139.212.224] by tm16.bullet.mail.bf1.yahoo.com with NNFMP; 23 May 2016 12:29:44 -0000 Received: from [127.0.0.1] by omp1033.mail.bf1.yahoo.com with NNFMP; 23 May 2016 12:29:44 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 754557.51775.bm@omp1033.mail.bf1.yahoo.com X-YMail-OSG: aDz3EJgVM1lv9xX9TJkunihMh.LE5hvVVLUF3KuaNasr4m49lf_uXjPUsjxNYGF qRQKDzgfAHw.YFHSK7NoZ1QFM7qDyVa_qlAxPbSeSjR1Jm60FuZbMZn3jAVb1z10__8TX9OoLkTW 9ivoAPJXRfkgUZSIzgB7YC5OJLhWJMuIsa7IOXQfRbK2KX1ZiFf4Jy6JwR7Uwlc_6o7F93C.nVir e9QqmTzm7pHSyjt5xsTgKWQOJve1GNrePUg4U.pEGi6nFVXcI5f4T.titem8lJtijtTzCD7qtG4W P2M3FQXCTa.P64uVb.cWkjoyA9x6JrFes3_Nv8SIdkxhXzAG7ILxmIutiU6CLiY0qEL1X03sudu7 kKfkyhEkjOYATJPlgOtgkIbM4l4Tf0WpD7tMrWAPLZzhbT3crCA.cuLyspTm4zEI35G7U5DImMqw qQwM_UPXYGtzIUREkh.DktTGWqtCkLgr9mxWxR.DGnnLoHwqrifBl3kKcjp.N0w__PGbblGGrGfR IjVQo2qWtt_k5D1AD_6w- Received: from jws106100.mail.bf1.yahoo.com by sendmailws143.mail.bf1.yahoo.com; Mon, 23 May 2016 12:29:44 +0000; 1464006584.256 Date: Mon, 23 May 2016 12:29:43 +0000 (UTC) From: Andrea Cosentino Reply-To: Andrea Cosentino To: "dev@camel.apache.org" Message-ID: <1853430256.1023642.1464006583789.JavaMail.yahoo@mail.yahoo.com> In-Reply-To: References: Subject: Re: Annotation based DefaultProducer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit archived-at: Mon, 23 May 2016 12:29:57 -0000 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