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 4C54210B0B for ; Fri, 20 Sep 2013 23:20:35 +0000 (UTC) Received: (qmail 72278 invoked by uid 500); 20 Sep 2013 23:20:34 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 72254 invoked by uid 500); 20 Sep 2013 23:20:34 -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 72247 invoked by uid 99); 20 Sep 2013 23:20:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Sep 2013 23:20:34 +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, 20 Sep 2013 23:20:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C3B9523888A6 for ; Fri, 20 Sep 2013 23:20:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r879268 - in /websites/staging/felix/trunk/content: ./ documentation/subprojects/apache-felix-dependency-manager/ documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/ Date: Fri, 20 Sep 2013 23:20:12 -0000 To: commits@felix.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130920232012.C3B9523888A6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: buildbot Date: Fri Sep 20 23:20:12 2013 New Revision: 879268 Log: Staging update by buildbot for felix Added: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-composition.html Removed: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/apache-felix-dependency-manager-using-annotations-composition.html Modified: websites/staging/felix/trunk/content/ (props changed) websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html websites/staging/felix/trunk/content/sitemap.html Propchange: websites/staging/felix/trunk/content/ ------------------------------------------------------------------------------ --- cms:source-revision (original) +++ cms:source-revision Fri Sep 20 23:20:12 2013 @@ -1 +1 @@ -1525172 +1525175 Modified: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html ============================================================================== --- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html (original) +++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations.html Fri Sep 20 23:20:12 2013 @@ -87,11 +87,11 @@ components can interact with the dynamic
  • Dependency Manager components annotations.
  • Dependency Manager dependency annotations
  • Dependency Manager component lifecycle
  • -
  • Composition Explains how a component may be implemented using multiple object instances.
  • -
  • BndTools Tutorial A BndTools based demo of DependencyManager annotations.
  • +
  • Dependency Manager service composition.
  • +
  • BndTools based demo of Dependency Manager annotations
  • - Rev. 1525172 by pderop on Fri, 20 Sep 2013 23:12:27 +0000 + Rev. 1525175 by pderop on Fri, 20 Sep 2013 23:19:31 +0000
    Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project Added: websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-composition.html ============================================================================== --- websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-composition.html (added) +++ websites/staging/felix/trunk/content/documentation/subprojects/apache-felix-dependency-manager/apache-felix-dependency-manager-using-annotations/dependencymanager-annotations-composition.html Fri Sep 20 23:20:12 2013 @@ -0,0 +1,150 @@ + + + + + Apache Felix - Dependency Manager Service Composition + + + + + + +
    + +
    + + Apache + +
    +
    + + + +
    + + + +
    + This page is a translated version of /site/dependencymanager-annotations-composition.html. In case of + doubt you might want to refer to the old page. +
    + + +

    Dependency Manager Service Composition

    +

    This section shows how a component may be implemented using multiple object instances.

    +

    When implementing more complex services, you often find yourself using more than one instance for a given service. +However, several of these instances might want to have dependencies injected. In such cases you need to tell the +dependency manager which instances to consider. Within a Component (or an Aspect/Adapter), you can annotate a method +with the @Composition annotation. This method is meant to return such composition of service instances, and the objects +will be considered as part of the service implementation. So, all dependencies, as well as lifecycle annotations +(@Init, @Start, @Stop, @Destroy) will be applied on every objects returned by the method annotated with the @Composition annotation.

    +

    The following example illustrates a composition of two object instances, which are part of the implementation of a MyService service:

    +
    /**
    + * Main implementation for the MyService Service
    + */
    +@Component
    +public class MyServiceImpl implements MyService {
    +  // This object instance is also used to implement the service.
    +  private Helper helper = new Helper();
    +
    +  // MyServiceImpl, and Helper objects are part of the composition
    +  @Composition
    +  Object[] getComposition() {
    +    return new Object[] { this, helper };
    +  }
    +
    +  // This dependency is also applied to the Helper
    +  @ServiceDependency
    +  Dependency dep;
    +
    +  // Same thing for this dependency
    +  @ServiceDependency
    +  void bind(Dependency2 dep2) {}
    +
    +  // Lifecycle callbacks also applied on the Helper ...
    +  @Init
    +  void init() {}
    +
    +  @Start
    +  void start() {}
    +
    +  @Stop
    +  void stop() {}
    +
    +  @Destroy()
    +  void destroy() {}
    +}
    +
    +public class Helper {
    +  // Also injected, since we are part of the composition
    +  Dependency dep;
    +
    +  // But since we are not interested by the Dependency2, we don't have to declare the bind(Dependency2) method ...
    +
    +  // We only specify the start lifecycle callback because we need to return some extra service properties which will be published
    +  // along with the provided service ...
    +
    +  Map start() {
    +     Map extraServiceProperties = new HashMap();
    +     extraServiceProperties.add("foo", "bar");
    +     return extraServiceProperties;
    +  }
    +}
    +
    + + +

    Here, MyServiceImpl is the main component implementation, but is composed of the Helper object instance. So all Dependencies defined in MyServiceImpl +will be also injected to the Helper (if the Helper declares the fields or methods). The Helper may also declare lifecycle callbacks (optionally).

    +
    + Rev. 1525175 by pderop on Fri, 20 Sep 2013 23:19:31 +0000 +
    +
    + Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project + logo are trademarks of The Apache Software Foundation. All other marks mentioned + may be trademarks or registered trademarks of their respective owners. +
    +
    + + Modified: websites/staging/felix/trunk/content/sitemap.html ============================================================================== --- websites/staging/felix/trunk/content/sitemap.html (original) +++ websites/staging/felix/trunk/content/sitemap.html Fri Sep 20 23:20:12 2013 @@ -120,8 +120,8 @@
  • Apache Felix Dependency Manager - Reference Guide
  • Dependency Manager Annotations