]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/WriteStateBase.java
Cluster loading problem fix made by Antti
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / WriteStateBase.java
index 303e42cfc989e58da286c3f8d8dc5521258fc4b1..db6dac1db5409e1e3b8b2968d8dc2f8a1b1c546b 100644 (file)
@@ -1,83 +1,83 @@
-package fi.vtt.simantics.procore.internal;\r
-\r
-import java.util.concurrent.Semaphore;\r
-\r
-import org.simantics.db.common.utils.Logger;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.procedure.Procedure;\r
-import org.simantics.db.request.WriteTraits;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- *\r
- * @param <T> result value type\r
- */\r
-public class WriteStateBase<T> {\r
-\r
-    final protected WriteTraits request;\r
-    final protected Semaphore notify;\r
-    final protected Procedure<T> procedure;\r
-\r
-    protected T result;\r
-    protected Throwable exception;\r
-\r
-    public WriteStateBase(WriteTraits request, Semaphore notify, Procedure<T> procedure) {\r
-        assert(request != null);\r
-\r
-        this.request = request;\r
-        this.notify = notify;\r
-        this.procedure = procedure;\r
-    }\r
-\r
-    public WriteTraits getRequest() {\r
-        return request;\r
-    }\r
-\r
-    @SuppressWarnings("unchecked")\r
-    public void setResult(Object result) {\r
-        this.result = (T) result;\r
-    }\r
-\r
-    public void except(Throwable throwable) {\r
-        this.exception = throwable;\r
-    }\r
-\r
-//    public void cancel(CancelTransactionException e) {\r
-//        this.exception = e;\r
-//    }\r
-//\r
-//    public boolean isCanceled() {\r
-//        return exception instanceof CancelTransactionException;\r
-//    }\r
-\r
-    public boolean isExcepted() {\r
-        return exception != null;\r
-    }\r
-\r
-    public void finish() {\r
-\r
-        if(procedure != null) {\r
-\r
-            try {\r
-                // Callback is client code, we have to be prepared for it to throw unexpected exceptions.\r
-                // All we can do here is to log those, can't really pass them anywhere.\r
-                if (procedure != null) {\r
-                    if(isExcepted()) {\r
-                        if(exception instanceof DatabaseException) procedure.exception(exception);\r
-                        else procedure.exception(new DatabaseException(exception));\r
-                    }\r
-                    else procedure.execute(result);\r
-                }\r
-            } catch (Throwable t) {\r
-                Logger.defaultLogError("Write request callback caused an unexpected error, see exception.", t);\r
-                if (SessionImplSocket.DEBUG)\r
-                    t.printStackTrace();\r
-            }\r
-\r
-        }\r
-\r
-        if(notify != null) notify.release();\r
-\r
-    }\r
-\r
-}\r
+package fi.vtt.simantics.procore.internal;
+
+import java.util.concurrent.Semaphore;
+
+import org.simantics.db.common.utils.Logger;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.procedure.Procedure;
+import org.simantics.db.request.WriteTraits;
+
+/**
+ * @author Tuukka Lehtonen
+ *
+ * @param <T> result value type
+ */
+public class WriteStateBase<T> {
+
+    final protected WriteTraits request;
+    final protected Semaphore notify;
+    final protected Procedure<T> procedure;
+
+    protected T result;
+    protected Throwable exception;
+
+    public WriteStateBase(WriteTraits request, Semaphore notify, Procedure<T> procedure) {
+        assert(request != null);
+
+        this.request = request;
+        this.notify = notify;
+        this.procedure = procedure;
+    }
+
+    public WriteTraits getRequest() {
+        return request;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void setResult(Object result) {
+        this.result = (T) result;
+    }
+
+    public void except(Throwable throwable) {
+        this.exception = throwable;
+    }
+
+//    public void cancel(CancelTransactionException e) {
+//        this.exception = e;
+//    }
+//
+//    public boolean isCanceled() {
+//        return exception instanceof CancelTransactionException;
+//    }
+
+    public boolean isExcepted() {
+        return exception != null;
+    }
+
+    public void finish() {
+
+        if(procedure != null) {
+
+            try {
+                // Callback is client code, we have to be prepared for it to throw unexpected exceptions.
+                // All we can do here is to log those, can't really pass them anywhere.
+                if (procedure != null) {
+                    if(isExcepted()) {
+                        if(exception instanceof DatabaseException) procedure.exception(exception);
+                        else procedure.exception(new DatabaseException(exception));
+                    }
+                    else procedure.execute(result);
+                }
+            } catch (Throwable t) {
+                Logger.defaultLogError("Write request callback caused an unexpected error, see exception.", t);
+                if (SessionImplSocket.DEBUG)
+                    t.printStackTrace();
+            }
+
+        }
+
+        if(notify != null) notify.release();
+
+    }
+
+}