]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.services/src/org/simantics/db/services/adaption/reflection/ReflectionAdapter2.java
Playground for Antti.
[simantics/platform.git] / bundles / org.simantics.db.services / src / org / simantics / db / services / adaption / reflection / ReflectionAdapter2.java
index 187fc52199a390f37b68b3a48a940d20faa4d359..870b17e78e6132439e450b27ef42053bf03d99f0 100644 (file)
@@ -18,9 +18,9 @@ import java.util.Arrays;
 import org.simantics.db.AsyncReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.adaption.Adapter;
-import org.simantics.db.common.request.AsyncReadRequest;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.procedure.AsyncProcedure;
+import org.simantics.db.request.AsyncRead;
 
 public class ReflectionAdapter2<T> implements Adapter<T, Resource> {
 
@@ -78,35 +78,36 @@ public class ReflectionAdapter2<T> implements Adapter<T, Resource> {
                
        } else {
        
-            g.asyncRequest(new AsyncReadRequest() {
-    
+            g.asyncRequest(new AsyncRead() {
+                
                 @Override
-                public void run(AsyncReadGraph graph) {
-                       
+                public void perform(AsyncReadGraph graph, AsyncProcedure p) {
+                    
                     Object[] args = new Object[parameters.length];
                     try {
-                       for(int i=0;i<parameters.length;++i)
-                               args[i] = parameters[i].adapt(graph, r);
-                       procedure.execute(graph, constructor.newInstance(args));
-                               } catch (IllegalArgumentException e) {
-                                   procedure.exception(g, e);
-                                       e.printStackTrace();
-                               } catch (InstantiationException e) {
-                        procedure.exception(g, e);
-                                       e.printStackTrace();
-                               } catch (IllegalAccessException e) {
-                        procedure.exception(g, e);
-                                       e.printStackTrace();
-                               } catch (InvocationTargetException e) {
-                        procedure.exception(g, e.getCause());
-                                       e.getCause().printStackTrace();
-                               } catch (DatabaseException e) {
-                        procedure.exception(g, e);
-                                       e.printStackTrace();
-                               } catch (Throwable t) {
-                                   procedure.exception(g, t);
-                                   t.printStackTrace();
-                               }
+                        for(int i=0;i<parameters.length;++i)
+                            args[i] = parameters[i].adapt(graph, r);
+                        p.execute(graph, constructor.newInstance(args));
+                    } catch (IllegalArgumentException e) {
+                        p.exception(g, e);
+                        e.printStackTrace();
+                    } catch (InstantiationException e) {
+                        p.exception(g, e);
+                        e.printStackTrace();
+                    } catch (IllegalAccessException e) {
+                        p.exception(g, e);
+                        e.printStackTrace();
+                    } catch (InvocationTargetException e) {
+                        p.exception(g, e.getCause());
+                        e.getCause().printStackTrace();
+                    } catch (DatabaseException e) {
+                        p.exception(g, e);
+                        e.printStackTrace();
+                    } catch (Throwable t) {
+                        p.exception(g, t);
+                        t.printStackTrace();
+                    }
+                    
                 }
                 
                 @Override
@@ -114,7 +115,7 @@ public class ReflectionAdapter2<T> implements Adapter<T, Resource> {
                        return "ReflectionAdapter$1" + constructor + "$" + Arrays.toString(parameters);
                 }
                 
-            });
+            }, procedure);
         
        }