cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johnth...@apache.org
Subject [3/4] cayenne git commit: Enhance CayenneFilter to allow setting a custom DataDomain name in web.xml
Date Wed, 02 May 2018 15:19:50 GMT
Enhance CayenneFilter to allow setting a custom DataDomain name in web.xml


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

Branch: refs/heads/master
Commit: 15b7f696be1a0d70273674bbba56ae069f638b1a
Parents: cac0527
Author: John Huss <johnthuss@apache.org>
Authored: Wed May 2 10:01:39 2018 -0500
Committer: John Huss <johnthuss@gmail.com>
Committed: Wed May 2 10:16:04 2018 -0500

----------------------------------------------------------------------
 .../cayenne/configuration/web/CayenneFilter.java    |  4 +++-
 .../cayenne/configuration/web/WebConfiguration.java | 16 ++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/15b7f696/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
----------------------------------------------------------------------
diff --git a/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
b/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
index 2f158c5..11958b8 100644
--- a/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
+++ b/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/CayenneFilter.java
@@ -76,7 +76,9 @@ public class CayenneFilter implements Filter {
         Collection<Module> modules = configAdapter.createModules();
         modules.addAll(getAdditionalModules());
 
-        ServerRuntime runtime = ServerRuntime.builder()
+        String dataDomainName = configAdapter.getDataDomainName();
+        
+        ServerRuntime runtime = ServerRuntime.builder(dataDomainName)
                 .addConfigs(configurationLocations)
                 .addModules(modules).build();
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/15b7f696/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/WebConfiguration.java
----------------------------------------------------------------------
diff --git a/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/WebConfiguration.java
b/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/WebConfiguration.java
index 6874e55..a65d913 100644
--- a/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/WebConfiguration.java
+++ b/cayenne-web/src/main/java/org/apache/cayenne/configuration/web/WebConfiguration.java
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.cayenne.configuration.web;
 
+import org.apache.cayenne.configuration.server.PropertyDataSourceFactory;
+import org.apache.cayenne.configuration.server.ServerRuntimeBuilder;
 import org.apache.cayenne.di.Module;
 import org.apache.cayenne.util.Util;
 
@@ -45,6 +47,7 @@ public class WebConfiguration {
 
     static final String CONFIGURATION_LOCATION_PARAMETER = "configuration-location";
     static final String EXTRA_MODULES_PARAMETER = "extra-modules";
+    static final String DATA_DOMAIN_NAME_PARAMETER = "data-domain-name";
 
     private FilterConfig configuration;
 
@@ -100,6 +103,19 @@ public class WebConfiguration {
     }
 
     /**
+     * If you are using multiple configuration files (cayenne-*.xml) this allows you
+     * to specify a name for the data domain other than the default name "cayenne" 
+     * (see {@value ServerRuntimeBuilder}).
+     * A specific data domain name is useful if you are setting database connection info

+     * using properties via {@link PropertyDataSourceFactory}.
+     * @return
+     */
+    public String getDataDomainName() {
+        String name = configuration.getInitParameter(DATA_DOMAIN_NAME_PARAMETER);
+        return name;
+    }
+    
+    /**
      * Creates and returns a collection of modules made of provided standard modules and
      * extra custom modules specified via an optional "extra-modules" init parameter. The
      * value of the parameter is expected to be a comma or space-separated list of class


Mime
View raw message