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 put to Map (Cayenne DI);
Date Thu, 29 Sep 2016 21:57:22 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master c093be34b -> 7296d1fef


CAY-2035 | Autobind items put to Map (Cayenne DI);


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

Branch: refs/heads/master
Commit: 7296d1fefd67cdfd77087d2777404cad4885cf60
Parents: c093be3
Author: Savva Kolbachev <s.kolbachev@gmail.com>
Authored: Fri Sep 30 00:54:47 2016 +0300
Committer: Savva Kolbachev <s.kolbachev@gmail.com>
Committed: Fri Sep 30 00:54:47 2016 +0300

----------------------------------------------------------------------
 .../cayenne/dbsync/CayenneDbSyncModule.java     | 14 ----------
 .../cayenne/di/spi/DefaultMapBuilder.java       | 28 +++++++++++++++-----
 2 files changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/7296d1fe/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/CayenneDbSyncModule.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/CayenneDbSyncModule.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/CayenneDbSyncModule.java
index 4fa43b2..cbdcd0e 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/CayenneDbSyncModule.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/CayenneDbSyncModule.java
@@ -45,20 +45,6 @@ public class CayenneDbSyncModule implements Module {
     @Override
     public void configure(Binder binder) {
 
-        // TODO: explicit binding before inserting into a map will be uneeded soon
-        binder.bind(DB2MergerTokenFactory.class).to(DB2MergerTokenFactory.class);
-        binder.bind(DerbyMergerTokenFactory.class).to(DerbyMergerTokenFactory.class);
-        binder.bind(FirebirdMergerTokenFactory.class).to(FirebirdMergerTokenFactory.class);
-        binder.bind(H2MergerTokenFactory.class).to(H2MergerTokenFactory.class);
-        binder.bind(HSQLMergerTokenFactory.class).to(HSQLMergerTokenFactory.class);
-        binder.bind(IngresMergerTokenFactory.class).to(IngresMergerTokenFactory.class);
-        binder.bind(MySQLMergerTokenFactory.class).to(MySQLMergerTokenFactory.class);
-        binder.bind(OpenBaseMergerTokenFactory.class).to(OpenBaseMergerTokenFactory.class);
-        binder.bind(OracleMergerTokenFactory.class).to(OracleMergerTokenFactory.class);
-        binder.bind(PostgresMergerTokenFactory.class).to(PostgresMergerTokenFactory.class);
-        binder.bind(SQLServerMergerTokenFactory.class).to(SQLServerMergerTokenFactory.class);
-        binder.bind(SybaseMergerTokenFactory.class).to(SybaseMergerTokenFactory.class);
-
         // default and per adapter merger factories...
         binder.bind(MergerTokenFactory.class).to(DefaultMergerTokenFactory.class);
         binder.bindMap(MERGER_FACTORIES_MAP)

http://git-wip-us.apache.org/repos/asf/cayenne/blob/7296d1fe/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultMapBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultMapBuilder.java b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultMapBuilder.java
index c5ba93c..9461c97 100644
--- a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultMapBuilder.java
+++ b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultMapBuilder.java
@@ -18,15 +18,11 @@
  ****************************************************************/
 package org.apache.cayenne.di.spi;
 
+import org.apache.cayenne.di.*;
+
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.apache.cayenne.di.DIRuntimeException;
-import org.apache.cayenne.di.Key;
-import org.apache.cayenne.di.MapBuilder;
-import org.apache.cayenne.di.Provider;
-import org.apache.cayenne.di.Scope;
-
 /**
  * @since 3.1
  */
@@ -48,8 +44,26 @@ class DefaultMapBuilder<T> implements MapBuilder<T> {
     public MapBuilder<T> put(String key, Class<? extends T> interfaceType)
             throws DIRuntimeException {
 
+        Key<?> bindingKey = Key.get(interfaceType);
+        Binding<?> binding = injector.getBinding(bindingKey);
+
+        if (binding == null) {
+            return putWithBinding(key, interfaceType);
+        }
+
         // TODO: andrus 11/15/2009 - report overriding the key??
-        getMapProvider().put(key, injector.getProvider(interfaceType));
+        getMapProvider().put(key, binding.getScoped());
+        return this;
+    }
+
+    <K extends T> MapBuilder<T> putWithBinding(String key, Class<K> interfaceType)
{
+        Key<K> bindingKey = Key.get(interfaceType);
+
+        Provider<K> provider0 = new ConstructorInjectingProvider<>(interfaceType,
injector);
+        Provider<K> provider1 = new FieldInjectingProvider<>(provider0, injector);
+        injector.putBinding(bindingKey, provider1);
+
+        getMapProvider().put(key, injector.getProvider(bindingKey));
         return this;
     }
 


Mime
View raw message