Author: timothyjward
Date: Wed Mar  9 14:38:15 2016
New Revision: 1734243

URL: http://svn.apache.org/viewvc?rev=1734243&view=rev
Log:
[tx-control] Separate common tx-service code and use it to build an XA 
Transaction Control service

Added:
    aries/trunk/tx-control/tx-control-service-common/
    aries/trunk/tx-control/tx-control-service-common/LICENSE
    aries/trunk/tx-control/tx-control-service-common/NOTICE
    aries/trunk/tx-control/tx-control-service-common/pom.xml
      - copied, changed from r1733320, 
aries/trunk/tx-control/tx-control-service-local/pom.xml
    aries/trunk/tx-control/tx-control-service-common/src/
    aries/trunk/tx-control/tx-control-service-common/src/main/
    aries/trunk/tx-control/tx-control-service-common/src/main/java/
    aries/trunk/tx-control/tx-control-service-common/src/main/java/org/
    aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/activator/
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/activator/AbstractActivator.java
      - copied, changed from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/Activator.java
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionContextImpl.java
      - copied, changed from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/AbstractTransactionContextImpl.java
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionControlImpl.java
      - copied, changed from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionControlImpl.java
    
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextImpl.java
      - copied, changed from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextImpl.java
    aries/trunk/tx-control/tx-control-service-common/src/test/
    aries/trunk/tx-control/tx-control-service-common/src/test/java/
    aries/trunk/tx-control/tx-control-service-common/src/test/java/org/
    aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/
    
aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/
    
aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/
    
aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/control/
    
aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/control/service/
    
aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/control/service/common/
    
aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/control/service/common/impl/
    
aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextTest.java
      - copied, changed from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextTest.java
    aries/trunk/tx-control/tx-control-service-xa/
    aries/trunk/tx-control/tx-control-service-xa/LICENSE
    aries/trunk/tx-control/tx-control-service-xa/NOTICE
    aries/trunk/tx-control/tx-control-service-xa/pom.xml
      - copied, changed from r1733320, 
aries/trunk/tx-control/tx-control-service-local/pom.xml
    aries/trunk/tx-control/tx-control-service-xa/src/
    aries/trunk/tx-control/tx-control-service-xa/src/main/
    aries/trunk/tx-control/tx-control-service-xa/src/main/java/
    aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/
    aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/
    aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/
    
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/
    
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/
    
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/
    
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/
    
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/
    
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/Activator.java
    
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/TransactionContextImpl.java
    
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/TransactionControlImpl.java
    aries/trunk/tx-control/tx-control-service-xa/src/test/
    aries/trunk/tx-control/tx-control-service-xa/src/test/java/
    aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/
    aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/
    aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/
    
aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/tx/
    
aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/tx/control/
    
aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/tx/control/service/
    
aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/tx/control/service/xa/
    
aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/tx/control/service/xa/impl/
    
aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/tx/control/service/xa/impl/TransactionContextTest.java
      - copied, changed from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/TransactionContextTest.java
    
aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/tx/control/service/xa/impl/TransactionControlRunningTest.java
    
aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/tx/control/service/xa/impl/TransactionControlStatusTest.java
    
aries/trunk/tx-control/tx-control-service-xa/src/test/java/org/apache/aries/tx/control/service/xa/impl/TransactionLifecycleTest.java
Removed:
    
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/AbstractTransactionContextImpl.java
    
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextImpl.java
    
aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextTest.java
Modified:
    aries/trunk/tx-control/pom.xml
    aries/trunk/tx-control/tx-control-itests/pom.xml
    
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
    aries/trunk/tx-control/tx-control-service-local/pom.xml
    
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/Activator.java
    
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionContextImpl.java
    
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionControlImpl.java
    
aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/TransactionContextTest.java

Modified: aries/trunk/tx-control/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/pom.xml?rev=1734243&r1=1734242&r2=1734243&view=diff
==============================================================================
--- aries/trunk/tx-control/pom.xml (original)
+++ aries/trunk/tx-control/pom.xml Wed Mar  9 14:38:15 2016
@@ -42,7 +42,9 @@
                        </activation>
                        <modules>
                                <module>tx-control-api</module>
+                               <module>tx-control-service-common</module>
                                <module>tx-control-service-local</module>
+                               <module>tx-control-service-xa</module>
                                <module>tx-control-provider-jdbc-local</module>
                                <module>tx-control-itests</module>
                        </modules>

Modified: aries/trunk/tx-control/tx-control-itests/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/pom.xml?rev=1734243&r1=1734242&r2=1734243&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-itests/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-itests/pom.xml Wed Mar  9 14:38:15 2016
@@ -53,6 +53,12 @@
                        <version>0.0.1-SNAPSHOT</version>
                </dependency>
                <dependency>
+                       <groupId>org.apache.aries.tx-control</groupId>
+                       <artifactId>tx-control-service-xa</artifactId>
+                       <scope>test</scope>
+                       <version>0.0.1-SNAPSHOT</version>
+               </dependency>
+               <dependency>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>org.apache.felix.coordinator</artifactId>
                        <scope>test</scope>

Modified: 
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java?rev=1734243&r1=1734242&r2=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
 Wed Mar  9 14:38:15 2016
@@ -164,7 +164,7 @@ public abstract class AbstractTransactio
        }
 
        @Configuration
