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 4B4EC200B9F for ; Tue, 11 Oct 2016 17:12:25 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 49F5D160AF3; Tue, 11 Oct 2016 15:12:25 +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 6B713160AD2 for ; Tue, 11 Oct 2016 17:12:24 +0200 (CEST) Received: (qmail 17668 invoked by uid 500); 11 Oct 2016 15:12:23 -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 17651 invoked by uid 99); 11 Oct 2016 15:12:23 -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; Tue, 11 Oct 2016 15:12:23 +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 8B7DDC0957 for ; Tue, 11 Oct 2016 15:12:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.12 X-Spam-Level: X-Spam-Status: No, score=-1.12 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id RxRCtJpWnCus for ; Tue, 11 Oct 2016 15:12:18 +0000 (UTC) Received: from nm24-vm0.bullet.mail.ne1.yahoo.com (nm24-vm0.bullet.mail.ne1.yahoo.com [98.138.90.34]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id A69AC5FAFA for ; Tue, 11 Oct 2016 15:12:18 +0000 (UTC) Received: from [98.138.100.117] by nm24.bullet.mail.ne1.yahoo.com with NNFMP; 11 Oct 2016 15:12:12 -0000 Received: from [98.138.104.115] by tm108.bullet.mail.ne1.yahoo.com with NNFMP; 11 Oct 2016 15:12:12 -0000 Received: from [127.0.0.1] by smtp224.mail.ne1.yahoo.com with NNFMP; 11 Oct 2016 15:12:12 -0000 X-Yahoo-Newman-Id: 13805.38744.bm@smtp224.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: pdtgqGAVM1lYupDTf_qsqtRnJfxq.y6drf.9uYpew4dvFY4 R27fZ76mkGPiae7S.DyxMsHhhDcDvznHyIQtkDHL2zE64WqR4J38cn3NWx76 QQaYGV9axtb8k6VjUP1u9GmNcBvl4nV4FQotzcHPfXMDYntjQoIdx30koUtA RKG5657oiu_V3SF.R5ReLd4Qz_8AZiM2cjPL6LQtT12ezWY.COmIbvcwYeU4 ViPf6AlOzGK_N62NzogEn8Hv.hL.ELwMnYZPVL1K95nUq_0YQQkNhC1djGKT seTHLHa2qaL6PhX0SA.uLkG4ucos3G1GpSxFpa0Skf0P5maFYgXOo6t1Wixy LS4gnySWnGprEsCNkkFMi1zPG_PN2FZp_Ov1fLUkxhFzMbqVgX4SwQMJeztp T5lUoXKHpdFAVmwSmDkuEfQhhceC8BIReXaa1Cj4LGen2phO7GzZ3yOQ.FU5 0feknvOwZu4ysMd7yc6PlkR_iIAqWUdkxRJqpiwUrE85bhxnfftYOJFyS.Yn Qio6V0zJTAcTC_6MWluo4Y5C6iPivGbvCzHxutuh0e5Dgmev29QVa2xQplxY - X-Yahoo-SMTP: .9oIUzyswBANsYgUm_5uPui0skTnzGJXJQ-- From: David Jencks Content-Type: multipart/alternative; boundary="Apple-Mail=_7D43F814-2221-45A6-806A-83B7882B4003" Mime-Version: 1.0 (Mac OS X Mail 10.0 \(3226\)) Subject: Re: [blueprint-maven-plugin] Ideas for config handling Date: Tue, 11 Oct 2016 08:12:09 -0700 References: <7eaabd35-9166-b675-2d41-cca0d6a0be0a@die-schneider.net> To: dev@aries.apache.org In-Reply-To: <7eaabd35-9166-b675-2d41-cca0d6a0be0a@die-schneider.net> Message-Id: <2AA93D28-1A48-4B92-AB20-CB5179F32150@yahoo.com> X-Mailer: Apple Mail (2.3226) archived-at: Tue, 11 Oct 2016 15:12:25 -0000 --Apple-Mail=_7D43F814-2221-45A6-806A-83B7882B4003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 I don=E2=80=99t think i would consider ever recommending anyone use = blueprint 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, that 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 as 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 = wrote: >=20 > 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. >=20 > 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. >=20 > Christian >=20 > 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. >>=20 >> 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]...) ? >>=20 >>=20 >>=20 >> 2016-10-11 10:15 GMT+02:00 Christian Schneider = : >>=20 >>> Currently config is done in the blueprint-maven-plugin in this way: >>>=20 >>> - Define a property-placeholder element in xml (using the cm = namespace). >>> This defines the reference to the pid and optionally the default = values. >>>=20 >>> - Use @Value("${key}") in the java code to inject a config value = into a >>> field. >>>=20 >>>=20 >>> Problems >>>=20 >>> * 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) >>>=20 >>>=20 >>> Goals >>>=20 >>> * Pure annotation approach >>> * Should only need API dependencies in user code. Ideally these = should >>> not bring unwanted additional annotations that we can not use. >>>=20 >>>=20 >>> Idea >>>=20 >>> The OSGi meta type spec allows to define type safe config using >>> annotations. We could use the same constructs to define blueprint = configs. >>>=20 >>> It looks like this: >>>=20 >>> |@ObjectClassDefinition(pid=3D"my.config.id") @interface = ServerConfig { >>> String host() default "0.0.0.0"; int port() default 8080; boolean >>> enableSSL() default false; }| >>>=20 >>> This could be done in a new blueprint config namespace that enables = the >>> annotation processing. In this case the blueprint-maven-plugin just = needs >>> to add the namespace and enable element to the generated blueprint. >>>=20 >>> Another approach is to parse the config in the = blueprint-maven-plugin and >>> create a property placeholder Element in our current style. >>>=20 >>> 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 = special >>> syntax: >>>=20 >>> @Inject @Named("${key}") >>> String myAttribute; >>>=20 >>> We could also cover system properties in this way: >>>=20 >>> @Inject @Named("$system{key}") >>>=20 >>> This approach has the advantage that it does not require any new >>> annotation but it bends the purpose of the @Named annotation a bit. >>>=20 >>> WDYT? >>>=20 >>>=20 >>> Christian >>>=20 >>> -- >>> Christian Schneider >>> http://www.liquid-reality.de >>>=20 >>> Open Source Architect >>> http://www.talend.com >>>=20 >>>=20 >>=20 >=20 >=20 > --=20 > Christian Schneider > http://www.liquid-reality.de >=20 > Open Source Architect > http://www.talend.com --Apple-Mail=_7D43F814-2221-45A6-806A-83B7882B4003--