Author: timothyjward
Date: Thu May  7 15:19:32 2015
New Revision: 1678229

URL: http://svn.apache.org/r1678229
Log:
[ARIES-1318] Initial commit of an OSGi Async Service from RFC 206

Added:
    aries/trunk/async/async-all/   (with props)
    aries/trunk/async/async-all/LICENSE
    aries/trunk/async/async-all/NOTICE
    aries/trunk/async/async-all/pom.xml
    aries/trunk/async/async-api/   (with props)
    aries/trunk/async/async-api/LICENSE
    aries/trunk/async/async-api/NOTICE
    aries/trunk/async/async-api/pom.xml
    aries/trunk/async/async-api/src/
    aries/trunk/async/async-api/src/main/
    aries/trunk/async/async-api/src/main/java/
    aries/trunk/async/async-api/src/main/java/org/
    aries/trunk/async/async-api/src/main/java/org/osgi/
    aries/trunk/async/async-api/src/main/java/org/osgi/service/
    aries/trunk/async/async-api/src/main/java/org/osgi/service/async/
    aries/trunk/async/async-api/src/main/java/org/osgi/service/async/Async.java
    aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/
    
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/AsyncDelegate.java
    
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/packageinfo
    aries/trunk/async/async-api/src/main/java/org/osgi/service/async/packageinfo
    aries/trunk/async/async-impl/   (with props)
    aries/trunk/async/async-impl/LICENSE
    aries/trunk/async/async-impl/NOTICE
    aries/trunk/async/async-impl/pom.xml
    aries/trunk/async/async-impl/src/
    aries/trunk/async/async-impl/src/main/
    aries/trunk/async/async-impl/src/main/java/
    aries/trunk/async/async-impl/src/main/java/org/
    aries/trunk/async/async-impl/src/main/java/org/apache/
    aries/trunk/async/async-impl/src/main/java/org/apache/aries/
    aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/
    aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/
    
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Activator.java
    
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncService.java
    
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncServiceFactory.java
    
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/FireAndForgetWork.java
    
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/MethodCall.java
    
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/TrackingInvocationHandler.java
    
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Work.java
    aries/trunk/async/async-impl/src/test/
    aries/trunk/async/async-impl/src/test/java/
    aries/trunk/async/async-impl/src/test/java/org/
    aries/trunk/async/async-impl/src/test/java/org/apache/
    aries/trunk/async/async-impl/src/test/java/org/apache/aries/
    aries/trunk/async/async-impl/src/test/java/org/apache/aries/async/
    aries/trunk/async/async-impl/src/test/java/org/apache/aries/async/impl/
    
aries/trunk/async/async-impl/src/test/java/org/apache/aries/async/impl/AsyncServiceTest.java
Modified:
    aries/trunk/async/   (props changed)
    aries/trunk/async/pom.xml
    aries/trunk/async/promise-api/pom.xml
    aries/trunk/pom.xml

Propchange: aries/trunk/async/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu May  7 15:19:32 2015
@@ -0,0 +1 @@
+target

Propchange: aries/trunk/async/async-all/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu May  7 15:19:32 2015
@@ -0,0 +1 @@
+target

Added: aries/trunk/async/async-all/LICENSE
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-all/LICENSE?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-all/LICENSE (added)
+++ aries/trunk/async/async-all/LICENSE Thu May  7 15:19:32 2015
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

Added: aries/trunk/async/async-all/NOTICE
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-all/NOTICE?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-all/NOTICE (added)
+++ aries/trunk/async/async-all/NOTICE Thu May  7 15:19:32 2015
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+

Added: aries/trunk/async/async-all/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-all/pom.xml?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-all/pom.xml (added)
+++ aries/trunk/async/async-all/pom.xml Thu May  7 15:19:32 2015
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.async</groupId>
+    <artifactId>org.apache.aries.async</artifactId>
+    <packaging>bundle</packaging>
+    <name>Aries Async Service Bundle (all in one)</name>
+    <version>0.0.1-SNAPSHOT</version>
+    <description>
+        This bundle contains the Aries Async Service implementation and all of 
its dependencies
+    </description>
+
+    <!--<scm>-->
+        
<!--<connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/async/async-api</connection>-->
+        
<!--<developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/async/async-api</developerConnection>-->
+        
<!--<url>http://svn.apache.org/viewvc/aries/trunk/async/async-api</url>-->
+    <!--</scm>-->
+
+    <properties>
+       
<aries.osgi.activator>org.apache.aries.async.impl.Activator</aries.osgi.activator>
+        <!-- Export package versions are maintained in packageinfo files -->
+        <aries.osgi.export.pkg>
+            org.apache.aries.async.promise,
+            org.osgi.service.async;provide:=true,
+            org.osgi.service.async.delegate,
+            org.osgi.util.function,
+            org.osgi.util.promise;provide:=true,
+            org.osgi.service.log
+        </aries.osgi.export.pkg>
+        <aries.osgi.private.pkg>
+               org.apache.aries.async.impl,
+            net.sf.cglib.*
+        </aries.osgi.private.pkg>
+        <aries.osgi.import.pkg>
+            org.apache.aries.async.promise,
+            org.osgi.service.async,
+            org.osgi.service.async.delegate,
+            org.osgi.util.function,
+            org.osgi.util.promise,
+            org.osgi.service.log,
+            !net.sf.cglib.asm.util,
+            !org.apache.tools.*,
+            *
+        </aries.osgi.import.pkg>
+        <lastReleaseVersion>0.0.1-SNAPSHOT</lastReleaseVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.async</groupId>
+            <artifactId>org.apache.aries.async.promise.api</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.async</groupId>
+            <artifactId>org.apache.aries.async.api</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.async</groupId>
+            <artifactId>org.apache.aries.async.impl</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+               <groupId>cglib</groupId>
+                       <artifactId>cglib-nodep</artifactId>
+                       <version>3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.aries.versioning</groupId>
+                <artifactId>org.apache.aries.versioning.plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>default-verify</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>version-check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                       <groupId>org.apache.felix</groupId>
+                       <artifactId>maven-bundle-plugin</artifactId>
+                   <configuration>
+                       <instructions>
+                               
<Provide-Capability>osgi.service;objectClass:List&lt;String&gt;=org.osgi.service.async.Async;uses:=org.osgi.service.async,osgi.implementation;osgi.implementation=osgi.async;version:Version=1.0.0;uses:=org.osgi.service.async</Provide-Capability>
+                       </instructions>
+                   </configuration>
+               </plugin>
+        </plugins>
+    </build>
+
+</project>