-       public Option[] localH2Configuration() {
+       public Option[] localEmbeddedH2LocalTxConfiguration() {
                String localRepo = System.getProperty("maven.repo.local");
                if (localRepo == null) {
                        localRepo = 
System.getProperty("org.ops4j.pax.url.mvn.localRepository");
@@ -187,7 +187,7 @@ public abstract class AbstractTransactio
        }
 
        @Configuration
-       public Option[] serverH2Configuration() {
+       public Option[] localServerH2LocalTxConfiguration() {
                String localRepo = System.getProperty("maven.repo.local");
                if (localRepo == null) {
                        localRepo = 
System.getProperty("org.ops4j.pax.url.mvn.localRepository");
@@ -211,7 +211,7 @@ public abstract class AbstractTransactio
        }
 
        @Configuration
-       public Option[] configAdminDrivenConfiguration() {
+       public Option[] localConfigAdminDrivenH2LocalTxConfiguration() {
                String localRepo = System.getProperty("maven.repo.local");
                if (localRepo == null) {
                        localRepo = 
System.getProperty("org.ops4j.pax.url.mvn.localRepository");
@@ -235,6 +235,79 @@ public abstract class AbstractTransactio
 //                             
,CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
                                );
        }
+       
+       @Configuration
+       public Option[] localEmbeddedH2XATxConfiguration() {
+               String localRepo = System.getProperty("maven.repo.local");
+               if (localRepo == null) {
+                       localRepo = 
System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+               }
+               
+               Option testSpecificOptions = testSpecificOptions();
+               
+               return options(junitBundles(), 
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+                               when(localRepo != null)
+                                               
.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + 
localRepo)),
+                               mavenBundle("org.apache.aries.testsupport", 
"org.apache.aries.testsupport.unit").versionAsInProject(),
+                               xaTxControlService(),
+                               localJdbcResourceProviderWithH2(),
+                               when(testSpecificOptions != 
null).useOptions(testSpecificOptions),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-api").versionAsInProject(),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-service").versionAsInProject()
+                               
+//                             
,CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+               );
+       }
+
+       @Configuration
+       public Option[] localServerH2XATxConfiguration() {
+               String localRepo = System.getProperty("maven.repo.local");
+               if (localRepo == null) {
+                       localRepo = 
System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+               }
+               
+               Option testSpecificOptions = testSpecificOptions();
+               
+               return options(junitBundles(), 
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+                               when(localRepo != null)
+                               
.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + 
localRepo)),
+                               mavenBundle("org.apache.aries.testsupport", 
"org.apache.aries.testsupport.unit").versionAsInProject(),
+                               xaTxControlService(),
+                               localJdbcResourceProviderWithH2(),
+                               
systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
+                               when(testSpecificOptions != 
null).useOptions(testSpecificOptions),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-api").versionAsInProject(),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-service").versionAsInProject()
+                               
+//                             
,CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+                               );
+       }
+
+       @Configuration
+       public Option[] localConfigAdminDrivenH2XATxConfiguration() {
+               String localRepo = System.getProperty("maven.repo.local");
+               if (localRepo == null) {
+                       localRepo = 
System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+               }
+               
+               Option testSpecificOptions = testSpecificOptions();
+               
+               return options(junitBundles(), 
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+                               when(localRepo != null)
+                               
.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + 
localRepo)),
+                               mavenBundle("org.apache.aries.testsupport", 
"org.apache.aries.testsupport.unit").versionAsInProject(),
+                               xaTxControlService(),
+                               localJdbcResourceProviderWithH2(),
+                               
systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
+                               mavenBundle("org.apache.felix", 
"org.apache.felix.configadmin").versionAsInProject(),
+                               
systemProperty(CONFIGURED_PROVIDER_PROPERTY).value("true"),
+                               when(testSpecificOptions != 
null).useOptions(testSpecificOptions),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-api").versionAsInProject(),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-service").versionAsInProject()
+                               
+//                             
,CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+                               );
+       }
 
        private String getRemoteDBPath() {
                String fullResourceName = getClass().getName().replace('.', 
'/') + ".class";
@@ -253,6 +326,12 @@ public abstract class AbstractTransactio
                                mavenBundle("org.apache.aries.tx-control", 
"tx-control-service-local").versionAsInProject());
        }
 
