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 AE17D200CFE for ; Fri, 8 Sep 2017 11:03:13 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id ACCA71609C0; Fri, 8 Sep 2017 09:03:13 +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 CBAB71609A7 for ; Fri, 8 Sep 2017 11:03:12 +0200 (CEST) Received: (qmail 71815 invoked by uid 500); 8 Sep 2017 09:03:11 -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 71803 invoked by uid 99); 8 Sep 2017 09:03:11 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Sep 2017 09:03:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 1086B18F9F3 for ; Fri, 8 Sep 2017 09:03:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.379 X-Spam-Level: X-Spam-Status: No, score=0.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id 1ZFD1b1LZn6T for ; Fri, 8 Sep 2017 09:03:05 +0000 (UTC) Received: from mail-qk0-f181.google.com (mail-qk0-f181.google.com [209.85.220.181]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 5C05A5F570 for ; Fri, 8 Sep 2017 09:03:05 +0000 (UTC) Received: by mail-qk0-f181.google.com with SMTP id a128so4801952qkc.5 for ; Fri, 08 Sep 2017 02:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=qd3rhb5UjD9gEUaPX6tWALU6LJA5828pG7oAOjPd9cU=; b=QC5tet1kLDQ6eFk6oJQ4y3a5HmwIleQol8LYuH4MUW0c1jzSQhEhzBEm+33ZaEzZDt NmQMzVCYQZQEuxDGUNJHTvM6GdIo93OZGDadwlOjAPaGL40eV4nYS0zMO42U/dNIQo6K VBE99z3tSPS1WFnYz2vnKtQhM0/VMg3+hyuRh9hllQLQIB2zD0hKSNWn13xlFwhjwtzr hakLpZK6a0hM8ZR5BJwwFLnQksdL3co/TqBa572P54E14J8R970mgdtGZeu3rjsj5Ppw WFCAVrUQ7Kuv4tp+uGlrbtsZBoqj7rcYE9+eMvKKfgKD81UG1muIRH+eNsUE2Ilf/Pnd Nvdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=qd3rhb5UjD9gEUaPX6tWALU6LJA5828pG7oAOjPd9cU=; b=h9AyqfBwsJUY4EgbwQALJNFg9P4o/hTXAm+b7f/YPh4cjTIUblJci3uQ9BGpUlpbb8 iNQDDfujqPmiUyrb3IAKeuUeu4gt6TUnmZ00OKxFH4laMv/p88Uo24EcGBRe8Qvj2RGU XoqiYldkj80HDtkgnhnbhfuAcWkJqqnX8uuxHMAN6C3mSu6tyC45rd3I2ReBsLXoX3Er w3H9FUfv0nwYjqYjw1T2yUnxdYKDwUhFSaMba4vGuM/p/N8zl+DDULqKVd7VkLM8GMCp QhN6nf3w0HnfSD6DC8hBWDm98bZ0squJKgaIkXAzVoOgRO1V3KWh9IS/qLXIh2FJzTMJ IrrQ== X-Gm-Message-State: AHPjjUjAAYevVN1DsUB/2c9WxcmA8d9M0ZnACr/vY8Av9pBVeMRhkUat 6R8g6+KKr341zdx3hAwYbZCnvqEbReAPTxbTiUDzUg== X-Google-Smtp-Source: AOwi7QASJUo2unr2SIewRn7tetUpUMp5mpiWTAL6GcCDCnVC1a58j6xVMdP23Ng8jHFdbXx1VTeMZ5Xb/vabri0nZnQ= X-Received: by 10.55.212.75 with SMTP id l72mr2723269qki.259.1504861384621; Fri, 08 Sep 2017 02:03:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.61.39 with HTTP; Fri, 8 Sep 2017 02:02:44 -0700 (PDT) In-Reply-To: References: From: Claus Ibsen Date: Fri, 8 Sep 2017 11:02:44 +0200 Message-ID: Subject: Re: Hierarchical registry for CamelContext To: dev Content-Type: text/plain; charset="UTF-8" archived-at: Fri, 08 Sep 2017 09:03:13 -0000 On Fri, Sep 8, 2017 at 10:38 AM, Luca Burgazzoli wrote: > Hi, > > I was thinking if instead we could have the camel context have its own > registry and end users can add their own "bean repository", like > > context.addBeanRepository(new SpringBeanRepository()) > context.addBeanRepository(new JNDIRepositoy()) > > Then when asking the registry to lookup beans, it will go through the > repositories according to their order and if it does not find any its > internal repositories which can then be used to add internal stuffs > like rest/service-call/etc configurations and so on. > > Would that make sense ? > Maybe can we talk about this later. We have a 2.20.0 release to get done first. > > --- > Luca Burgazzoli > > > On Mon, Feb 6, 2017 at 10:41 AM, Claus Ibsen wrote: >> Hi >> >> Yeah the idea of having it internal and named as containerRegistry, or >> maybe better named as contextRegistry or internalRegistry or >> camelInternalRegistry to make it stand out its not for Camel end users >> per see. >> >> A side bonus can be that we could make this internal registry >> available for unit testing Camel where users sometimes have a little >> trouble adding beans to the registry when using spring / cdi / java / >> karaf et all. There is a couple of JIRAs about this. Then the APIs on >> camel-test could offer a way to register custom beans that take >> priority over the regular registry. >> >> >> >> >> >> >> On Mon, Feb 6, 2017 at 10:13 AM, Luca Burgazzoli wrote: >>> Well, what we have as today is just fine but sometime it requires a >>> little bit of additional work and maintenance even it is not strictly >>> needed. >>> Let's take as example hystrix and service call stuffs we added recently: >>> >>> 1. hystrix configuration is retrieved from the registry but work in >>> spring only as blueprint and cdi support is not implemented and would >>> require additional work, even the spring support is a little limited. >>> 2. service call configurations can be retrieved from the camel context >>> (via getter method) or from the registry but configurations you add to >>> the camel context element are added to the context, not the registry >>> so the behavior is a little different and it pollute the camel context >>> with additional methods. >>> 3. Add support for service-call to spring & co may require to write a >>> custom bean factory >>> 4. hystrix and service-call configurations are not supposed to be used >>> outside the camel context, so having them available for DI in >>> spring/blueprint/cdi does not make much sense >>> >>> The proposed solution aim to harmonize such things by adding them to a >>> camel contex own registry. >>> Of course the container specific registry can still be used to >>> configure hystrix/service-call and it is used first, something like: >>> >>> registry.lookupByName(String name, Class type) { >>> Object answer = containerRegistry.lookupByName(name); >>> if (answer == null) { >>> answer = contextRegistry,.lookupByName(name); >>> } >>> >>> return answer; >>> } >>> >>> >>> >>> --- >>> Luca Burgazzoli >>> >>> >>> On Fri, Feb 3, 2017 at 4:27 PM, Paul Gale wrote: >>>> Luca, >>>> >>>> Can you outline either some particular business problem that you're trying >>>> to solve or some current impediment to a solution that would be remedied by >>>> your proposed design change? >>>> >>>> Perhaps a few use case scenarios might help demonstrate the need. Just a >>>> thought. >>>> >>>> Thanks, >>>> Paul >>>> >>>> On Fri, Feb 3, 2017 at 8:39 AM, Luca Burgazzoli >>>> wrote: >>>> >>>>> Yes an easy way to register beans that are not really meaningful >>>>> outside the camel context and maybe beans we do not want to make >>>>> available through dependency injection so they can't be easily >>>>> modified outside. >>>>> The hierarchical nature is only to make it transparent for consumer >>>>> i.e. a service call / hystrix implementation would search in the >>>>> registry and do not care were the bean come from. >>>>> >>>>> Indeed I'm not sure it is the best option, still need to experiment about >>>>> it. >>>>> >>>>> --- >>>>> Luca Burgazzoli >>>>> >>>>> >>>>> On Fri, Feb 3, 2017 at 2:11 PM, Claus Ibsen wrote: >>>>> > Hi >>>>> > >>>>> > So are you referring to some configuration for service call / hystrix >>>>> etc? >>>>> > >>>>> > The problem with the registry being hierarchical is that its backed by >>>>> > different implementations and then the user experience is different >>>>> > depending on which beans you get. For example CDI/spring has all kind >>>>> > of dependency injection magic, where as a basic map registry cannot do >>>>> > anything. >>>>> > >>>>> > So it sounds more like you are looking for an internal generic registry? >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > On Thu, Feb 2, 2017 at 6:21 PM, Luca Burgazzoli >>>>> wrote: >>>>> >> Hello everyone, >>>>> >> >>>>> >> I'm wondering if it would make sense to have a sort of hierarchical >>>>> >> registry where the root registry is always created by the CamelContext >>>>> >> then the specific container registry adds its own registry on top and >>>>> >> the lookup would be top down. >>>>> >> >>>>> >> The motivation is that there are some beans that are only used by >>>>> >> camel and the registry is always involved so it does not make much >>>>> >> sense to have them available also on the container, i.e. the >>>>> >> ServiceCall and Hystrix configured through XML. >>>>> >> >>>>> >> This would reduce the complexity to add new definitions to the XML as >>>>> >> one do not need to create a container specific parser (blueprint, >>>>> >> spring, cdi) for object that are strictly camel-context related. >>>>> >> >>>>> >> 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 -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2