Propchange: aries/trunk/async/async-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu May  7 15:19:32 2015
@@ -0,0 +1 @@
+target

Added: aries/trunk/async/async-api/LICENSE
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-api/LICENSE?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-api/LICENSE (added)
+++ aries/trunk/async/async-api/LICENSE Thu May  7 15:19:32 2015
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

Added: aries/trunk/async/async-api/NOTICE
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-api/NOTICE?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-api/NOTICE (added)
+++ aries/trunk/async/async-api/NOTICE Thu May  7 15:19:32 2015
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+

Added: aries/trunk/async/async-api/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-api/pom.xml?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-api/pom.xml (added)
+++ aries/trunk/async/async-api/pom.xml Thu May  7 15:19:32 2015
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.async</groupId>
+    <artifactId>org.apache.aries.async.api</artifactId>
+    <packaging>bundle</packaging>
+    <name>OSGI Async API</name>
+    <version>0.0.1-SNAPSHOT</version>
+    <description>
+        This bundle contains the OSGi Async Service API.
+    </description>
+
+    <!--<scm>-->
+        
<!--<connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/async/async-api</connection>-->
+        
<!--<developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/async/async-api</developerConnection>-->
+        
<!--<url>http://svn.apache.org/viewvc/aries/trunk/async/async-api</url>-->
+    <!--</scm>-->
+
+    <properties>
+        <!-- Export package versions are maintained in packageinfo files -->
+        <aries.osgi.export.pkg>
+            org.osgi.service.async,
+            org.osgi.service.async.delegate
+        </aries.osgi.export.pkg>
+        <aries.osgi.private.pkg />
+        <aries.osgi.import.pkg>
+            org.osgi.service.async,
+            org.osgi.service.async.delegate,
+            *
+        </aries.osgi.import.pkg>
+        <lastReleaseVersion>0.0.1-SNAPSHOT</lastReleaseVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.async</groupId>
+            <artifactId>org.apache.aries.async.promise.api</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.annotation</artifactId>
+            <version>6.0.1</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.aries.versioning</groupId>
+                <artifactId>org.apache.aries.versioning.plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>default-verify</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>version-check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/Async.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-api/src/main/java/org/osgi/service/async/Async.java?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-api/src/main/java/org/osgi/service/async/Async.java 
(added)
+++ aries/trunk/async/async-api/src/main/java/org/osgi/service/async/Async.java 
Thu May  7 15:19:32 2015
@@ -0,0 +1,59 @@
+package org.osgi.service.async;
+
+import org.osgi.annotation.versioning.ProviderType;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.promise.Promise;
+
+/**
+ * The Async Service, as defined in OSGi RFC 204
+ * https://github.com/osgi/design/tree/master/rfcs/rfc0206
+ */
+@ProviderType
+public interface Async {
+    
+    /**
+     * Create a mediated object for asynchronous calls
+     *
+     * @param target The object to mediate
+     * @param iface The type that the mediated object should implement or 
extend
+     * @return A mediated object
+     * @throws IllegalArgumentException if mediation fails
+     */
+    <T> T mediate(T target, Class<T> iface);
+    
+    /**
+     * Create a mediated object for asynchronous calls
+     *
+     * @param target The service reference to mediate
+     * @param iface The type that the mediated object should implement or 
extend
+     * @return A mediated service
+     * @throws IllegalArgumentException if mediation fails
+     */
+    <T> T mediate(ServiceReference<? extends T> target, Class<T> iface);
+    
+    /**
+     * Asynchronously run the last method call registered by a mediated object,
+     * returning the result as a Promise.
+     *
+     * @param r the return value of the mediated call
+     * @return a Promise
+     */
+    <R> Promise<R> call(R r);
+    
+    /**
+     * Asynchronously run the last method call registered by a mediated object,
+     * returning the result as a Promise.
+     *
+     * @return a Promise
+     */
+    Promise<?> call();
+    
+    /**
+     * Asynchronously run the last method call registered by a mediated object,
+     * ignoring the return value.
+     *
+     * @return a Promise indicating whether the task started successfully
+     */
+    Promise<Void> execute();
+    
+}

