]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db/src/org/simantics/db/procedure/AsyncContextMultiProcedure.java
875ee37abe6dab1cb37e4a6e0568e2c883630bd1
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / procedure / AsyncContextMultiProcedure.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.procedure;
13
14 import org.simantics.db.AsyncReadGraph;
15
16 /**
17  * @author Antti Villberg
18  * 
19  * First execute is called k times. After this finished or exception is called exactly once.
20  *
21  * @param <Result> the result object type accepted by the procedure
22  */
23 public interface AsyncContextMultiProcedure<Context, Result> {
24
25     /**
26      * Invoked once for each separate result of the request with potentially
27      * multiple results. It shall be guaranteed that all <code>execute</code>
28      * invocations have been completed when either
29      * {@link #finished(AsyncReadGraph)} or
30      * {@link #exception(AsyncReadGraph, Throwable)} are called and that no
31      * <code>execute</code> invocations will follow afterwards.
32      * 
33      * @param graph asynchronous graph access
34      * @param result a single result of the multiresult procedure
35      */
36     void execute(AsyncReadGraph graph, Context context, Result result);
37
38     /**
39      * Invoked after all {@link #execute(AsyncReadGraph, Object)} calls have
40      * been finished successfully. This method will not be invoked if case of
41      * errors in {@link #execute(AsyncReadGraph, Object)} or the performed
42      * request that provides the results to this procedure.
43      * 
44      * @param graph asynchronous graph access
45      */
46     void finished(AsyncReadGraph graph);
47
48     /**
49      * If an error occurs in the processing of the database request that
50      * produces the results for this procedure.
51      * 
52      * @param graph asynchronous graph access
53      * @param throwable the exception that occurred
54      */
55     void exception(AsyncReadGraph graph, Throwable throwable);
56
57 }