]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db/src/org/simantics/db/procedure/AsyncMultiProcedure.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / procedure / AsyncMultiProcedure.java
diff --git a/bundles/org.simantics.db/src/org/simantics/db/procedure/AsyncMultiProcedure.java b/bundles/org.simantics.db/src/org/simantics/db/procedure/AsyncMultiProcedure.java
new file mode 100644 (file)
index 0000000..b07e4ee
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.procedure;\r
+\r
+import org.simantics.db.AsyncReadGraph;\r
+\r
+/**\r
+ * @author Antti Villberg\r
+ * \r
+ * First execute is called k times. After this finished or exception is called exactly once.\r
+ *\r
+ * @param <Result> the result object type accepted by the procedure\r
+ */\r
+public interface AsyncMultiProcedure<Result> {\r
+\r
+    /**\r
+     * Invoked once for each separate result of the request with potentially\r
+     * multiple results. It shall be guaranteed that all <code>execute</code>\r
+     * invocations have been completed when either\r
+     * {@link #finished(AsyncReadGraph)} or\r
+     * {@link #exception(AsyncReadGraph, Throwable)} are called and that no\r
+     * <code>execute</code> invocations will follow afterwards.\r
+     * \r
+     * @param graph asynchronous graph access\r
+     * @param result a single result of the multiresult procedure\r
+     */\r
+    void execute(AsyncReadGraph graph, Result result);\r
+\r
+    /**\r
+     * Invoked after all {@link #execute(AsyncReadGraph, Object)} calls have\r
+     * been finished successfully. This method will not be invoked if case of\r
+     * errors in {@link #execute(AsyncReadGraph, Object)} or the performed\r
+     * request that provides the results to this procedure.\r
+     * \r
+     * @param graph asynchronous graph access\r
+     */\r
+    void finished(AsyncReadGraph graph);\r
+\r
+    /**\r
+     * If an error occurs in the processing of the database request that\r
+     * produces the results for this procedure.\r
+     * \r
+     * @param graph asynchronous graph access\r
+     * @param throwable the exception that occurred\r
+     */\r
+    void exception(AsyncReadGraph graph, Throwable throwable);\r
+\r
+}\r