Added: 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/AsyncDelegate.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/AsyncDelegate.java?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/AsyncDelegate.java
 (added)
+++ 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/AsyncDelegate.java
 Thu May  7 15:19:32 2015
@@ -0,0 +1,35 @@
+package org.osgi.service.async.delegate;
+
+import java.lang.reflect.Method;
+import org.osgi.annotation.versioning.ConsumerType;
+import org.osgi.util.promise.Promise;
+
+/**
+ * The AsyncDelegate, as defined in OSGi RFC 204
+ * https://github.com/osgi/design/tree/master/rfcs/rfc0206
+ */
+@ConsumerType
+public interface AsyncDelegate {
+       /**
+        * Asynchronously call a method
+        * 
+        * @param m the method
+        * @param args the arguments
+        * 
+        * @return A promise, or <code>null</code> if the method is not 
supported
+     *
+        * @throws Exception
+     */
+       Promise<?> async(Method m, Object[] args) throws Exception;
+
+       /**
+     * Asynchronously call a method
+        * 
+     * @param m the method
+     * @param args the arguments
+        * 
+        * @return <code>true<code> if accepted, or <code>false</code> 
otherwise.
+        * @throws Exception 
+        */
+       boolean execute(Method m, Object[] args) throws Exception;
+}

Added: 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/packageinfo
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/packageinfo?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/packageinfo
 (added)
+++ 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/delegate/packageinfo
 Thu May  7 15:19:32 2015
@@ -0,0 +1 @@
+version 1.0

Added: 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/packageinfo
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-api/src/main/java/org/osgi/service/async/packageinfo?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/packageinfo 
(added)
+++ 
aries/trunk/async/async-api/src/main/java/org/osgi/service/async/packageinfo 
Thu May  7 15:19:32 2015
@@ -0,0 +1 @@
+version 1.0

Propchange: aries/trunk/async/async-impl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu May  7 15:19:32 2015
@@ -0,0 +1 @@
+target

Added: aries/trunk/async/async-impl/LICENSE
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/LICENSE?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-impl/LICENSE (added)
+++ aries/trunk/async/async-impl/LICENSE Thu May  7 15:19:32 2015
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

Added: aries/trunk/async/async-impl/NOTICE
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/NOTICE?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-impl/NOTICE (added)
+++ aries/trunk/async/async-impl/NOTICE Thu May  7 15:19:32 2015
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+

Added: aries/trunk/async/async-impl/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/pom.xml?rev=1678229&view=auto
==============================================================================
--- aries/trunk/async/async-impl/pom.xml (added)
+++ aries/trunk/async/async-impl/pom.xml Thu May  7 15:19:32 2015
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>parent</artifactId>
+        <version>2.0.0</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.async</groupId>
+    <artifactId>org.apache.aries.async.impl</artifactId>
+    <packaging>bundle</packaging>
+    <name>Aries Async Service</name>
+    <version>0.0.1-SNAPSHOT</version>
+    <description>
+        This bundle contains the Aries Async Service implementation.
+    </description>
+
+    <!--<scm>-->
+        
<!--<connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/async/async-api</connection>-->
+        
<!--<developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/async/async-api</developerConnection>-->
+        
<!--<url>http://svn.apache.org/viewvc/aries/trunk/async/async-api</url>-->
+    <!--</scm>-->
+
+    <properties>
+       
<aries.osgi.activator>org.apache.aries.async.impl.Activator</aries.osgi.activator>
+        <!-- Export package versions are maintained in packageinfo files -->
+        <aries.osgi.export.pkg>
+        </aries.osgi.export.pkg>
+        <aries.osgi.private.pkg>
+               org.apache.aries.async.impl
+        </aries.osgi.private.pkg>
+        <aries.osgi.import.pkg>
+            *
+        </aries.osgi.import.pkg>
+        <lastReleaseVersion>0.0.1-SNAPSHOT</lastReleaseVersion>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.async</groupId>
+            <artifactId>org.apache.aries.async.promise.api</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.async</groupId>
+            <artifactId>org.apache.aries.async.api</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.annotation</artifactId>
+            <version>6.0.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.annotation</artifactId>
+            <version>6.0.1</version>
+        </dependency>
+        <dependency>
+               <groupId>cglib</groupId>
+                       <artifactId>cglib-nodep</artifactId>
+                       <version>3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.9.5</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.aries.versioning</groupId>
+                <artifactId>org.apache.aries.versioning.plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>default-verify</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>version-check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+               <plugin>
+                       <groupId>org.apache.felix</groupId>
+                       <artifactId>maven-bundle-plugin</artifactId>
+                   <configuration>
+                       <instructions>
+                               
<Provide-Capability>osgi.service;objectClass:List&lt;String&gt;=org.osgi.service.async.Async;uses:=org.osgi.service.async,osgi.implementation;osgi.implementation=osgi.async;version:Version=1.0.0;uses:=org.osgi.service.async</Provide-Capability>
+                       </instructions>
+                   </configuration>
+               </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Activator.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Activator.java?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Activator.java
 (added)
