Return-Path: X-Original-To: apmail-felix-dev-archive@www.apache.org Delivered-To: apmail-felix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6EE6910E66 for ; Wed, 30 Oct 2013 19:32:40 +0000 (UTC) Received: (qmail 69289 invoked by uid 500); 30 Oct 2013 19:32:39 -0000 Delivered-To: apmail-felix-dev-archive@felix.apache.org Received: (qmail 68987 invoked by uid 500); 30 Oct 2013 19:32:35 -0000 Mailing-List: contact dev-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list dev@felix.apache.org Received: (qmail 68978 invoked by uid 99); 30 Oct 2013 19:32:32 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Oct 2013 19:32:32 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of andrei.pozolotin@gmail.com designates 209.85.214.172 as permitted sender) Received: from [209.85.214.172] (HELO mail-ob0-f172.google.com) (209.85.214.172) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Oct 2013 19:32:27 +0000 Received: by mail-ob0-f172.google.com with SMTP id gq1so1992366obb.3 for ; Wed, 30 Oct 2013 12:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=E1t12Z1XzFPIPxxvhouSMO9KZkeCjUKY4YN4jBRloK8=; b=ixydkLW8vpX/AmM7Q31w3dbPgxq7z4ocIISynWNUpD/wGW3Fu+oIvqrf1tGbBlCL4i 4W56dcf1/6MKx5sm4qcEOB/ro4EE7GSoSqtW5x8CDtbKPVdcM6ptfdPHAgPC7bwZd3ny fZsS9JNpiSF1d4AJCqbSvQfBV0Z6S/90FiE/w+mvk0S9sftup9f8KchYnHQV80Os9+Jv UWDtqBGJfMPDNQokeQPXfe90k3Mc9GhnXM1FOvgvurezmHOIWNqKxuAoGg5HkSMlgq3O C6uM6ZxeaNirIzIAvwEZNYFV0zDf8Qt5Rvil7AbweXRY4/PfYi4WlpoTNtWbiCSZwgeC 1lIw== X-Received: by 10.182.40.201 with SMTP id z9mr5366186obk.45.1383161527161; Wed, 30 Oct 2013 12:32:07 -0700 (PDT) Received: from [10.222.4.152] ([67.217.131.2]) by mx.google.com with ESMTPSA id eg8sm2848515obd.6.2013.10.30.12.32.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Oct 2013 12:32:06 -0700 (PDT) Message-ID: <52715EB4.1000608@gmail.com> Date: Wed, 30 Oct 2013 14:32:04 -0500 From: Andrei Pozolotin User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: dev@felix.apache.org Subject: Re: [DS] A new style of factory components References: <054BAFAB-EE5C-416B-A661-449978A11E27@yahoo.com> In-Reply-To: <054BAFAB-EE5C-416B-A661-449978A11E27@yahoo.com> X-Enigmail-Version: 1.6 Content-Type: multipart/alternative; boundary="------------080502060608090703070000" X-Virus-Checked: Checked by ClamAV on apache.org --------------080502060608090703070000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I documented my workarounds for similar use cases here http://wiki.osgi.org/wiki/Declarative_Services#Component_Factories with actual production code here https://github.com/barchart/barchart-osgi/tree/master/factory-ca https://github.com/barchart/barchart-osgi/tree/master/factory-ds -------- Original Message -------- Subject: [DS] A new style of factory components From: David Jencks To: dev@felix.apache.org Date: Wed 30 Oct 2013 12:47:51 PM CDT > I'm asking about this inside osgi as well. > > Factory components in DS have a number of oddities that make them unusable in many scenarios. I'd like to suggest that some type of factory component work very similarly to components configured from config admin with a factory PID, but with the configuration info supplied in code to the ComponentFactory newInstance method or a new ComponentInstance modified method. > > 1. Factory components are only registered when their references are satisfied, based on the default target filters from xml config or properties. (112.5.5) This might be plausible if you are not setting target filters for references in the configuration, but if you are why would you have to wait for _some_ possible reference targets to be registered when those are not likely to be the ones actually bound? > > 2. The situation is worse if you want to set target filters. (112.5.5) further explains that if the target filters are not satisfied when newInstance is called, you get a ComponentException thrown rather than a component waiting for the reference it needs to show up. Furthermore if any target filter for a required reference becomes unsatisfied the component is permanently disposed of without any notice. It is possible to track service events yourself to keep trying to create your component but this is sort of ridiculous. > > 2. There is no way to modify the configuration of a component instance created from a factory component. > > What I would find useful would be a new kind of factory component where: > > 1. The ComponentFactory service is registered when the component is enabled, irrespective of whether any references are satisifed. > > 2. Calling newInstance always creates and enables a component right away, whether or not the references are satisfied. > > 3. The component created from newInstance persists until it is explicitly disposed with the ComponentInstance.dispose() method or the bundle is stopped > > 4. ComponentFactory.newInstance return a subclass of ComponentInstance, say FactoryInstance, with a modified(Dictionary) method that will update the component properties, including (if the component is registered as a service) the service properties, just like a CA configuration update will update a component. I'd expect this method would not be accessible from the ComponentContext.getComponentInstance() component instance object. > > Something would have to turn this new behavior on, either a new name for the factory attribute (xml and annotation) or an additional attribute. > > The possibility of modifying a factory instance configuration could work for the current style of component factory as well. > > ------------ > > My use case for this is to provide a way to process (or ignore) Configurations for DS component similar to what is provided for ManagedServices and ManagedServiceFactories via ConfigurationPlugins. DS runs off of configuration events and configuration plugins are not applied to configurations retrieved from CA, only to those pushed into MS and MSFs. In addition I think this style of component factory would generally be much more useful than the current factory components. > > > Thoughts? > > many thanks > david jencks > > --------------080502060608090703070000--