cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [09/10] cayenne git commit: CAY-2166 Auto-loading of Cayenne modules
Date Sun, 11 Dec 2016 18:00:03 GMT
CAY-2166 Auto-loading of Cayenne modules

* back to overrides as collection instead of Class[]


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

Branch: refs/heads/master
Commit: 302ca65c6cd31f00033517e9ddfae127c7bd0578
Parents: 374aab3
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Sun Dec 11 17:05:33 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Sun Dec 11 20:50:15 2016 +0300

----------------------------------------------------------------------
 cayenne-crypto/pom.xml                          |  2 +-
 .../cayenne/crypto/CryptoModuleBuilder.java     |  5 +--
 .../cayenne/crypto/CryptoModuleProvider.java    | 47 ++++++++++++++++++++
 .../apache/cayenne/di/spi/ModuleProvider.java   |  4 +-
 .../apache/cayenne/di/spi/ModuleLoaderTest.java | 21 +++++----
 .../cayenne/java8/Java8ModuleProvider.java      |  7 ++-
 .../apache/cayenne/joda/JodaModuleProvider.java |  7 ++-
 .../server/ServerModuleProvider.java            |  7 ++-
 8 files changed, 80 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/302ca65c/cayenne-crypto/pom.xml
----------------------------------------------------------------------
diff --git a/cayenne-crypto/pom.xml b/cayenne-crypto/pom.xml
index c1156ec..ea4e759 100644
--- a/cayenne-crypto/pom.xml
+++ b/cayenne-crypto/pom.xml
@@ -68,7 +68,7 @@
 	</dependencies>
 	<build>
 		<plugins>
-			<!-- This ensures LICESNE and NOTICE inclusion in all jars -->
+			<!-- This ensures LICENSE and NOTICE inclusion in all jars -->
             <plugin>
                 <artifactId>maven-remote-resources-plugin</artifactId>
                 <executions>

http://git-wip-us.apache.org/repos/asf/cayenne/blob/302ca65c/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/CryptoModuleBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/CryptoModuleBuilder.java
b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/CryptoModuleBuilder.java
index 63adfe8..62a8af2 100644
--- a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/CryptoModuleBuilder.java
+++ b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/CryptoModuleBuilder.java
@@ -37,10 +37,7 @@ import java.util.Map;
 import java.util.Objects;
 
 /**
- * A builder of a Cayenne DI module that will contain all extension to Cayenne
- * runtime needed to enable encryption of certain data columns. Builder allows
- * to specify custom ciphers, as well as a strategy for discovering which
- * columns are encrypted.
+ * A builder that allows to customize {@link CryptoModule} module.
  *
  * @since 4.0
  */