+       public Option xaTxControlService() {
+               return CoreOptions.composite(
+                               mavenBundle("org.apache.felix", 
"org.apache.felix.coordinator").versionAsInProject(),
+                               mavenBundle("org.apache.aries.tx-control", 
"tx-control-service-xa").versionAsInProject());
+       }
+
        public Option localJdbcResourceProviderWithH2() {
                return CoreOptions.composite(
                                mavenBundle("com.h2database", 
"h2").versionAsInProject(),

Added: aries/trunk/tx-control/tx-control-service-common/LICENSE
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-common/LICENSE?rev=1734243&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-service-common/LICENSE (added)
+++ aries/trunk/tx-control/tx-control-service-common/LICENSE Wed Mar  9 
14:38:15 2016
@@ -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/tx-control/tx-control-service-common/NOTICE
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-common/NOTICE?rev=1734243&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-service-common/NOTICE (added)
+++ aries/trunk/tx-control/tx-control-service-common/NOTICE Wed Mar  9 14:38:15 
2016
@@ -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/).
+
+

Copied: aries/trunk/tx-control/tx-control-service-common/pom.xml (from 
r1733320, aries/trunk/tx-control/tx-control-service-local/pom.xml)
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-common/pom.xml?p2=aries/trunk/tx-control/tx-control-service-common/pom.xml&p1=aries/trunk/tx-control/tx-control-service-local/pom.xml&r1=1733320&r2=1734243&rev=1734243&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-service-local/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-service-common/pom.xml Wed Mar  9 
14:38:15 2016
@@ -8,13 +8,14 @@
                <relativePath>../../parent/pom.xml</relativePath>
        </parent>
        <groupId>org.apache.aries.tx-control</groupId>
-       <artifactId>tx-control-service-local</artifactId>
-       <packaging>bundle</packaging>
-       <name>OSGi Transaction Control Service - Local Transactions</name>
+       <artifactId>tx-control-service-common</artifactId>
+       <name>OSGi Transaction Control Service - Common Code</name>
        <version>0.0.1-SNAPSHOT</version>
 
        <description>
-        This bundle contains a Coordinator based OSGi Transaction Control 
Service implementation suitable for local resources.
+        This jar contains a common code for building OSGi Transaction Control 
Service implementations.
+        It is not complete and should not be deployed at runtime, instead it 
should be repackaged
+        inside a complete implementation.
     </description>
 
        <scm>
@@ -29,23 +30,6 @@
         </url>
        </scm>
 
-       <properties>
-               <aries.osgi.activator>
-                  org.apache.aries.tx.control.service.local.impl.Activator
-               </aries.osgi.activator>
-               <aries.osgi.export.pkg>
-                       org.osgi.service.transaction.control
-               </aries.osgi.export.pkg>
-        <aries.osgi.private.pkg>
-            org.apache.aries.tx.control.service.local.*
-        </aries.osgi.private.pkg>
-               <aries.osgi.import.pkg>
-                       
org.osgi.service.transaction.control;version="[0.0.1,0.0.2)",
-                       *
-               </aries.osgi.import.pkg>
-               <lastReleaseVersion>0.0.1-SNAPSHOT</lastReleaseVersion>
-       </properties>
-
        <dependencies>
            <dependency>
                <groupId>org.slf4j</groupId>

Copied: 
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/activator/AbstractActivator.java
 (from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/Activator.java)
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/activator/AbstractActivator.java?p2=aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/activator/AbstractActivator.java&p1=aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/Activator.java&r1=1733320&r2=1734243&rev=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/Activator.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/activator/AbstractActivator.java
 Wed Mar  9 14:38:15 2016
@@ -1,7 +1,6 @@
-package org.apache.aries.tx.control.service.local.impl;
+package org.apache.aries.tx.control.service.common.activator;
 
 import java.util.Dictionary;
-import java.util.Hashtable;
 import java.util.Optional;
 
 import org.osgi.framework.BundleActivator;
@@ -15,9 +14,9 @@ import org.osgi.util.tracker.ServiceTrac
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class Activator implements BundleActivator, 
ServiceTrackerCustomizer<Coordinator, Coordinator> {
+public abstract class AbstractActivator implements BundleActivator, 
ServiceTrackerCustomizer<Coordinator, Coordinator> {
 
-       private static final Logger logger = 
LoggerFactory.getLogger(Activator.class);
+       private static final Logger logger = 
LoggerFactory.getLogger(AbstractActivator.class);
        
        private BundleContext context;
        
@@ -59,18 +58,16 @@ public class Activator implements Bundle
                if(register) {
                        logger.info("Registering a new local-only 
TransactionControl service");
                        ServiceRegistration<TransactionControl> reg = 
context.registerService(
-                                       TransactionControl.class, new 
TransactionControlImpl(c), getProperties());
+                                       TransactionControl.class, 
getTransactionControl(c), getProperties());
                        synchronized (lock) {
                                this.reg = reg;
                        }
                }
        }
 
-       private Dictionary<String, Object> getProperties() {
-               Dictionary<String, Object> props = new Hashtable<>();
-               props.put("osgi.local.enabled", Boolean.TRUE);
-               return props;
-       }
+       protected abstract TransactionControl getTransactionControl(Coordinator 
c);
+
+       protected abstract Dictionary<String, Object> getProperties();
 
        @Override
        public void modifiedService(ServiceReference<Coordinator> reference, 
Coordinator service) {

Copied: 
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionContextImpl.java
 (from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/AbstractTransactionContextImpl.java)
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionContextImpl.java?p2=aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionContextImpl.java&p1=aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/AbstractTransactionContextImpl.java&r1=1733320&r2=1734243&rev=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/AbstractTransactionContextImpl.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionContextImpl.java
 Wed Mar  9 14:38:15 2016
@@ -1,4 +1,4 @@
-package org.apache.aries.tx.control.service.local.impl;
+package org.apache.aries.tx.control.service.common.impl;
 
 import java.util.ArrayList;
 import java.util.HashMap;

Copied: 
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionControlImpl.java
 (from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionControlImpl.java)
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionControlImpl.java?p2=aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionControlImpl.java&p1=aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionControlImpl.java&r1=1733320&r2=1734243&rev=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionControlImpl.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/AbstractTransactionControlImpl.java
 Wed Mar  9 14:38:15 2016
@@ -1,4 +1,4 @@
-package org.apache.aries.tx.control.service.local.impl;
+package org.apache.aries.tx.control.service.common.impl;
 
 import static java.util.Optional.ofNullable;
 import static java.util.stream.Collectors.toList;
@@ -20,7 +20,7 @@ import org.osgi.service.transaction.cont
 import org.osgi.service.transaction.control.TransactionException;
 import org.osgi.service.transaction.control.TransactionRolledBackException;
 
-public class TransactionControlImpl implements TransactionControl {
+public abstract class AbstractTransactionControlImpl implements 
TransactionControl {
 
        private final class TransactionBuilderImpl extends TransactionBuilder {
 
@@ -56,7 +56,7 @@ public class TransactionControlImpl impl
                                        currentCoord = coordinator.begin(
                                                        
"Resource-Local-Transaction.REQUIRED", 30000);
                                        endCoordination = true;
-                                       currentTran = new 
TransactionContextImpl(currentCoord);
+                                       currentTran = 
startTransaction(currentCoord);
                                        endTransaction = true;
                                        
currentCoord.getVariables().put(TransactionContextKey.class,
                                                        currentTran);
@@ -85,8 +85,7 @@ public class TransactionControlImpl impl
                                currentCoord = coordinator.begin(
                                                
"Resource-Local-Transaction.REQUIRES_NEW", 30000);
 
-                               currentTran = new TransactionContextImpl(
-                                               currentCoord);
+                               currentTran = startTransaction(currentCoord);
                                
currentCoord.getVariables().put(TransactionContextKey.class,
                                                currentTran);
                        } catch (RuntimeException re) {
@@ -268,10 +267,12 @@ public class TransactionControlImpl impl
 
        private final Coordinator coordinator;
 
-       public TransactionControlImpl(Coordinator c) {
+       public AbstractTransactionControlImpl(Coordinator c) {
                coordinator = c;
        }
 
+       protected abstract AbstractTransactionContextImpl 
startTransaction(Coordination currentCoord);
+
        @Override
        public TransactionBuilder build() {
                return new TransactionBuilderImpl();

Copied: 
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextImpl.java
 (from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextImpl.java)
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextImpl.java?p2=aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextImpl.java&p1=aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextImpl.java&r1=1733320&r2=1734243&rev=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextImpl.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-service-common/src/main/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextImpl.java
 Wed Mar  9 14:38:15 2016
@@ -1,4 +1,4 @@
-package org.apache.aries.tx.control.service.local.impl;
+package org.apache.aries.tx.control.service.common.impl;
 
 import static 
org.osgi.service.transaction.control.TransactionStatus.NO_TRANSACTION;
 

Copied: 
aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextTest.java
 (from r1733320, 
aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextTest.java)
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextTest.java?p2=aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextTest.java&p1=aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextTest.java&r1=1733320&r2=1734243&rev=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/NoTransactionContextTest.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-service-common/src/test/java/org/apache/aries/tx/control/service/common/impl/NoTransactionContextTest.java
 Wed Mar  9 14:38:15 2016
@@ -1,4 +1,4 @@
-package org.apache.aries.tx.control.service.local.impl;
+package org.apache.aries.tx.control.service.common.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -12,6 +12,8 @@ import java.util.concurrent.atomic.Atomi
 
 import javax.transaction.xa.XAResource;
 
+import 
org.apache.aries.tx.control.service.common.impl.AbstractTransactionContextImpl;
+import 
org.apache.aries.tx.control.service.common.impl.NoTransactionContextImpl;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;

Modified: aries/trunk/tx-control/tx-control-service-local/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-local/pom.xml?rev=1734243&r1=1734242&r2=1734243&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-service-local/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-service-local/pom.xml Wed Mar  9 14:38:15 
2016
@@ -37,6 +37,7 @@
                        org.osgi.service.transaction.control
                </aries.osgi.export.pkg>
         <aries.osgi.private.pkg>
+            org.apache.aries.tx.control.service.common.*,
             org.apache.aries.tx.control.service.local.*
         </aries.osgi.private.pkg>
                <aries.osgi.import.pkg>
@@ -58,6 +59,12 @@
                        <scope>provided</scope>
                </dependency>
                <dependency>
+            <groupId>org.apache.aries.tx-control</groupId>
+            <artifactId>tx-control-service-common</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+               <dependency>
                        <groupId>org.osgi</groupId>
                        <artifactId>org.osgi.service.coordinator</artifactId>
                        <version>1.0.2</version>

Modified: 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/Activator.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/Activator.java?rev=1734243&r1=1734242&r2=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/Activator.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/Activator.java
 Wed Mar  9 14:38:15 2016
@@ -2,111 +2,22 @@ package org.apache.aries.tx.control.serv
 
 import java.util.Dictionary;
 import java.util.Hashtable;
-import java.util.Optional;
 
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
+import org.apache.aries.tx.control.service.common.activator.AbstractActivator;
 import org.osgi.service.coordinator.Coordinator;
 import org.osgi.service.transaction.control.TransactionControl;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-public class Activator implements BundleActivator, 
ServiceTrackerCustomizer<Coordinator, Coordinator> {
+public class Activator extends AbstractActivator {
 
-       private static final Logger logger = 
LoggerFactory.getLogger(Activator.class);
-       
-       private BundleContext context;
-       
-       private ServiceTracker<Coordinator, Coordinator> tracker;
-       
-       private Coordinator inUse;
-       private ServiceRegistration<TransactionControl> reg;
-       
-       private Object lock = new Object();
-       
        @Override
-       public void start(BundleContext context) throws Exception {
-               this.context = context;
-               tracker = new ServiceTracker<>(context, Coordinator.class, 
this);
-               tracker.open();
+       protected TransactionControl getTransactionControl(Coordinator c) {
+               return new TransactionControlImpl(c);
        }
-
-       @Override
-       public void stop(BundleContext context) throws Exception {
-               tracker.close();
-       }
-
+       
        @Override
-       public Coordinator addingService(ServiceReference<Coordinator> 
reference) {
-               Coordinator c = context.getService(reference);
-               checkAndRegister(c);
-               return c;
-       }
-
-       private void checkAndRegister(Coordinator c) {
-               boolean register = false;
-               synchronized (lock) {
-                       if(inUse == null) {
-                               inUse = c;
-                               register = true;
-                       }
-               }
-               
-               if(register) {
-                       logger.info("Registering a new local-only 
TransactionControl service");
-                       ServiceRegistration<TransactionControl> reg = 
context.registerService(
-                                       TransactionControl.class, new 
TransactionControlImpl(c), getProperties());
-                       synchronized (lock) {
-                               this.reg = reg;
-                       }
-               }
-       }
-
-       private Dictionary<String, Object> getProperties() {
+       protected Dictionary<String, Object> getProperties() {
                Dictionary<String, Object> props = new Hashtable<>();
                props.put("osgi.local.enabled", Boolean.TRUE);
                return props;
        }
-
-       @Override
-       public void modifiedService(ServiceReference<Coordinator> reference, 
Coordinator service) {
-       }
-
-       @Override
-       public void removedService(ServiceReference<Coordinator> reference, 
Coordinator service) {
-               ServiceRegistration<TransactionControl> toUnregister = null;
-               synchronized (lock) {
-                       if(inUse == service) {
-                               inUse = null;
-                               toUnregister = reg;
-                               reg = null;
-                       }
-               }
-               
-               if(toUnregister != null) {
-                       try {
-                               toUnregister.unregister();
-                       } catch (IllegalStateException ise) {
-                               logger.debug("An exception occurred when 
unregistering the Transaction Control service", ise);
-                       }
-                       
-                       Optional<?> check = 
tracker.getTracked().values().stream()
-                               .filter(c -> {
-                                       checkAndRegister(c);
-                                       synchronized (lock) {
-                                               return reg != null;
-                                       }
-                               }).findFirst();
-                       
-                       if(!check.isPresent()) {
-                               logger.info("No replacement Coordinator service 
was available. The Transaction Control service will remain unavailable until a 
new Coordinator can be found");
-                       }
-               }
-               context.ungetService(reference);
-       }
-
 }

Modified: 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionContextImpl.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionContextImpl.java?rev=1734243&r1=1734242&r2=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionContextImpl.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionContextImpl.java
 Wed Mar  9 14:38:15 2016
@@ -14,6 +14,7 @@ import java.util.function.Consumer;
 
 import javax.transaction.xa.XAResource;
 
+import 
org.apache.aries.tx.control.service.common.impl.AbstractTransactionContextImpl;
 import org.osgi.service.coordinator.Coordination;
 import org.osgi.service.transaction.control.LocalResource;
 import org.osgi.service.transaction.control.TransactionContext;

Modified: 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionControlImpl.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionControlImpl.java?rev=1734243&r1=1734242&r2=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionControlImpl.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-service-local/src/main/java/org/apache/aries/tx/control/service/local/impl/TransactionControlImpl.java
 Wed Mar  9 14:38:15 2016
@@ -1,351 +1,19 @@
 package org.apache.aries.tx.control.service.local.impl;
 
-import static java.util.Optional.ofNullable;
-import static java.util.stream.Collectors.toList;
-import static 
org.osgi.service.transaction.control.TransactionStatus.NO_TRANSACTION;
-import static 
org.osgi.service.transaction.control.TransactionStatus.ROLLED_BACK;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.Callable;
-
+import 
org.apache.aries.tx.control.service.common.impl.AbstractTransactionContextImpl;
+import 
org.apache.aries.tx.control.service.common.impl.AbstractTransactionControlImpl;
 import org.osgi.service.coordinator.Coordination;
-import org.osgi.service.coordinator.CoordinationException;
 import org.osgi.service.coordinator.Coordinator;
-import org.osgi.service.transaction.control.ScopedWorkException;
-import org.osgi.service.transaction.control.TransactionBuilder;
-import org.osgi.service.transaction.control.TransactionContext;
-import org.osgi.service.transaction.control.TransactionControl;
-import org.osgi.service.transaction.control.TransactionException;
-import org.osgi.service.transaction.control.TransactionRolledBackException;
-
-public class TransactionControlImpl implements TransactionControl {
-
-       private final class TransactionBuilderImpl extends TransactionBuilder {
-
-               private void checkExceptions() {
-                       List<Class<? extends Throwable>> duplicates = 
rollbackFor.stream()
-                                       .filter(noRollbackFor::contains)
-                                       .collect(toList());
-                       if(!duplicates.isEmpty()) {
-                               throw new TransactionException("The transaction 
declares that the Exceptions " + 
-                                               duplicates + " must both 
trigger and not trigger rollback");
-                       }
-               }
-
-               @Override
-               public <T> T required(Callable<T> work)
-                               throws TransactionException, 
TransactionRolledBackException {
-                       checkExceptions();
-                       
-                       Coordination currentCoord = coordinator.peek();
-                       boolean endTransaction = false;
-                       boolean endCoordination = false;
-
-                       AbstractTransactionContextImpl currentTran = ofNullable(
-                                       currentCoord).map(c -> 
(AbstractTransactionContextImpl) c
-                                                       
.getVariables().get(TransactionContextKey.class))
-                                                       .filter(atc -> atc
-                                                                       
.getTransactionStatus() != NO_TRANSACTION)
-                                                       .orElse(null);
-                       try {
-                               if (currentTran == null) {
-                                       // We must create a new coordination to 
scope our new
-                                       // transaction
-                                       currentCoord = coordinator.begin(
-                                                       
"Resource-Local-Transaction.REQUIRED", 30000);
-                                       endCoordination = true;
-                                       currentTran = new 
TransactionContextImpl(currentCoord);
-                                       endTransaction = true;
-                                       
currentCoord.getVariables().put(TransactionContextKey.class,
-                                                       currentTran);
-                               }
-                       } catch (RuntimeException re) {
-                               if(endTransaction) {
-                                       currentTran.finish();
-                               }
-                               if (endCoordination) {
-                                       currentCoord.end();
-                               }
-                               throw re;
-                       }
-
-                       return doWork(work, currentTran, currentCoord, 
endTransaction, endCoordination);
-               }
-
-               @Override
-               public <T> T requiresNew(Callable<T> work)
-                               throws TransactionException, 
TransactionRolledBackException {
-                       checkExceptions();
-                       
-                       Coordination currentCoord = null;
-                       AbstractTransactionContextImpl currentTran;
-                       try {
-                               currentCoord = coordinator.begin(
-                                               
"Resource-Local-Transaction.REQUIRES_NEW", 30000);
-
-                               currentTran = new TransactionContextImpl(
-                                               currentCoord);
-                               
currentCoord.getVariables().put(TransactionContextKey.class,
-                                               currentTran);
-                       } catch (RuntimeException re) {
-                               if (currentCoord != null)
-                                       currentCoord.end();
-                               throw re;
-                       }
-
-                       return doWork(work, currentTran, currentCoord, true, 
true);
-               }
-
-               @Override
-               public <T> T supports(Callable<T> work) throws 
TransactionException {
-                       checkExceptions();
-                       
-                       Coordination currentCoord = coordinator.peek();
-                       boolean endTransaction = false;
-                       boolean endCoordination = false;
-
-                       AbstractTransactionContextImpl currentTran = ofNullable(
-                                       currentCoord).map(c -> 
(AbstractTransactionContextImpl) c
-                                                       
.getVariables().get(TransactionContextKey.class))
-                                                       .orElse(null);
-                       try {
-                               if (currentTran == null) {
-                                       // We must create a new coordination to 
scope our new
-                                       // transaction
-                                       currentCoord = coordinator.begin(
-                                                       
"Resource-Local-Transaction.SUPPORTS", 30000);
-                                       endCoordination = true;
-                                       currentTran = new 
NoTransactionContextImpl(currentCoord);
-                                       endTransaction = true;
-                                       
currentCoord.getVariables().put(TransactionContextKey.class,
-                                                       currentTran);
-                               }
-                       } catch (RuntimeException re) {
-                               if(endTransaction) {
-                                       currentTran.finish();
-                               }
-                               if (endCoordination) {
-                                       currentCoord.end();
-                               }
-                               throw re;
-                       }
-
-                       return doWork(work, currentTran, currentCoord, 
endTransaction, endCoordination);
-               }
 
-               @Override
-               public <T> T notSupported(Callable<T> work)
-                               throws TransactionException {
-                       checkExceptions();
-                       
-                       Coordination currentCoord = coordinator.peek();
-                       boolean endTransaction = false;
-                       boolean endCoordination = false;
-
-                       AbstractTransactionContextImpl currentTran = ofNullable(
-                                       currentCoord).map(c -> 
(AbstractTransactionContextImpl) c
-                                                       
.getVariables().get(TransactionContextKey.class))
-                                                       .filter(atc -> atc
-                                                                       
.getTransactionStatus() == NO_TRANSACTION)
-                                                       .orElse(null);
-                       try {
-                               if (currentTran == null) {
-                                       // We must create a new coordination to 
scope our new
-                                       // transaction
-                                       currentCoord = coordinator.begin(
-                                                       
"Resource-Local-Transaction.NOT_SUPPORTED", 30000);
-                                       endCoordination = true;
-                                       currentTran = new 
NoTransactionContextImpl(currentCoord);
-                                       endTransaction = true;
-                                       
currentCoord.getVariables().put(TransactionContextKey.class,
-                                                       currentTran);
-                               }
-                       } catch (RuntimeException re) {
-                               if(endTransaction) {
-                                       currentTran.finish();
-                               }
-                               if (endCoordination) {
-                                       currentCoord.end();
-                               }
-                               throw re;
-                       }
-                       return doWork(work, currentTran, currentCoord, 
endTransaction, endCoordination);
-               }
-
-               private <R> R doWork(Callable<R> transactionalWork,
-                               AbstractTransactionContextImpl currentTran, 
Coordination currentCoord, 
-                               boolean endTransaction, boolean 
endCoordination) {
-                       R result;
-                       try {
-                               result = transactionalWork.call();
-
-                       } catch (Throwable t) {
-                               //TODO handle noRollbackFor
-                               if(requiresRollback(t)) {
-                                       currentCoord.fail(t);
-                               }
-                               if(endTransaction) {
-                                       try {
-                                               currentTran.finish();
-                                       } catch (Exception e) {
-                                               currentTran.recordFailure(e);
-                                       }
-                               }
-                               if (endCoordination) {
-                                       try {
-                                               currentCoord.end();
-                                       } catch (CoordinationException ce) {
-                                               if(ce.getType() != 
CoordinationException.FAILED) {
-                                                       
currentTran.recordFailure(ce);
-                                               }
-                                       }
-                               }
-                               ScopedWorkException workException = new 
ScopedWorkException("The scoped work threw an exception", t, 
-                                               endCoordination ? null : 
currentTran);
-                               Throwable throwable = 
currentTran.firstUnexpectedException.get();
-                               if(throwable != null) {
-                                       workException.addSuppressed(throwable);
-                               }
-                               
currentTran.subsequentExceptions.stream().forEach(workException::addSuppressed);
-                               
-                               throw workException;
-                       }
-                       
-                       if(endTransaction) {
-                               try {
-                                       currentTran.finish();
-                               } catch (Exception e) {
-                                       currentTran.recordFailure(e);
-                                       currentCoord.fail(e);
-                               }
-                       }
-                       try {
-                               if (endCoordination) {
-                                       currentCoord.end();
-                               }
-                       } catch (CoordinationException ce) {
-                               if(ce.getType() != 
CoordinationException.FAILED) {
-                                       currentTran.recordFailure(ce);
-                               }
-                       }
-                       
-                       Throwable throwable = 
currentTran.firstUnexpectedException.get();
-                       if(throwable != null) {
-                               TransactionException te = 
currentTran.getTransactionStatus() == ROLLED_BACK ?
-                                               new 
TransactionRolledBackException("The transaction rolled back due to a failure", 
throwable) :
-                                               new TransactionException("There 
was an error in the Transaction completion.", throwable);
-                               
-                               
currentTran.subsequentExceptions.stream().forEach(te::addSuppressed);
-                               
-                               throw te;
-                       }
-                       
-                       return result;
-               }
-
-               private boolean requiresRollback(Throwable t) {
-                       return mostSpecificMatch(noRollbackFor, t)
-                               .map(noRollbackType -> 
mostSpecificMatch(rollbackFor, t)
-                                               .map(rollbackType -> 
noRollbackType.isAssignableFrom(rollbackType))
-                                               .orElse(false))
-                               .orElse(true);
-               }
-               
-               private Optional<Class<? extends Throwable>> 
mostSpecificMatch(Collection<Class<? extends Throwable>> types, Throwable t) {
-                       return types.stream()
-                                       .filter(c -> c.isInstance(t))
-                                       .max((c1, c2) -> {
-                                                       if(c1 == c2) return 0;
-                                                       
-                                                       return 
c1.isAssignableFrom(c2) ? 1 : c2.isAssignableFrom(c1) ? -1 : 0;
-                                               });
-               }
-       }
-
-       private static class TransactionContextKey {}
-
-       private final Coordinator coordinator;
+public class TransactionControlImpl extends AbstractTransactionControlImpl {
 
        public TransactionControlImpl(Coordinator c) {
-               coordinator = c;
-       }
-
-       @Override
-       public TransactionBuilder build() {
-               return new TransactionBuilderImpl();
-       }
-
-       @Override
-       public boolean getRollbackOnly() throws IllegalStateException {
-               return getCurrentTranContextChecked().getRollbackOnly();
-       }
-
-       @Override
-       public void setRollbackOnly() throws IllegalStateException {
-               getCurrentTranContextChecked().setRollbackOnly();
-       }
-
-       @Override
-       public <T> T required(Callable<T> work)
-                       throws TransactionException, 
TransactionRolledBackException {
-               return build().required(work);
-       }
-
-       @Override
-       public <T> T requiresNew(Callable<T> work)
-                       throws TransactionException, 
TransactionRolledBackException {
-               return build().requiresNew(work);
-       }
-
-       @Override
-       public <T> T notSupported(Callable<T> work) throws TransactionException 
{
-               return build().notSupported(work);
-       }
-
-       @Override
-       public <T> T supports(Callable<T> work) throws TransactionException {
-               return build().supports(work);
+               super(c);
        }
 
        @Override
-       public boolean activeTransaction() {
-               TransactionContext context = getCurrentContext();
-               return context != null
-                               && context.getTransactionStatus() != 
NO_TRANSACTION;
+       protected AbstractTransactionContextImpl startTransaction(Coordination 
currentCoord) {
+               return new TransactionContextImpl(currentCoord);
        }
-
-       @Override
-       public boolean activeScope() {
-               return getCurrentContext() != null;
-       }
-
-       private TransactionContext getCurrentTranContextChecked() {
-               TransactionContext toUse = getCurrentContext();
-               if (toUse == null) {
-                       throw new IllegalStateException(
-                                       "There is no applicable transaction 
context");
-               }
-               return toUse;
-       }
-
-       @Override
-       public TransactionContext getCurrentContext() {
-               TransactionContext toUse = null;
-
-               Coordination peek = coordinator.peek();
-               if (peek != null) {
-                       toUse = (TransactionContext) peek.getVariables()
-                                       .get(TransactionContextKey.class);
-               }
-               return toUse;
-       }
-
-       @Override
-       public void ignoreException(Throwable t) throws IllegalStateException {
-               // TODO Auto-generated method stub
-
-       }
-
+       
 }

Modified: 
aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/TransactionContextTest.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/TransactionContextTest.java?rev=1734243&r1=1734242&r2=1734243&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/TransactionContextTest.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-service-local/src/test/java/org/apache/aries/tx/control/service/local/impl/TransactionContextTest.java
 Wed Mar  9 14:38:15 2016
@@ -19,6 +19,7 @@ import java.util.concurrent.atomic.Atomi
 
 import javax.transaction.xa.XAResource;
 
+import 
org.apache.aries.tx.control.service.common.impl.AbstractTransactionContextImpl;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -285,9 +286,9 @@ public class TransactionContextTest {
                ctx.registerLocalResource(localResource);
                
                Mockito.doAnswer(i -> {
-                       assertEquals(COMMITTING, ctx.getTransactionStatus());
+                       assertEquals(ROLLING_BACK, ctx.getTransactionStatus());
                        return null;
-               }).when(localResource).commit();
+               }).when(localResource).rollback();
                
                getParticipant().ended(coordination);
                

Added: aries/trunk/tx-control/tx-control-service-xa/LICENSE
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-xa/LICENSE?rev=1734243&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-service-xa/LICENSE (added)
+++ aries/trunk/tx-control/tx-control-service-xa/LICENSE Wed Mar  9 14:38:15 
2016
@@ -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/tx-control/tx-control-service-xa/NOTICE
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-xa/NOTICE?rev=1734243&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-service-xa/NOTICE (added)
+++ aries/trunk/tx-control/tx-control-service-xa/NOTICE Wed Mar  9 14:38:15 2016
@@ -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/).
+
+

Copied: aries/trunk/tx-control/tx-control-service-xa/pom.xml (from r1733320, 
aries/trunk/tx-control/tx-control-service-local/pom.xml)
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-xa/pom.xml?p2=aries/trunk/tx-control/tx-control-service-xa/pom.xml&p1=aries/trunk/tx-control/tx-control-service-local/pom.xml&r1=1733320&r2=1734243&rev=1734243&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-service-local/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-service-xa/pom.xml Wed Mar  9 14:38:15 
2016
@@ -8,13 +8,14 @@
                <relativePath>../../parent/pom.xml</relativePath>
        </parent>
        <groupId>org.apache.aries.tx-control</groupId>
-       <artifactId>tx-control-service-local</artifactId>
+       <artifactId>tx-control-service-xa</artifactId>
        <packaging>bundle</packaging>
-       <name>OSGi Transaction Control Service - Local Transactions</name>
+       <name>OSGi Transaction Control Service - XA Transactions</name>
        <version>0.0.1-SNAPSHOT</version>
 
        <description>
-        This bundle contains a Coordinator based OSGi Transaction Control 
Service implementation suitable for local resources.
+        This bundle contains an OSGi Transaction Control Service 
implementation based on
+        the Geronimo Transaction Manager. It is suitable for use with XA 
resources.
     </description>
 
        <scm>
@@ -31,15 +32,25 @@
 
        <properties>
                <aries.osgi.activator>
-                  org.apache.aries.tx.control.service.local.impl.Activator
+                       org.apache.aries.tx.control.service.xa.impl.Activator
                </aries.osgi.activator>
                <aries.osgi.export.pkg>
                        org.osgi.service.transaction.control
                </aries.osgi.export.pkg>
-        <aries.osgi.private.pkg>
-            org.apache.aries.tx.control.service.local.*
-        </aries.osgi.private.pkg>
+        <!-- 
+            The JTA API package should be private as we don't share any of it, 
but we 
+            Must take javax.transaction.xa from the outside 
+        -->
+               <aries.osgi.private.pkg>
+                       javax.resource.spi,
+                       javax.transaction,
+                       org.apache.aries.tx.control.service.common.*,
+                       org.apache.aries.tx.control.service.xa.*,
+                       org.apache.geronimo.transaction.*
+               </aries.osgi.private.pkg>
+               <!-- No transaction log at the moment -->
                <aries.osgi.import.pkg>
+                       !org.objectweb.howl.*,
                        
org.osgi.service.transaction.control;version="[0.0.1,0.0.2)",
                        *
                </aries.osgi.import.pkg>
@@ -47,10 +58,10 @@
        </properties>
 
        <dependencies>
-           <dependency>
-               <groupId>org.slf4j</groupId>
-               <artifactId>slf4j-api</artifactId>
-           </dependency>
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-api</artifactId>
+               </dependency>
                <dependency>
                        <groupId>org.apache.aries.tx-control</groupId>
                        <artifactId>tx-control-api</artifactId>
@@ -58,6 +69,24 @@
                        <scope>provided</scope>
                </dependency>
                <dependency>
+                       <groupId>org.apache.aries.tx-control</groupId>
+                       <artifactId>tx-control-service-common</artifactId>
+                       <version>0.0.1-SNAPSHOT</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.geronimo.components</groupId>
+                       <artifactId>geronimo-transaction</artifactId>
+                       <version>3.1.3</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.geronimo.specs</groupId>
+                       <artifactId>geronimo-jta_1.1_spec</artifactId>
+                       <version>1.1.1</version>
+                       <scope>provided</scope>
+               </dependency>
+               <dependency>
                        <groupId>org.osgi</groupId>
                        <artifactId>org.osgi.service.coordinator</artifactId>
                        <version>1.0.2</version>
@@ -75,16 +104,16 @@
                        <scope>provided</scope>
                </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>
+                       <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>

Added: 
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/Activator.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/Activator.java?rev=1734243&view=auto
==============================================================================
--- 
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/Activator.java
 (added)
+++ 
aries/trunk/tx-control/tx-control-service-xa/src/main/java/org/apache/aries/tx/control/service/xa/impl/Activator.java
 Wed Mar  9 14:38:15 2016
@@ -0,0 +1,37 @@
+package org.apache.aries.tx.control.service.xa.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import javax.transaction.xa.XAException;
+
+import org.apache.aries.tx.control.service.common.activator.AbstractActivator;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.osgi.service.coordinator.Coordinator;
+import org.osgi.service.transaction.control.TransactionControl;
+
+public class Activator extends AbstractActivator {
+
+       private final GeronimoTransactionManager transactionManager;
+       
+       {
+               try {
+                       transactionManager = new GeronimoTransactionManager();
+               } catch (XAException e) {
+                       throw new RuntimeException("Unable to create the 
Transaction Manager");
+               }
+       }
+       
+       @Override
+       protected TransactionControl getTransactionControl(Coordinator c) {
+               return new TransactionControlImpl(transactionManager, c);
+       }
+       
+       @Override
+       protected Dictionary<String, Object> getProperties() {
+               Dictionary<String, Object> props = new Hashtable<>();
+               props.put("osgi.local.enabled", Boolean.TRUE);
+               props.put("osgi.xa.enabled", Boolean.TRUE);
+               return props;
+       }
+}


Reply via email to