cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: CAY-2165 Explicit "contribution" API for easier expansion of DI collections and map
Date Mon, 02 Jan 2017 13:55:01 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 36e70f4e7 -> 50d4fbf50


CAY-2165 Explicit "contribution" API for easier expansion of DI collections and map

* adding a method to flip external TX property


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/50d4fbf5
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/50d4fbf5
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/50d4fbf5

Branch: refs/heads/master
Commit: 50d4fbf50047e87a99b67a3ac4d9e577e9522a87
Parents: 36e70f4
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Mon Jan 2 16:54:43 2017 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Mon Jan 2 16:54:43 2017 +0300

----------------------------------------------------------------------
 .../cayenne/configuration/server/ServerModule.java     | 13 ++++++++++++-
 .../java/org/apache/cayenne/tx/BaseTransaction.java    |  1 +
 .../org/apache/cayenne/tx/ExternalTransaction.java     |  1 +
 3 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/50d4fbf5/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
index 1e32efc..e8314c0 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModule.java
@@ -97,6 +97,17 @@ public class ServerModule implements Module {
     protected String[] configurationLocations;
 
     /**
+     * Sets transaction management to either external or internal transactions. Default is
internally-managed transactions.
+     *
+     * @param binder  DI binder passed to the module during injector startup.
+     * @param useExternal whether external (true) or internal (false) transaction management
should be used.
+     * @since 4.0
+     */
+    public static void useExternalTransactions(Binder binder, boolean useExternal) {
+        contributeProperties(binder).put(Constants.SERVER_EXTERNAL_TX_PROPERTY, String.valueOf(useExternal));
+    }
+
+    /**
      * Provides access to a DI collection builder for String locations that allows downstream
modules to
      * "contribute" their own Cayenne project locations.
      *
@@ -207,7 +218,7 @@ public class ServerModule implements Module {
         this.configurationLocations = new String[configurationLocations.length + 1];
         this.configurationLocations[0] = firstConfigLocation;
 
-        if(configurationLocations.length > 0) {
+        if (configurationLocations.length > 0) {
             System.arraycopy(configurationLocations, 0, this.configurationLocations, 1, configurationLocations.length);
         }
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/50d4fbf5/cayenne-server/src/main/java/org/apache/cayenne/tx/BaseTransaction.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/tx/BaseTransaction.java b/cayenne-server/src/main/java/org/apache/cayenne/tx/BaseTransaction.java
index 6281b01..9b7ac0f 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/tx/BaseTransaction.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/tx/BaseTransaction.java
@@ -223,6 +223,7 @@ public abstract class BaseTransaction implements Transaction {
         }
 
         if (connections == null) {
+            // transaction is single-threaded, so using a non-concurrent map...
             connections = new HashMap<>();
         }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/50d4fbf5/cayenne-server/src/main/java/org/apache/cayenne/tx/ExternalTransaction.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/tx/ExternalTransaction.java b/cayenne-server/src/main/java/org/apache/cayenne/tx/ExternalTransaction.java
index 168a2bc..8fd4316 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/tx/ExternalTransaction.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/tx/ExternalTransaction.java
@@ -39,6 +39,7 @@ public class ExternalTransaction extends BaseTransaction {
         logger.logCommitTransaction("no commit - transaction controlled externally.");
     }
 
+    @Override
     protected void processRollback() {
         logger.logRollbackTransaction("no rollback - transaction controlled externally.");
     }


Mime
View raw message