]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/AdaptionService2.java
Still working for multiple readers
[simantics/platform.git] / bundles / org.simantics.db.services / src / org / simantics / db / services / adaption / AdaptionService2.java
index 47a14ddbcbccc7424bec9fe1ea059c588dffc24d..7cc87e30b155869c4219b47ac045404cd9361b1d 100644 (file)
@@ -20,6 +20,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.adaption.Adapter;
 import org.simantics.db.adaption.AdaptionService;
+import org.simantics.db.common.procedure.BlockingAsyncProcedure;
 import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
 import org.simantics.db.common.procedure.single.SyncReadProcedure;
 import org.simantics.db.common.request.BinaryRead;
@@ -583,11 +584,15 @@ public class AdaptionService2 implements AdaptionService {
     public <T, C> T adapt(ReadGraph g, Resource r, C context, Class<C> contextClass, Class<T> targetClass, boolean possible) throws DatabaseException {
 
        Adapter<T,C> adapter = getAdapter(g, r, context, contextClass, targetClass, possible);
+       if(adapter == null) return null;
        
-               SyncReadProcedure<T> procedure = new SyncReadProcedure<T>();
-       adapter.adapt(g, r, context, procedure);
-               procedure.checkAndThrow();
-               return procedure.result;
+       BlockingAsyncProcedure<T> ap = new BlockingAsyncProcedure<T>(null, adapter);
+       
+//             SyncReadProcedure<T> procedure = new SyncReadProcedure<T>();
+       adapter.adapt(g, r, context, ap);
+       return ap.get();
+//             procedure.checkAndThrow();
+//             return procedure.result;
        
     }