+++ 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Activator.java
 Thu May  7 15:19:32 2015
@@ -0,0 +1,51 @@
+package org.apache.aries.async.impl;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Hashtable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.async.Async;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator implements BundleActivator {
+       
+       private final ExecutorService executor = 
Executors.newFixedThreadPool(10, new ThreadFactory() {
+               
+               private final AtomicInteger count = new AtomicInteger();
+               
+               public Thread newThread(final Runnable r) {
+                       Thread t = new Thread(new Runnable(){
+                               public void run() {
+                                       AccessController.doPrivileged(new 
PrivilegedAction<Void>() {
+                                               public Void run() {
+                                                       r.run();
+                                                       return null;
+                                               }
+                                       });
+                               }
+                       }, "Asynchronous Execution Service Thread " + 
count.incrementAndGet());
+                       return t;
+               }
+       });
+       
+       private volatile ServiceTracker<LogService, LogService> 
logServiceTracker;
+       
+       public void start(BundleContext context) throws Exception {
+               logServiceTracker = new ServiceTracker<LogService, 
LogService>(context, LogService.class, null);
+               logServiceTracker.open();
+               
+               context.registerService(Async.class.getName(), new 
AsyncServiceFactory(executor, logServiceTracker), new Hashtable<String, 
Object>());
+       }
+
+       public void stop(BundleContext context) throws Exception {
+               executor.shutdownNow();
+               logServiceTracker.close();
+       }
+}

Added: 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncService.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncService.java?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncService.java
 (added)
+++ 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncService.java
 Thu May  7 15:19:32 2015
