cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skolbac...@apache.org
Subject cayenne git commit: CAY-2035 | Autobind items added to collections (Cayenne DI)
Date Tue, 03 Nov 2015 10:19:52 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 9ddd0c92b -> bdd8d903a


CAY-2035 | Autobind items added to collections (Cayenne DI)


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

Branch: refs/heads/master
Commit: bdd8d903ac88cf50890cdfeb126fdd636b98563c
Parents: 9ddd0c9
Author: Savva Kolbachev <s.kolbachev@gmail.com>
Authored: Tue Nov 3 13:19:12 2015 +0300
Committer: Savva Kolbachev <s.kolbachev@gmail.com>
Committed: Tue Nov 3 13:19:12 2015 +0300

----------------------------------------------------------------------
 .../cayenne/di/spi/DefaultListBuilder.java       | 17 +++++++++++++++++
 .../di/spi/DefaultInjectorInjectionTest.java     | 19 +++++++++++++++++++
 .../configuration/server/ServerModule.java       | 19 -------------------
 .../server/DataDomainProviderTest.java           | 15 ---------------
 .../cayenne/tools/configuration/ToolsModule.java | 19 -------------------
 docs/doc/src/main/resources/RELEASE-NOTES.txt    |  1 +
 6 files changed, 37 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/bdd8d903/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultListBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultListBuilder.java b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultListBuilder.java
