Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B60A0107B7 for ; Fri, 3 May 2013 09:00:36 +0000 (UTC) Received: (qmail 9139 invoked by uid 500); 3 May 2013 09:00:36 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 9085 invoked by uid 500); 3 May 2013 09:00:36 -0000 Mailing-List: contact commits-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 commits@felix.apache.org Received: (qmail 9058 invoked by uid 99); 3 May 2013 09:00:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 May 2013 09:00:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 May 2013 09:00:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A84A42388B4E; Fri, 3 May 2013 09:00:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1478675 - /felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.mdtext Date: Fri, 03 May 2013 09:00:13 -0000 To: commits@felix.apache.org From: guillaume@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130503090013.A84A42388B4E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: guillaume Date: Fri May 3 09:00:13 2013 New Revision: 1478675 URL: http://svn.apache.org/r1478675 Log: Provide code samples for supported @Bind method patterns Modified: felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.mdtext Modified: felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.mdtext URL: http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.mdtext?rev=1478675&r1=1478674&r2=1478675&view=diff ============================================================================== --- felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.mdtext (original) +++ felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/describing-components/service-requirement-handler.mdtext Fri May 3 09:00:13 2013 @@ -91,16 +91,67 @@ The second injection mechanism uses meth * A bind method called when a service appears * An unbind method called when a service disappears -* A modified method called when a service is modified (the service properties changed, but the service still matches the requirement) +* A modified method called when a service is modified (the service properties have changed, but the service still matches the requirement) -Moreover, callbacks can be in the component super class (in this case methods must be public). These methods can have one of these four signatures: +Moreover, callbacks can be in the component super class (in this case methods must be public). These methods can have one of these signatures: -* Without any argument: the method is just a notification (method()) -* With the service object : the object is the implicated service object (method(Service svc)) -* With an OSGi service reference: the service reference appearing or disappearing (method(ServiceReference ref)) -* With the service object and the OSGi service reference (method(Service svc, ServiceReference ref)) -* With the service object and the service properties inside a Map (method(Service svc, Map properties)) -* With the service object and the service properties inside a Dictionary (method(Service svc, Dictionary properties)) +* Without any argument: the method is just a notification + + :::java + public void bindService() { + // ... + } + +* With the service object: the object is the implicated service object. Service dependency type is inferred from the parameter's type. + + :::java + public void bindService(HelloService hello) { + m_hello = hello; + } + +* With an OSGi service reference: the service reference appearing or disappearing. + + :::java + public void bindService(ServiceReference reference) { + // ... + } + public void bindService(ServiceReference reference) { + // ... + } + public void bindService(ServiceReference reference) { + // ... + } + +* With the service object and the OSGi service reference. + + :::java + public void bindService(HelloService hello, ServiceReference reference) { + // ... + } + +* With the service object and the service properties inside a Map (no adherence to OSGi APIs). + + :::java + public void bindService(HelloService hello, Map properties) { + // ... + } + +* With the service object and the service properties inside a Dictionary (no adherence to OSGi APIs). + + :::java + public void bindService(HelloService hello, Dictionary properties) { + // ... + } + +
+

Important

+

Notice that, when missing (typically no interface can be inferred from the code) dependency information must be supplied to iPOJO in some way +

    +
  • @Bind with specification and/or filter attribute
  • +
  • Using XML metadata declaration
  • +
+

+
The following component implementation shows an example of implementation using this mechanism: @@ -120,11 +171,11 @@ The `modified` callback is not mandatory :::xml - + - - ... + + ... Note, that the different callbacks can be have different signatures. By using this mechanism, you need to be sure to manage the dynamism correctly.