--- /dev/null
+package org.simantics.db.common.procedure.single;\r
+\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.AsyncProcedure;\r
+\r
+final public class SyncReadProcedure<T> implements AsyncProcedure<T> {\r
+\r
+ private Throwable exception = null;\r
+ public T result = null;\r
+ \r
+ @Override\r
+ public synchronized void execute(AsyncReadGraph graph, T t) {\r
+ result = t;\r
+ }\r
+\r
+ @Override\r
+ public void exception(AsyncReadGraph graph, Throwable t) {\r
+ exception = t;\r
+ }\r
+ \r
+ public void checkAndThrow() throws DatabaseException {\r
+ if(exception != null) {\r
+ if (exception instanceof DatabaseException)\r
+ throw (DatabaseException) exception;\r
+ else\r
+ throw new DatabaseException(\r
+ "Unexpected exception in ReadGraph.syncRequest(AsyncRead)",\r
+ exception);\r
+ }\r
+ }\r
+ \r
+}\r
+\r