index 853bb5e..eb9654f 100644
--- a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultListBuilder.java
+++ b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultListBuilder.java
@@ -52,6 +52,23 @@ class DefaultListBuilder<T> implements ListBuilder<T> {
             throws DIRuntimeException {
 
         Key<?> key = Key.get(interfaceType);
+        Binding<?> binding = injector.getBinding(key);
+
+        if (binding == null) {
+            return addWithBinding(interfaceType);
+        }
+
+        getListProvider().add(key, binding.getScoped());
+        return this;
+    }
+
+    <K extends T> ListBuilder<T> addWithBinding(Class<K> interfaceType)
{
+        Key<K> key = Key.get(interfaceType);
+
+        Provider<K> provider0 = new ConstructorInjectingProvider<>(interfaceType,
injector);
+        Provider<K> provider1 = new FieldInjectingProvider<>(provider0, injector);
+        injector.putBinding(key, provider1);
+
         getListProvider().add(key, injector.getProvider(key));
         return this;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bdd8d903/cayenne-di/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorInjectionTest.java
----------------------------------------------------------------------
diff --git a/cayenne-di/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorInjectionTest.java
b/cayenne-di/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorInjectionTest.java
index 31b9cd3..3d81ea3 100644
--- a/cayenne-di/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorInjectionTest.java
+++ b/cayenne-di/src/test/java/org/apache/cayenne/di/spi/DefaultInjectorInjectionTest.java
@@ -387,6 +387,25 @@ public class DefaultInjectorInjectionTest {
     }
 
     @Test
+    public void testListInjection_addTypeWithBinding() {
+        Module module = new Module() {
+
+            public void configure(Binder binder) {
+                binder.bind(MockInterface1.class).to(
+                        MockImplementation1_ListConfiguration.class);
+
+                binder.bindList("xyz").add(MockImplementation5.class).add("yvalue");
+            }
+        };
+
+        DefaultInjector injector = new DefaultInjector(module);
+
+        MockInterface1 service = injector.getInstance(MockInterface1.class);
+        assertNotNull(service);
+        assertEquals(";xyz;yvalue", service.getName());
+    }
+
+    @Test
     public void testListInjection_empty() {
         Module module = new Module() {
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bdd8d903/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 c761b4c..ef3f1ab 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
@@ -143,31 +143,12 @@ public class ServerModule implements Module {
 		// Users can
 		// add their own to install custom adapters automatically
 
-		// a bit ugly - need to bind all sniffers explicitly first before
-		// placing then in a list
-		binder.bind(FirebirdSniffer.class).to(FirebirdSniffer.class);
-		binder.bind(OpenBaseSniffer.class).to(OpenBaseSniffer.class);
-		binder.bind(FrontBaseSniffer.class).to(FrontBaseSniffer.class);
-		binder.bind(IngresSniffer.class).to(IngresSniffer.class);
-		binder.bind(SQLiteSniffer.class).to(SQLiteSniffer.class);
-		binder.bind(DB2Sniffer.class).to(DB2Sniffer.class);
-		binder.bind(H2Sniffer.class).to(H2Sniffer.class);
-		binder.bind(HSQLDBSniffer.class).to(HSQLDBSniffer.class);
-		binder.bind(SybaseSniffer.class).to(SybaseSniffer.class);
-		binder.bind(DerbySniffer.class).to(DerbySniffer.class);
-		binder.bind(SQLServerSniffer.class).to(SQLServerSniffer.class);
-		binder.bind(OracleSniffer.class).to(OracleSniffer.class);
-		binder.bind(PostgresSniffer.class).to(PostgresSniffer.class);
-		binder.bind(MySQLSniffer.class).to(MySQLSniffer.class);
-
 		binder.bindList(Constants.SERVER_ADAPTER_DETECTORS_LIST).add(FirebirdSniffer.class).add(OpenBaseSniffer.class)
 				.add(FrontBaseSniffer.class).add(IngresSniffer.class).add(SQLiteSniffer.class).add(DB2Sniffer.class)
 				.add(H2Sniffer.class).add(HSQLDBSniffer.class).add(SybaseSniffer.class).add(DerbySniffer.class)
 				.add(SQLServerSniffer.class).add(OracleSniffer.class).add(PostgresSniffer.class)
 				.add(MySQLSniffer.class);
 
-        binder.bind(TransactionFilter.class).to(TransactionFilter.class);
-
 		// configure a filter chain with only one TransactionFilter as default
 		binder.bindList(Constants.SERVER_DOMAIN_FILTERS_LIST)
                 .add(TransactionFilter.class);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bdd8d903/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java
b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java
index cc771b3..b0ba2b0 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/configuration/server/DataDomainProviderTest.java
@@ -142,21 +142,6 @@ public class DataDomainProviderTest {
 
 				binder.bindMap(Constants.PROPERTIES_MAP);
 
-				binder.bind(FirebirdSniffer.class).to(FirebirdSniffer.class);
-				binder.bind(OpenBaseSniffer.class).to(OpenBaseSniffer.class);
-				binder.bind(FrontBaseSniffer.class).to(FrontBaseSniffer.class);
-				binder.bind(IngresSniffer.class).to(IngresSniffer.class);
-				binder.bind(SQLiteSniffer.class).to(SQLiteSniffer.class);
-				binder.bind(DB2Sniffer.class).to(DB2Sniffer.class);
-				binder.bind(H2Sniffer.class).to(H2Sniffer.class);
-				binder.bind(HSQLDBSniffer.class).to(HSQLDBSniffer.class);
-				binder.bind(SybaseSniffer.class).to(SybaseSniffer.class);
-				binder.bind(DerbySniffer.class).to(DerbySniffer.class);
-				binder.bind(SQLServerSniffer.class).to(SQLServerSniffer.class);
-				binder.bind(OracleSniffer.class).to(OracleSniffer.class);
-				binder.bind(PostgresSniffer.class).to(PostgresSniffer.class);
-				binder.bind(MySQLSniffer.class).to(MySQLSniffer.class);
-
 				binder.bindList(Constants.SERVER_ADAPTER_DETECTORS_LIST).add(FirebirdSniffer.class)
 						.add(OpenBaseSniffer.class).add(FrontBaseSniffer.class).add(IngresSniffer.class)
 						.add(SQLiteSniffer.class).add(DB2Sniffer.class).add(H2Sniffer.class).add(HSQLDBSniffer.class)

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bdd8d903/cayenne-tools/src/main/java/org/apache/cayenne/tools/configuration/ToolsModule.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/configuration/ToolsModule.java
b/cayenne-tools/src/main/java/org/apache/cayenne/tools/configuration/ToolsModule.java
index 91078d7..b800ea2 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/configuration/ToolsModule.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/configuration/ToolsModule.java
@@ -92,25 +92,6 @@ public class ToolsModule implements Module {
         binder.bind(BatchTranslatorFactory.class).to(DefaultBatchTranslatorFactory.class);
         binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
 
-        // TODO: this is cloned from ServerModule... figure out how to reuse
-        // this list
-        // a bit ugly - need to bind all sniffers explicitly first before
-        // placing then in a list
-        binder.bind(FirebirdSniffer.class).to(FirebirdSniffer.class);
-        binder.bind(OpenBaseSniffer.class).to(OpenBaseSniffer.class);
-        binder.bind(FrontBaseSniffer.class).to(FrontBaseSniffer.class);
-        binder.bind(IngresSniffer.class).to(IngresSniffer.class);
-        binder.bind(SQLiteSniffer.class).to(SQLiteSniffer.class);
-        binder.bind(DB2Sniffer.class).to(DB2Sniffer.class);
-        binder.bind(H2Sniffer.class).to(H2Sniffer.class);
-        binder.bind(HSQLDBSniffer.class).to(HSQLDBSniffer.class);
-        binder.bind(SybaseSniffer.class).to(SybaseSniffer.class);
-        binder.bind(DerbySniffer.class).to(DerbySniffer.class);
-        binder.bind(SQLServerSniffer.class).to(SQLServerSniffer.class);
-        binder.bind(OracleSniffer.class).to(OracleSniffer.class);
-        binder.bind(PostgresSniffer.class).to(PostgresSniffer.class);
-        binder.bind(MySQLSniffer.class).to(MySQLSniffer.class);
-
         binder.bindList(Constants.SERVER_ADAPTER_DETECTORS_LIST).add(FirebirdSniffer.class).add(OpenBaseSniffer.class)
                 .add(FrontBaseSniffer.class).add(IngresSniffer.class).add(SQLiteSniffer.class).add(DB2Sniffer.class)
                 .add(H2Sniffer.class).add(HSQLDBSniffer.class).add(SybaseSniffer.class).add(DerbySniffer.class)

http://git-wip-us.apache.org/repos/asf/cayenne/blob/bdd8d903/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index b0fba2e..e4b2d5e 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -35,6 +35,7 @@ CAY-2027 Support for Expression outer join syntax in EJBQL
 CAY-2028 Wrap DataChannelFilter calls in the main transaction
 CAY-2029 Allow out-of-order insertion into DI lists
 CAY-2030 Capturing a stream of commit changes
+CAY-2035 Autobind items added to collections (Cayenne DI)
 
 Bug Fixes:
 


Mime
View raw message