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 24C2F18F51 for ; Sat, 30 Apr 2016 20:21:02 +0000 (UTC) Received: (qmail 28354 invoked by uid 500); 30 Apr 2016 20:21:01 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 28312 invoked by uid 500); 30 Apr 2016 20:21:01 -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 28303 invoked by uid 99); 30 Apr 2016 20:21:01 -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; Sat, 30 Apr 2016 20:21:01 +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 46706C0E44 for ; Sat, 30 Apr 2016 20:21:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.999 X-Spam-Level: X-Spam-Status: No, score=0.999 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id qUmmj6SdyHjh for ; Sat, 30 Apr 2016 20:21:00 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 81F435FB61 for ; Sat, 30 Apr 2016 20:20:59 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6551BE00E7 for ; Sat, 30 Apr 2016 20:20:58 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 864833A0216 for ; Sat, 30 Apr 2016 20:20:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1741809 - /felix/site/trunk/content/documentation/subprojects/apache-felix-service-component-runtime.mdtext Date: Sat, 30 Apr 2016 20:20:57 -0000 To: commits@felix.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160430202057.864833A0216@svn01-us-west.apache.org> Author: cziegeler Date: Sat Apr 30 20:20:56 2016 New Revision: 1741809 URL: http://svn.apache.org/viewvc?rev=1741809&view=rev Log: Minor update to SCR docs Modified: felix/site/trunk/content/documentation/subprojects/apache-felix-service-component-runtime.mdtext Modified: felix/site/trunk/content/documentation/subprojects/apache-felix-service-component-runtime.mdtext URL: http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-service-component-runtime.mdtext?rev=1741809&r1=1741808&r2=1741809&view=diff ============================================================================== --- felix/site/trunk/content/documentation/subprojects/apache-felix-service-component-runtime.mdtext (original) +++ felix/site/trunk/content/documentation/subprojects/apache-felix-service-component-runtime.mdtext Sat Apr 30 20:20:56 2016 @@ -1,17 +1,17 @@ Title: Apache Felix Service Component Runtime (SCR) [TOC] -The Apache Felix Service Component Runtime described by the OSGi Declarative Services Specification is implemented by the `org.apache.felix.scr` bundle. As specified, the components must be declared in XML-formatted descriptor files which in turn must be listed in the `Service-Component` header of the declaring bundle. +The Apache Felix Service Component Runtime described by the OSGi Declarative Services Specification is implemented by the `org.apache.felix.scr` bundle. As specified, the components must be declared in XML-formatted descriptor files which in turn must be listed in the `Service-Component` header of the declaring bundle. But the good news is, you usually don't have to worry about XML as you can simply use annotations which are processed at build time. The build tool will create the XML files and headers for you. The component declarations are read when the declaring bundle is started and the respective components are verified and activated depending on their declaration. -The Apache Felix Declarative Services implementation with the OSGi Declarative Services Specification Version 1.1 passes the OSGi CT. +The Apache Felix Declarative Services implementation is the reference implementation for the OSGi Declarative Services Specification Version 1.3 (R6) and therefore passes the OSGi CT. ## Example -To help you get a head start, here is an example of using Declarative Services. You will find more examples in the `trunk/examples` folder of the Apache Felix Project. +To help you get a head start, here is an example of using Declarative Services "by hand". Instead of using annotations, the XML is created by hand. We discourage doing so, but this is just to give you an idea how it really works. You will find more examples in the `trunk/examples` folder of the Apache Felix Project. -## Component +### Component First of all the component must be implemented in a simple Java class. The Declarative Services Specification basically places no restrictions on the contents of this class. If you make use of advanced functionality such as providing an `activate()` or `deactivate()` method or using service loopup by *event strategy* (see 112.3.1 Accessing Services) you will of course have to provide the respective methods. @@ -32,7 +32,7 @@ For the sake of example, lets define a v This is of course a very simple and not very intelligently implemented comparator... -## Declaration +### Declaration The next step consists of writing the declaration. I usually put these files in the `OSGI-INF` folder of the bundle, but the files may be placed anywhere within the bundle or any of the bundle's fragments as long as its path is listed in the `Service-Component` bundle manifest header. @@ -63,7 +63,7 @@ To finalize this declaration, add the fo Service-Component: OSGI-INF/sample.xml -## Activation +### Activation It may well be that the component needs to be notified, when it is activated and deactivated. For this, the component may implement an `activate` method and a `deactivate` method. Both methods must be `public` or `protected` and take a single argument, the `org.osgi.service.ComponentContext`. It is recommended for this method to the `protected` as it is only used by the Service Component Runtime and should of course not be part of the public API of the component. @@ -95,7 +95,7 @@ Here is the initial class extended with Nothing more needs to be done as the Service Component Runtime automatically recognizes and calls these methods. -## Service Binding +### Service Binding The next step would probably be to do some service binding. This is somewhat more overhead, as the referred to services must be declared. On the other hand, you do not have to care to listen for these services. As examples of these strategies we will first use the lookup strategy to access an OSGi `HttpService` and then we will use the event strategy to access an OSGi `LogService` (I personally prefer the event strategy, but your mileage may vary). @@ -258,6 +258,6 @@ The `ScrService` allows access to all re ## Summary -This tutorial just listed some very basic information on Declarative Service. To get more information, for example on hoe the Configuration Admin Service may be used to configure components, refer to the Declarative Services Sepecification in the OSGi Service Platform *Service Compendium* book. +This tutorial just listed some very basic information on Declarative Service. To get more information, for example on how the Configuration Admin Service may be used to configure components, refer to the Declarative Services Sepecification in the OSGi Service Platform *Service Compendium* book. Have Fun !