http://git-wip-us.apache.org/repos/asf/cayenne/blob/302ca65c/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/CryptoModuleProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/CryptoModuleProvider.java
b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/CryptoModuleProvider.java
new file mode 100644
index 0000000..c65b4df
--- /dev/null
+++ b/cayenne-crypto/src/main/java/org/apache/cayenne/crypto/CryptoModuleProvider.java
@@ -0,0 +1,47 @@
+/*
+ *    Licensed to the Apache Software Foundation (ASF) under one
+ *    or more contributor license agreements.  See the NOTICE file
+ *    distributed with this work for additional information
+ *    regarding copyright ownership.  The ASF licenses this file
+ *    to you under the Apache License, Version 2.0 (the
+ *    "License"); you may not use this file except in compliance
+ *    with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing,
+ *    software distributed under the License is distributed on an
+ *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *    KIND, either express or implied.  See the License for the
+ *    specific language governing permissions and limitations
+ *    under the License.
+ */
+package org.apache.cayenne.crypto;
+
+import org.apache.cayenne.di.Module;
+import org.apache.cayenne.di.spi.ModuleProvider;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @since 4.0
+ */
+public class CryptoModuleProvider implements ModuleProvider {
+
+    @Override
+    public Module module() {
+        return new CryptoModule();
+    }
+
+    @Override
+    public Class<? extends Module> moduleType() {
+        return CryptoModule.class;
+    }
+
+    @Override
+    public Collection<Class<? extends Module>> overrides() {
+        // we don't override anything, we only decorate ServerModule services...
+        return Collections.emptyList();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/302ca65c/cayenne-di/src/main/java/org/apache/cayenne/di/spi/ModuleProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/ModuleProvider.java b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/ModuleProvider.java
index e96322e..679b593 100644
--- a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/ModuleProvider.java
+++ b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/ModuleProvider.java
@@ -20,6 +20,8 @@ package org.apache.cayenne.di.spi;
 
 import org.apache.cayenne.di.Module;
 
+import java.util.Collection;
+
 /**
  * Provider of modules used by module auto-loading mechanism to identify and load modules.
  *
@@ -37,5 +39,5 @@ public interface ModuleProvider {
      *
      * @return a collection of module types this module overrides.
      */
-    Class<? extends Module>[] overrides();
+    Collection<Class<? extends Module>> overrides();
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/302ca65c/cayenne-di/src/test/java/org/apache/cayenne/di/spi/ModuleLoaderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-di/src/test/java/org/apache/cayenne/di/spi/ModuleLoaderTest.java b/cayenne-di/src/test/java/org/apache/cayenne/di/spi/ModuleLoaderTest.java
index 3456b5b..9443524 100644
--- a/cayenne-di/src/test/java/org/apache/cayenne/di/spi/ModuleLoaderTest.java
+++ b/cayenne-di/src/test/java/org/apache/cayenne/di/spi/ModuleLoaderTest.java
@@ -24,6 +24,8 @@ import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.di.Module;
 import org.junit.Test;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 import static org.junit.Assert.assertEquals;
@@ -90,9 +92,11 @@ public class ModuleLoaderTest {
             return Module1.class;
         }
 
+
         @Override
-        public Class<? extends Module>[] overrides() {
-            return new Class[]{Module2.class};
+        public Collection<Class<? extends Module>> overrides() {
+            Collection c = Collections.singletonList(Module2.class);
+            return c;
         }
     }
 
@@ -109,8 +113,8 @@ public class ModuleLoaderTest {
         }
 
         @Override
-        public Class<? extends Module>[] overrides() {
-            return new Class[0];
+        public Collection<Class<? extends Module>> overrides() {
+            return Collections.emptyList();
         }
     }
 
@@ -127,8 +131,8 @@ public class ModuleLoaderTest {
         }
 
         @Override
-        public Class<? extends Module>[] overrides() {
-            return new Class[0];
+        public Collection<Class<? extends Module>> overrides() {
+            return Collections.emptyList();
         }
     }
 
@@ -145,8 +149,9 @@ public class ModuleLoaderTest {
         }
 
         @Override
-        public Class<? extends Module>[] overrides() {
-            return new Class[]{Module3.class};
+        public Collection<Class<? extends Module>> overrides() {
+            Collection c = Collections.singletonList(Module3.class);
+            return c;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/302ca65c/cayenne-java8/src/main/java/org/apache/cayenne/java8/Java8ModuleProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-java8/src/main/java/org/apache/cayenne/java8/Java8ModuleProvider.java
b/cayenne-java8/src/main/java/org/apache/cayenne/java8/Java8ModuleProvider.java
index 243dc73..f8fe1b6 100644
--- a/cayenne-java8/src/main/java/org/apache/cayenne/java8/Java8ModuleProvider.java
+++ b/cayenne-java8/src/main/java/org/apache/cayenne/java8/Java8ModuleProvider.java
@@ -21,6 +21,9 @@ package org.apache.cayenne.java8;
 import org.apache.cayenne.di.Module;
 import org.apache.cayenne.di.spi.ModuleProvider;
 
+import java.util.Collection;
+import java.util.Collections;
+
 /**
  * @since 4.0
  */
@@ -37,7 +40,7 @@ public class Java8ModuleProvider implements ModuleProvider {
     }
 
     @Override
-    public Class<? extends Module>[] overrides() {
-        return new Class[0];
+    public Collection<Class<? extends Module>> overrides() {
+        return Collections.emptyList();
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/302ca65c/cayenne-joda/src/main/java/org/apache/cayenne/joda/JodaModuleProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-joda/src/main/java/org/apache/cayenne/joda/JodaModuleProvider.java b/cayenne-joda/src/main/java/org/apache/cayenne/joda/JodaModuleProvider.java
index 9c9e204..d390937 100644
--- a/cayenne-joda/src/main/java/org/apache/cayenne/joda/JodaModuleProvider.java
+++ b/cayenne-joda/src/main/java/org/apache/cayenne/joda/JodaModuleProvider.java
@@ -21,6 +21,9 @@ package org.apache.cayenne.joda;
 import org.apache.cayenne.di.Module;
 import org.apache.cayenne.di.spi.ModuleProvider;
 
+import java.util.Collection;
+import java.util.Collections;
+
 /**
  * @since 4.0
  */
@@ -37,7 +40,7 @@ public class JodaModuleProvider implements ModuleProvider {
     }
 
     @Override
-    public Class<? extends Module>[] overrides() {
-        return new Class[0];
+    public Collection<Class<? extends Module>> overrides() {
+        return Collections.emptyList();
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/302ca65c/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModuleProvider.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModuleProvider.java
b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModuleProvider.java
index 55d681d..e8e126d 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModuleProvider.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/configuration/server/ServerModuleProvider.java
@@ -21,6 +21,9 @@ package org.apache.cayenne.configuration.server;
 import org.apache.cayenne.di.Module;
 import org.apache.cayenne.di.spi.ModuleProvider;
 
+import java.util.Collection;
+import java.util.Collections;
+
 /**
  * ServerModule auto-loading facility.
  *
@@ -39,7 +42,7 @@ public class ServerModuleProvider implements ModuleProvider {
     }
 
     @Override
-    public Class<? extends Module>[] overrides() {
-        return new Class[0];
+    public Collection<Class<? extends Module>> overrides() {
+        return Collections.emptyList();
     }
 }


Mime
View raw message