@@ -0,0 +1,175 @@
+package org.apache.aries.async.impl;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+
+import net.sf.cglib.proxy.Enhancer;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.service.async.Async;
+import org.osgi.service.log.LogService;
+import org.osgi.util.promise.Promise;
+import org.osgi.util.tracker.ServiceTracker;
+
+
+public class AsyncService implements Async {
+
+       private static final class CGLibAwareClassLoader extends ClassLoader {
+               private final ClassLoader serviceTypeLoader;
+
+               private CGLibAwareClassLoader(Bundle registeringBundle) {
+                       this.serviceTypeLoader = 
registeringBundle.adapt(BundleWiring.class).getClassLoader();
+               }
+
+               private CGLibAwareClassLoader(ClassLoader loader) {
+                       this.serviceTypeLoader = loader;
+               }
+
+               @Override
+               protected Class<?> findClass(String var0)
+                               throws ClassNotFoundException {
+                       if(var0.startsWith("net.sf.cglib")) {
+                               return 
AsyncService.class.getClassLoader().loadClass(var0);
+                       } else {
+                               return serviceTypeLoader.loadClass(var0);
+                       }
+               }
+       }
+
+       private final Bundle clientBundle;
+       
+       private final ConcurrentMap<Thread, MethodCall> invocations = new 
ConcurrentHashMap<Thread, MethodCall>();
+       
+       private final ExecutorService executor;
+       
+       private final ServiceTracker<LogService, LogService> logServiceTracker;
+       
+       public AsyncService(Bundle clientBundle, ExecutorService executor, 
ServiceTracker<LogService, LogService> logServiceTracker) {
+               super();
+               this.clientBundle = clientBundle;
+               this.executor = executor;
+               this.logServiceTracker = logServiceTracker;
+       }
+
+       public <T> T mediate(final T service, final Class<T> iface) {
+               return AccessController.doPrivileged(new PrivilegedAction<T>() {
+                       public T run() {
+                               return privMediate(service, iface);
+                       }
+               });
+       }
+
+       @SuppressWarnings("unchecked")
+       private <T> T privMediate(T service, Class<T> iface) {
+               
+               TrackingInvocationHandler handler = new 
TrackingInvocationHandler(this, 
+                               clientBundle, logServiceTracker, service);
+               
+               if(iface.isInterface()) {
+                       return (T) Proxy.newProxyInstance(
+                                       new 
ClassLoader(service.getClass().getClassLoader()){}, 
+                                       new Class[] {iface}, handler);
+               } else {
+                       return (T) proxyClass(iface, handler, 
+                                       new 
CGLibAwareClassLoader(service.getClass().getClassLoader()));
+               }
+       }
+
+       public <T> T mediate(final ServiceReference<? extends T> ref, final 
Class<T> iface) {
+               return AccessController.doPrivileged(new PrivilegedAction<T>() {
+                       public T run() {
+                               return privMediate(ref, iface);
+                       }
+               });
+       }
+       
+       @SuppressWarnings("unchecked")
+       private <T> T privMediate(ServiceReference<? extends T> ref, Class<T> 
iface) {
+
+               TrackingInvocationHandler handler = new 
TrackingInvocationHandler(this, 
+                               clientBundle, logServiceTracker, ref);
+               
+               Bundle registeringBundle = ref.getBundle();
+
+               if(iface.isInterface()) {
+                       return (T) Proxy.newProxyInstance(
+                                       new 
ClassLoader(registeringBundle.adapt(BundleWiring.class).getClassLoader()){}, 
+                                       new Class[] {iface}, handler);
+               } else {
+                       return (T) proxyClass(iface, handler, 
+                                       new 
CGLibAwareClassLoader(registeringBundle));
+               }
+       }
+
+       private Object proxyClass(Class<?> mostSpecificClass, 
+                       TrackingInvocationHandler handler, ClassLoader 
classLoader) {
+               
+               acceptClassType(mostSpecificClass);
+               
+               Enhancer enhancer = new Enhancer();
+               enhancer.setClassLoader(classLoader);
+               enhancer.setSuperclass(mostSpecificClass);
+               enhancer.setCallback(handler);
+               
+               return enhancer.create();
+       }
+
+       private void acceptClassType(Class<?> type) {
+               
+               if(Modifier.isFinal(type.getModifiers())) {
+                       throw new IllegalArgumentException("The type " + 
type.getName() + " is final");
+               }
+               try {
+                       type.getConstructor();
+               } catch (NoSuchMethodException nsme) {
+                       throw new IllegalArgumentException("The type " + 
type.getName() + " has no zero-argument constructor", nsme);
+               }
+               
+               Class<?> toCheck = type;
+               while(toCheck != Object.class) {
+                       for(Method m : toCheck.getDeclaredMethods()) {
+                               if(Modifier.isFinal(m.getModifiers())) {
+                                       throw new IllegalArgumentException("The 
type hierarchy for " + type.getName() + 
+                                                       " has a final method " 
+ m.getName() + " defined on " + toCheck.getName());
+                               }
+                       }
+                       toCheck = toCheck.getSuperclass();
+               }
+       }
+
+       public <T> Promise<T> call(T call) throws IllegalStateException {
+               MethodCall currentInvocation = consumeCurrentInvocation();
+               if(currentInvocation == null) throw new 
IllegalStateException("Incorrect API usage - this thread has no pending method 
calls");
+               return currentInvocation.invokeAsynchronously(clientBundle, 
executor);
+       }
+
+       public Promise<?> call() throws IllegalStateException {
+               return call(null);
+       }
+
+       public Promise<Void> execute() throws IllegalStateException {
+               MethodCall currentInvocation = consumeCurrentInvocation();
+               if(currentInvocation == null) throw new 
IllegalStateException("Incorrect API usage - this thread has no pending method 
calls");
+               return currentInvocation.fireAndForget(clientBundle, executor);
+       }
+
+       void registerInvocation(MethodCall invocation) {
+               if(invocations.putIfAbsent(Thread.currentThread(), invocation) 
!= null) {
+                       invocations.remove(Thread.currentThread());
+                       throw new IllegalStateException("Incorrect API usage - 
this thread already has a pending method call");
+               }
+       }
+
+       MethodCall consumeCurrentInvocation() {
+               return invocations.remove(Thread.currentThread());
+       }
+
+}

Added: 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncServiceFactory.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncServiceFactory.java?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncServiceFactory.java
 (added)
+++ 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/AsyncServiceFactory.java
 Thu May  7 15:19:32 2015
@@ -0,0 +1,32 @@
+package org.apache.aries.async.impl;
+
+import java.util.concurrent.ExecutorService;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.async.Async;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class AsyncServiceFactory implements ServiceFactory<Async> {
+
+       private final ExecutorService executor;
+       
+       private final ServiceTracker<LogService, LogService> logServiceTracker;
+       
+       public AsyncServiceFactory(ExecutorService executor, 
ServiceTracker<LogService, LogService> logServiceTracker) {
+               this.logServiceTracker = logServiceTracker;
+               this.executor = executor;
+       }
+
+       public Async getService(Bundle bundle,
+                       ServiceRegistration<Async> registration) {
+               
+               return new AsyncService(bundle, executor, logServiceTracker);
+       }
+
+       public void ungetService(Bundle bundle,
+                       ServiceRegistration<Async> registration, Async service) 
{}
+
+}

Added: 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/FireAndForgetWork.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/FireAndForgetWork.java?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/FireAndForgetWork.java
 (added)
+++ 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/FireAndForgetWork.java
 Thu May  7 15:19:32 2015
@@ -0,0 +1,55 @@
+package org.apache.aries.async.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.osgi.util.promise.Deferred;
+
+public class FireAndForgetWork implements Runnable {
+
+       private final MethodCall methodCall;
+       
+       private final Deferred<Void> cleanup;
+       private final Deferred<Void> started;
+
+       private final AccessControlContext acc;
+       
+       public FireAndForgetWork(MethodCall methodCall, Deferred<Void> cleanup, 
Deferred<Void> started) {
+               this.methodCall = methodCall;
+               this.cleanup = cleanup;
+               this.started = started;
+               this.acc = AccessController.getContext();
+       }
+
+
+       public void run() {
+               try {
+                       final Object service = methodCall.getService();
+                       // This is necessary for non public methods. The 
original mediator call must
+                       // have been allowed to happen, so this should always 
be safe.
+                       methodCall.method.setAccessible(true);
+                       
+                       AccessController.doPrivileged(new 
PrivilegedAction<Void>() {
+                               public Void run() {
+                                       started.resolve(null);
+                                       try {
+                                               
methodCall.method.invoke(service, methodCall.arguments);
+                                               cleanup.resolve(null);
+                                       } catch (InvocationTargetException ite) 
{
+                                               
cleanup.fail(ite.getTargetException());
+                                       } catch (Exception e) {
+                                               cleanup.fail(e);
+                                       }
+                                       return null;
+                               }
+                       }, acc);
+               } catch (Exception e) {
+                       started.fail(e);
+                       cleanup.fail(e);
+               } finally {
+                       methodCall.releaseService();
+               }
+       }
+}

Added: 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/MethodCall.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/MethodCall.java?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/MethodCall.java
 (added)
+++ 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/MethodCall.java
 Thu May  7 15:19:32 2015
@@ -0,0 +1,176 @@
+package org.apache.aries.async.impl;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.RejectedExecutionException;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.async.delegate.AsyncDelegate;
+import org.osgi.service.log.LogService;
+import org.osgi.util.promise.Deferred;
+import org.osgi.util.promise.Failure;
+import org.osgi.util.promise.Promise;
+import org.osgi.util.promise.Promises;
+import org.osgi.util.tracker.ServiceTracker;
+
+
+public class MethodCall {
+       
+       private final Bundle clientBundle;
+       private final ServiceTracker<LogService, LogService> logServiceTracker;
+       
+       private final ServiceReference<?> reference;
+       private final Object service;
+
+       final Method method;
+       final Object[] arguments;
+       
+       public MethodCall(Bundle clientBundle, ServiceTracker<LogService, 
LogService> logServiceTracker, 
+                       ServiceReference<?> reference, Object service, Method 
method, Object[] arguments) {
+               this.clientBundle = clientBundle;
+               this.logServiceTracker = logServiceTracker;
+               this.reference = reference;
+               this.service = service;
+               this.method = method;
+               this.arguments = arguments;
+       }
+
+       Object getService() {
+               if(reference != null) {
+                       BundleContext bc = clientBundle.getBundleContext();
+                       if(bc != null) {
+                               try {
+                                       Object svc = bc.getService(reference);
+                                       if(svc == null) {
+                                               throw new 
ServiceException("Unable to retrieve the mediated service because it has been 
unregistered", 7);
+                                       } else {
+                                               return svc;
+                                       }
+                               } catch (Exception e) {
+                                       throw new ServiceException("Unable to 
retrieve the mediated service", 7, e);
+                               }
+                       } else {
+                               throw new ServiceException("Unable to retrieve 
the mediated service because the client bundle has been stopped", 7);
+                       }
+               } else {
+                       return service;
+               }
+       }
+       
+       void releaseService() {
+               if(reference != null) {
+                       BundleContext bc = clientBundle.getBundleContext();
+                       if(bc != null) {
+                               bc.ungetService(reference);
+                       }
+               }
+       }
+       
+       public <V> Promise<V> invokeAsynchronously(Bundle clientBundle, 
ExecutorService executor) {
+               
+               Deferred<V> deferred = new Deferred<V>();
+
+               Object svc;
+               try {
+                       svc = getService();
+               } catch (Exception e) {
+                       deferred.fail(e);
+                       return deferred.getPromise();
+               }
+               
+               if(svc instanceof AsyncDelegate) {
+                       try {
+                               @SuppressWarnings("unchecked")
+                               Promise<V> p = (Promise<V>) ((AsyncDelegate) 
svc).async(method, arguments);
+                               if(p != null) {
+                                       try {
+                                               deferred.resolveWith(p);
+                                               return deferred.getPromise();
+                                       } finally {
+                                               releaseService();
+                                       }
+                               }
+                       } catch (Exception e) {
+                               try {
+                                       deferred.fail(e);
+                                       return deferred.getPromise();
+                               } finally {
+                                       releaseService();
+                               }
+                       }
+               }
+               //If we get here then svc is either not an async delegate, or 
it rejected the call
+               
+               try {
+                       executor.execute(new Work<V>(this, deferred));
+               } catch (RejectedExecutionException ree) {
+                       deferred.fail(new ServiceException("The Async service 
is unable to accept new requests", 7, ree));
+               }
+               Promise<V> promise = deferred.getPromise();
+               
+               //Release the service we got at the start of this method
+               promise.onResolve(new Runnable() {
+                       public void run() {
+                               releaseService();
+                       }
+               });
+               
+               return promise;
+       }
+
+       public Promise<Void> fireAndForget(Bundle clientBundle, ExecutorService 
executor) {
+               Object svc;
+               try {
+                       svc = getService();
+               } catch (Exception e) {
+                       logError("Unable to obtain the service object", e);
+                       return Promises.failed(e);
+               }
+               
+               if(svc instanceof AsyncDelegate) {
+                       try {
+                               if(((AsyncDelegate) svc).execute(method, 
arguments)) {
+                                       releaseService();
+                                       return Promises.resolved(null);
+                               }
+                       } catch (Exception e) {
+                               releaseService();
+                               logError("The AsyncDelegate rejected the 
fire-and-forget invocation with an exception", e);
+                               return Promises.failed(e);
+                       }
+               }
+               //If we get here then svc is either not an async delegate, or 
it rejected the call
+               
+               Deferred<Void> cleanup = new Deferred<Void>();
+               Deferred<Void> started = new Deferred<Void>();
+               try {
+                       executor.execute(new FireAndForgetWork(this, cleanup, 
started));
+                       cleanup.getPromise().onResolve(new Runnable() {
+                               public void run() {
+                                       releaseService();
+                               }
+                       }).then(null, new Failure(){
+                               public void fail(Promise<?> resolved) throws 
Exception {
+                                       logError("The fire-and-forget 
invocation failed", resolved.getFailure());
+                               }
+                       });
+                       return started.getPromise();
+               } catch (RejectedExecutionException ree) {
+                       logError("The Async Service threadpool rejected the 
fire-and-forget invocation", ree);
+                       return Promises.failed(new ServiceException("Unable to 
enqueue the fire-and forget task", 7, ree));
+               }
+       }
+
+       void logError(String message, Throwable e) {
+               for(LogService log : logServiceTracker.getServices(new 
LogService[0])) {
+                       if(reference == null) {
+                               log.log(LogService.LOG_ERROR, message, e);
+                       } else {
+                               log.log(reference,  LogService.LOG_ERROR, 
message, e);
+                       }
+               }
+       }
+}

Added: 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/TrackingInvocationHandler.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/TrackingInvocationHandler.java?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/TrackingInvocationHandler.java
 (added)
+++ 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/TrackingInvocationHandler.java
 Thu May  7 15:19:32 2015
@@ -0,0 +1,69 @@
+package org.apache.aries.async.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+class TrackingInvocationHandler implements InvocationHandler, 
net.sf.cglib.proxy.InvocationHandler {
+
+       private static final Map<Class<?>, Object> RETURN_VALUES;
+       
+       static {
+               Map<Class<?>, Object> map = new HashMap<Class<?>, Object>();
+               
+               map.put(boolean.class, Boolean.FALSE);
+               map.put(byte.class, Byte.valueOf((byte)0));
+               map.put(short.class, Short.valueOf((short)0));
+               map.put(char.class, Character.valueOf((char)0));
+               map.put(int.class, Integer.valueOf(0));
+               map.put(float.class, Float.valueOf(0));
+               map.put(long.class, Long.valueOf(0));
+               map.put(double.class, Double.valueOf(0));
+               
+               RETURN_VALUES = Collections.unmodifiableMap(map);
+       }
+       
+       /**
+        * 
+        */
+       private final AsyncService asyncService;
+       private final ServiceTracker<LogService, LogService> logServiceTracker;
+       private final Bundle clientBundle;
+       private final ServiceReference<?> ref;
+       private final Object delegate;
+       
+       public TrackingInvocationHandler(AsyncService asyncService, 
+                       Bundle clientBundle, ServiceTracker<LogService, 
LogService> logServiceTracker, 
+                       ServiceReference<?> ref) {
+               this.asyncService = asyncService;
+               this.logServiceTracker = logServiceTracker;
+               this.clientBundle = clientBundle;
+               this.ref = ref;
+               this.delegate = null;
+       }
+       public TrackingInvocationHandler(AsyncService asyncService, 
+                       Bundle clientBundle,ServiceTracker<LogService, 
LogService> logServiceTracker, 
+                       Object service) {
+               this.asyncService = asyncService;
+               this.logServiceTracker = logServiceTracker;
+               this.clientBundle = clientBundle;
+               this.delegate = service;
+               this.ref = null;
+       }
+
+       public Object invoke(Object proxy, Method method, Object[] args)
+                       throws Throwable {
+               asyncService.registerInvocation(new MethodCall(clientBundle, 
logServiceTracker, 
+                               ref, delegate, method, args));
+               Class<?> returnType = method.getReturnType();
+               return RETURN_VALUES.get(returnType);
+       }
+       
+}

Added: 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Work.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Work.java?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Work.java
 (added)
+++ 
aries/trunk/async/async-impl/src/main/java/org/apache/aries/async/impl/Work.java
 Thu May  7 15:19:32 2015
@@ -0,0 +1,54 @@
+package org.apache.aries.async.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.osgi.util.promise.Deferred;
+
+public class Work<T> implements Runnable {
+
+       private final MethodCall methodCall;
+       
+       private final Deferred<T> deferred;
+
+       private final AccessControlContext acc;
+       
+       public Work(MethodCall methodCall, Deferred<T> deferred) {
+               this.methodCall = methodCall;
+               this.deferred = deferred;
+               this.acc = AccessController.getContext();
+       }
+
+
+       public void run() {
+               try {
+                       final Object service = methodCall.getService();
+                       // This is necessary for non public methods. The 
original mediator call must
+                       // have been allowed to happen, so this should always 
be safe.
+                       methodCall.method.setAccessible(true);
+                       
+                       @SuppressWarnings("unchecked")
+                       T returnValue = AccessController.doPrivileged(new 
PrivilegedExceptionAction<T>() {
+                               public T run() throws Exception {
+                                       return (T) 
methodCall.method.invoke(service, methodCall.arguments);
+                               }
+                       }, acc);
+                       
+                       deferred.resolve(returnValue);
+                       
+               } catch (PrivilegedActionException pae) {
+                       Throwable targetException = pae.getCause();
+                       if(targetException instanceof 
InvocationTargetException) {
+                               targetException = ((InvocationTargetException) 
targetException).getTargetException();
+                       }
+                       deferred.fail(targetException);
+               } catch (Exception e) {
+                       deferred.fail(e);
+               } finally {
+                       methodCall.releaseService();
+               }
+       }
+}

Added: 
aries/trunk/async/async-impl/src/test/java/org/apache/aries/async/impl/AsyncServiceTest.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/async-impl/src/test/java/org/apache/aries/async/impl/AsyncServiceTest.java?rev=1678229&view=auto
==============================================================================
--- 
aries/trunk/async/async-impl/src/test/java/org/apache/aries/async/impl/AsyncServiceTest.java
 (added)
+++ 
aries/trunk/async/async-impl/src/test/java/org/apache/aries/async/impl/AsyncServiceTest.java
 Thu May  7 15:19:32 2015
@@ -0,0 +1,88 @@
+package org.apache.aries.async.impl;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.service.log.LogService;
+import org.osgi.util.function.Predicate;
+import org.osgi.util.promise.Promise;
+import org.osgi.util.promise.Success;
+import org.osgi.util.tracker.ServiceTracker;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AsyncServiceTest {
+
+       public static class DelayedEcho {
+               public String echo(String s, int delay) {
+                       try {
+                               Thread.sleep(delay);
+                       } catch (InterruptedException e) {
+                               throw new RuntimeException("Thread 
interrupted", e);
+                       }
+                       if (s == null) throw new NullPointerException("Nothing 
to echo!");
+                       return s;
+               }
+       }
+       
+       private ExecutorService es;
+       
+       @Mock
+       ServiceTracker<LogService, LogService> serviceTracker;
+       
+       @Before
+       public void start() {
+               es = Executors.newFixedThreadPool(3);
+       }
+
+       @After
+       public void stop() {
+               es.shutdownNow();
+               try {
+                       es.awaitTermination(5, TimeUnit.SECONDS);
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+       }
+       
+       
+       @Test
+       public void test() throws InterruptedException {
+               DelayedEcho raw = new DelayedEcho();
+               
+               AsyncService service = new AsyncService(null, es, 
+                               serviceTracker);
+               
+               DelayedEcho mediated = service.mediate(raw, DelayedEcho.class);
+               
+               Promise<String> promise = service.call(mediated.echo("Hello 
World", 1000));
+               
+               final CountDownLatch latch = new CountDownLatch(1);
+               
+               promise.filter(new Predicate<String>() {
+                               @Override
+                               public boolean test(String t) {
+                                       return "Hello World".equals(t);
+                               }
+                       }).then(new Success<String, Void>() {
+                               @Override
+                               public Promise<Void> call(Promise<String> 
resolved)
+                                               throws Exception {
+                                       latch.countDown();
+                                       return null;
+                               }
+                       });
+               
+               assertTrue(latch.await(5, TimeUnit.SECONDS));
+       }
+
+}

Modified: aries/trunk/async/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/pom.xml?rev=1678229&r1=1678228&r2=1678229&view=diff
==============================================================================
--- aries/trunk/async/pom.xml (original)
+++ aries/trunk/async/pom.xml Thu May  7 15:19:32 2015
@@ -39,6 +39,9 @@
 
     <modules>
         <module>promise-api</module>
+        <module>async-api</module>
+        <module>async-impl</module>
+        <module>async-all</module>
     </modules>
 
 </project>

Modified: aries/trunk/async/promise-api/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/async/promise-api/pom.xml?rev=1678229&r1=1678228&r2=1678229&view=diff
==============================================================================
--- aries/trunk/async/promise-api/pom.xml (original)
+++ aries/trunk/async/promise-api/pom.xml Thu May  7 15:19:32 2015
@@ -56,7 +56,7 @@
             org.osgi.util.promise,
             *
         </aries.osgi.import.pkg>
-        <lastReleaseVersion>0.0.0</lastReleaseVersion>
+        <lastReleaseVersion>0.0.1-SNAPSHOT</lastReleaseVersion>
     </properties>
 
     <dependencies>

Modified: aries/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/pom.xml?rev=1678229&r1=1678228&r2=1678229&view=diff
==============================================================================
--- aries/trunk/pom.xml (original)
+++ aries/trunk/pom.xml Thu May  7 15:19:32 2015
@@ -57,6 +57,7 @@
         <module>samples</module>
         <module>esa-ant-task</module>
         <module>esa-maven-plugin</module>
+        <module>async</module>
     </modules>
 
     <build>


Reply via email to