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 D9F08200BAC for ; Wed, 12 Oct 2016 07:50:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D84AE160AF3; Wed, 12 Oct 2016 05:50:33 +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 05D1D160AE6 for ; Wed, 12 Oct 2016 07:50:32 +0200 (CEST) Received: (qmail 81252 invoked by uid 500); 12 Oct 2016 05:50:32 -0000 Mailing-List: contact dev-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list dev@aries.apache.org Received: (qmail 81234 invoked by uid 99); 12 Oct 2016 05:50:31 -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; Wed, 12 Oct 2016 05:50:31 +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 4244518067A for ; Wed, 12 Oct 2016 05:50:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.53 X-Spam-Level: * X-Spam-Status: No, score=1.53 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=2, 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: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id nhv_j8MMry1z for ; Wed, 12 Oct 2016 05:50:26 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id E4E005F177 for ; Wed, 12 Oct 2016 05:50:25 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id b81so62554933lfe.1 for ; Tue, 11 Oct 2016 22:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=KQAtjbZYBuS/tZkBJdKj+iTwQBc4WVvBbr1C6w2+3Ak=; b=iDbuq0E9vLYgUWggguPSOJVaqLLhJIUKqJ7961VZdCpNzkf8Y1c6BpCA4emelCDNe6 XrJPwroywK+H+pNcmjb4qjGSLcckM+N2m3twg7YDEchXkdKiasausgZtzMJd0Uqcf+3N y9JzLlCVI4lnYnOM6sQUzPmBVqQngBfFfdh8/Gvq6OBqfKoH/vRLpvRoAeVs8lakfBpO 4rHKEJh49LRv7SA3IDXLxxuLmI5zBvuS3TLswxdJSO7j38DVQIzHHHDedssEvoCUob2r UX7o44sSS9zJzeqB2jSqzYAojwoMN/CCqYqrRBkY1iiGy7gXNPZlAMJnQhr2SALeZthE YBgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=KQAtjbZYBuS/tZkBJdKj+iTwQBc4WVvBbr1C6w2+3Ak=; b=jcQh8S/Bk/0hN48DujJST776pf9BAvOFsO7aqf/6NoofnIDXtKRXyv9OJf4LQldZ6o 7OBaM9sp18N4g8adG5SGFPk7DsBiJOlfmmzmJSq54AF3zCfrvKJLhmrVPmEtZuckBDVU hnxwwMKBtF1Frstn40jMPXlMqpiW8aSHsVu1Zb/gtd7xusQNxGA6uQ3WV99cGKnQqbIL 6u3j/8mO6TVtsdQBT695G85RkrG1g+xJFkrvPyhwlJcKqkx4RiNSRUYTiUh9Dpi6IPnA Kxt6ewbscNsen0I3rPGq/JBWm1FVFA4WL3lBgYEm7SyQB9XEmqz9Bt8mu4marnkKPslZ f7lw== X-Gm-Message-State: AA6/9RkBXLrahm6Bv8lEHXS2WM/PGfxmzcglJXJxF1v5BR96PbxKEIw2ADl8nLKOgEcFZOoNF2Uo5pTtfvBHrA== X-Received: by 10.25.141.67 with SMTP id p64mr5751138lfd.86.1476251424914; Tue, 11 Oct 2016 22:50:24 -0700 (PDT) MIME-Version: 1.0 Sender: cschneider111@gmail.com Received: by 10.25.162.205 with HTTP; Tue, 11 Oct 2016 22:50:24 -0700 (PDT) In-Reply-To: <2AA93D28-1A48-4B92-AB20-CB5179F32150@yahoo.com> References: <7eaabd35-9166-b675-2d41-cca0d6a0be0a@die-schneider.net> <2AA93D28-1A48-4B92-AB20-CB5179F32150@yahoo.com> From: Christian Schneider Date: Wed, 12 Oct 2016 07:50:24 +0200 X-Google-Sender-Auth: 0vskDFZasOpzoQ7iN6OehgG2I9o Message-ID: Subject: Re: [blueprint-maven-plugin] Ideas for config handling To: dev@aries.apache.org Content-Type: multipart/alternative; boundary=001a113fc1acc803dd053ea491fb archived-at: Wed, 12 Oct 2016 05:50:34 -0000 --001a113fc1acc803dd053ea491fb Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I like the approach in DS to supply the config in one event but I don=C2=B4= t think it matches how dependency injection in blueprint works. In blueprint that config is often applied in different beans. Each bean is injected with config and its dependencies. Only after this step the init-method is used and the bean is injected into other beans. If I would get the config in a single event then it would be too late to inject it into other beans. So the only way I could imagine this to work is to inject the full config into each bean that needs it. This could be done a parameter of the init method (which is then similar to DS). The problem is that then several beans are tied together by the config even if they just need one attribute of it. Another problem is that by applying the config in each bean separately (and I think this is the only safe approach in blueprint) we loose the advantage of the single event. So while I am sure we can technically do it like in DS I think it would work less well from a design point of view. Christian 2016-10-11 17:12 GMT+02:00 David Jencks : > I don=E2=80=99t think i would consider ever recommending anyone use bluep= rint for > anything, but if I were to design something like this I would take the > opportunity to get one of the big advantages of DS also in blueprint, tha= t > all the configuration info is supplied in one event. So using your > annotation example (which would not need the @ObjectClassDefinition for > this use) > > @Inject @Named() > private ServerConfig serverConfig; > > When a configuration with the appropriate pid shows up, a ServerConfig > implementation returning the values from the configuration is created and > injected. If the configuration is a factory configuration with the pid a= s > the factory pid, then for each such configuration an instance is created. > > This doesn=E2=80=99t have the flexibility of what DS does (multiple pids,= no > necessary direct connection between pid and configuration annotation) but > something with those properties wouldn=E2=80=99t be hard to design. > > Metatype is extremely useful and generating metatype from annotations is > incredibly nice, but I would try to avoid requiring metatype for every > configuration annotation. > > david jencks > > > On Oct 11, 2016, at 2:57 AM, Christian Schneider < > chris@die-schneider.net> wrote: > > > > By default @Named("key") is used to inject a certain bean when type > information alone is not unique. In blueprint-maven-plugin we map it to a > bean id. > > So simply using the key for configs might overlap too easy. So I am not > sure which exact syntax we should use but the simple name is not enough. > > > > Support of different placeholders is also something that would be great > to support. It is rather rare but people use it. > > I think the must have is that we support placeholders from one config > and the system properties or framework properties. > > > > Christian > > > > On 11.10.2016 11:22, Guillaume Nodet wrote: > >> I like the use of annotations for config. > >> I've implemented it for CDI and it's quite nice. > >> I'm not sure that reusing @ObjectClassDefinition is a good idea, afaik > SCR > >> does not use it either. > >> I'd rather create a new blueprint annotation for such support. > >> > >> Also, I'm a bit skeptic about @Named("${key}") and > @Named("$system{key}") > >> Why not using something simpler: @Named("key") and @Named("system:key"= ) > ? > >> Or is that to support multiple placeholders with different syntaxes > (${xx}, > >> $[yy]...) ? > >> > >> > >> > >> 2016-10-11 10:15 GMT+02:00 Christian Schneider >: > >> > >>> Currently config is done in the blueprint-maven-plugin in this way: > >>> > >>> - Define a property-placeholder element in xml (using the cm > namespace). > >>> This defines the reference to the pid and optionally the default > values. > >>> > >>> - Use @Value("${key}") in the java code to inject a config value into= a > >>> field. > >>> > >>> > >>> Problems > >>> > >>> * The approach above requires a mix of xml and annotations. > >>> * @Value is a spring annotation. So the user code needs to refer to > >>> the spring library (even if it is not needed at runtime) > >>> > >>> > >>> Goals > >>> > >>> * Pure annotation approach > >>> * Should only need API dependencies in user code. Ideally these shou= ld > >>> not bring unwanted additional annotations that we can not use. > >>> > >>> > >>> Idea > >>> > >>> The OSGi meta type spec allows to define type safe config using > >>> annotations. We could use the same constructs to define blueprint > configs. > >>> > >>> It looks like this: > >>> > >>> |@ObjectClassDefinition(pid=3D"my.config.id") @interface ServerConfig= { > >>> String host() default "0.0.0.0"; int port() default 8080; boolean > >>> enableSSL() default false; }| > >>> > >>> This could be done in a new blueprint config namespace that enables t= he > >>> annotation processing. In this case the blueprint-maven-plugin just > needs > >>> to add the namespace and enable element to the generated blueprint. > >>> > >>> Another approach is to parse the config in the blueprint-maven-plugin > and > >>> create a property placeholder Element in our current style. > >>> > >>> If we have the above then we still need an annotation based way to > inject > >>> the config. One possible solution would be to use @Named with a speci= al > >>> syntax: > >>> > >>> @Inject @Named("${key}") > >>> String myAttribute; > >>> > >>> We could also cover system properties in this way: > >>> > >>> @Inject @Named("$system{key}") > >>> > >>> This approach has the advantage that it does not require any new > >>> annotation but it bends the purpose of the @Named annotation a bit. > >>> > >>> WDYT? > >>> > >>> > >>> Christian > >>> > >>> -- > >>> Christian Schneider > >>> http://www.liquid-reality.de > >>> > >>> Open Source Architect > >>> http://www.talend.com > >>> > >>> > >> > > > > > > -- > > Christian Schneider > > http://www.liquid-reality.de > > > > Open Source Architect > > http://www.talend.com > --=20 --=20 Christian Schneider http://www.liquid-reality.de Open Source Architect http://www.talend.com --001a113fc1acc803dd053ea491fb--