/*******************************************************************************
* Copyright (c) 2007, 2010 Association for Decentralized Information Management
* in Industry THTH ry.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* VTT Technical Research Centre of Finland - initial API and implementation
*******************************************************************************/
package org.simantics.db;
import java.util.function.Consumer;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.procedure.AsyncListener;
import org.simantics.db.procedure.AsyncMultiListener;
import org.simantics.db.procedure.AsyncMultiProcedure;
import org.simantics.db.procedure.AsyncProcedure;
import org.simantics.db.procedure.Listener;
import org.simantics.db.procedure.MultiListener;
import org.simantics.db.procedure.MultiProcedure;
import org.simantics.db.procedure.Procedure;
import org.simantics.db.procedure.SyncListener;
import org.simantics.db.procedure.SyncMultiListener;
import org.simantics.db.procedure.SyncMultiProcedure;
import org.simantics.db.procedure.SyncProcedure;
import org.simantics.db.request.AsyncMultiRead;
import org.simantics.db.request.AsyncRead;
import org.simantics.db.request.DelayedWrite;
import org.simantics.db.request.DelayedWriteResult;
import org.simantics.db.request.ExternalRead;
import org.simantics.db.request.MultiRead;
import org.simantics.db.request.Read;
import org.simantics.db.request.Write;
import org.simantics.db.request.WriteOnly;
import org.simantics.db.request.WriteOnlyResult;
import org.simantics.db.request.WriteResult;
/**
*
* For initiating requests in asynchronous manner. The possible requests are
*
* - {@link Read} for computing a single result synchronously
*
- {@link AsyncRead} for computing a single result asynchronously
*
- {@link MultiRead} for computing a collection of results synchronously
*
- {@link AsyncMultiRead} for computing a collection of results
* asynchronously
*
- {@link Write} for reading and writing synchronously
*
- {@link WriteOnly} for writing synchronously
*
*
* The standard AsyncRequestProcessors are
*
* - {@link AsyncReadGraph} for performing requests during other requests
*
- {@link Session} for initiating a transactions for performing requests
*
- {@link MergingGraphRequestProcessor} for merging several requests in a
* single transaction
*
*
* Database services (see e.g. {@link Session}) are available from implemented
* {@link ServiceLocator}. For a synchronous counterpart with the same
* functionality as AsyncRequestProcessor see {@link RequestProcessor}
*
* @version 0.7
* @author Antti Villberg
* @see Read
* @see AsyncRead
* @see MultiRead
* @see AsyncMultiRead
* @see Write
* @see WriteOnly
* @see AsyncReadGraph
* @see Session
* @see MergingGraphRequestProcessor
* @see RequestProcessor
*/
public interface AsyncRequestProcessorSpecific extends ServiceLocator {
/**
* Provides access to a set of standard resources defined in Layer0. The
* existence of {@link Builtins} is guaranteed at {@link Session} creation
* time hence the method does not throw. It is also assumed that the
* identify of the standard resources cannot change during sessions. To work
* this requires that Builtins.class has been registered with this
* ServiceLocator. Therefore this is merely a shorthand for
* ServiceLocator.getService(Builtins.class)
.
*
* @deprecated in favor of org.simantics.layer0.Layer0. Will be removed in Simantics 1.2
*
* @return the Builtins
instance associated with this session.
*/
// @Deprecated
// Builtins getBuiltins();
/**
* Asynchronously determines the result of the given {@link Read} and
* registers the given {@link Read} as a dependency of the ongoing request
* if any. This is usually invoked for the side-effects of the given
* {@link Read} but can also be used for e.g. dependency registering or
* cache priming. All exceptions from request processing will be lost.
*
* @param request an instance of {@link Read}.
*/
void asyncRequest(Read request);
/**
* Asynchronously registers the given {@link AsyncListener} (as identified
* by {@link Object#equals(Object)}) to track changes in the result
* determined from the given {@link Read}. Registers the given {@link Read}
* as a dependency of the ongoing request if any. Exceptions due to the
* determination of the result of the given {@link Read} will be transferred
* to the given {@link AsyncListener}.
*
* @param request an instance of {@link Read}.
* @param procedure an instance of {@link AsyncListener}.
*/
void asyncRequest(Read request, AsyncListener procedure);
/**
* Asynchronously registers the given {@link SyncListener} (as identified by
* {@link Object#equals(Object)}) to track changes in the result determined
* from the given {@link Read}. Registers the given {@link Read} as a
* dependency of the ongoing request if any. Exceptions due to the
* determination of the result of the given {@link Read} will be transferred
* to the given {@link SyncListener}
*
* @param request an instance of {@link Read}.
* @param procedure an instance of {@link SyncListener}.
*/
void asyncRequest(Read request, SyncListener procedure);
/**
* Asynchronously registers the given {@link Listener} (as identified by
* {@link Object#equals(Object)}) to track changes in the result determined
* from the given {@link Read}. Registers the given {@link Read} as a
* dependency of the ongoing request if any. Exceptions due to the
* determination of the result of the given {@link Read} will be transferred
* to the given {@link Listener}
*
* @param request an instance of {@link Read}.
* @param procedure an instance of {@link Listener}.
*/
void asyncRequest(Read request, Listener procedure);
/**
* Asynchronously supplies the result determined from the given {@link Read}
* to the given {@link AsyncProcedure}. Registers the given {@link Read} as
* a dependency of the ongoing request if any. Exceptions due to the
* determination of the result of the given {@link Read} will be transferred
* to the given {@link AsyncProcedure}
*
* @param request an instance of {@link Read}.
* @param procedure an instance of {@link AsyncProcedure}.
*/
void asyncRequest(Read request, AsyncProcedure procedure);
/**
* Asynchronously supplies the result determined from the given {@link Read}
* to the given {@link SyncProcedure}. Registers the given {@link Read} as a
* dependency of the ongoing request if any. Exceptions due to the
* determination of the result of the given {@link Read} will be transferred
* to the given {@link SyncProcedure}
*
* @param request an instance of {@link Read}.
* @param procedure an instance of {@link SyncProcedure}.
*/
void asyncRequest(Read request, SyncProcedure procedure);
/**
* Asynchronously supplies the result determined from the given {@link Read}
* to the given {@link Procedure}. Registers the given {@link Read} as a
* dependency of the ongoing request if any. Exceptions due to the
* determination of the result of the given {@link Read} will be transferred
* to the given {@link Procedure}
*
* @param request an instance of {@link Read}.
* @param procedure an instance of {@link Procedure}.
*/
void asyncRequest(Read request, Procedure procedure);
/**
* Asynchronously determines the result of the given {@link AsyncRead} and
* registers the given {@link AsyncRead} as a dependency of the ongoing
* request if any. This is usually invoked for the side-effects of the given
* {@link AsyncRead} but can also be used for e.g. dependency registering or
* cache priming. All exceptions from request processing will be lost.
*
* @param request an instance of {@link AsyncRead}.
*/
void asyncRequest(AsyncRead request);
/**
* Asynchronously registers the given {@link AsyncListener} (as identified
* by {@link Object#equals(Object)}) to track changes in the result
* determined from the given {@link AsyncRead}. Registers the given
* {@link AsyncRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link AsyncRead} will be transferred to the given {@link AsyncListener}.
*
* @param request an instance of {@link AsyncRead}.
* @param procedure an instance of {@link AsyncListener}.
*/
void asyncRequest(AsyncRead request, AsyncListener procedure);
/**
* Asynchronously registers the given {@link SyncListener} (as identified by
* {@link Object#equals(Object)}) to track changes in the result determined
* from the given {@link AsyncRead}. Registers the given {@link AsyncRead}
* as a dependency of the ongoing request if any. Exceptions due to the
* determination of the result of the given {@link AsyncRead} will be
* transferred to the given {@link SyncListener}
*
* @param request an instance of {@link AsyncRead}.
* @param procedure an instance of {@link SyncListener}.
*/
void asyncRequest(AsyncRead request, SyncListener procedure);
/**
* Asynchronously registers the given {@link Listener} (as identified by
* {@link Object#equals(Object)}) to track changes in the result determined
* from the given {@link AsyncRead}. Registers the given {@link AsyncRead}
* as a dependency of the ongoing request if any. Exceptions due to the
* determination of the result of the given {@link AsyncRead} will be
* transferred to the given {@link Listener}
*
* @param request an instance of {@link AsyncRead}.
* @param procedure an instance of {@link Listener}.
*/
void asyncRequest(AsyncRead request, Listener procedure);
/**
* Asynchronously supplies the result determined from the given
* {@link AsyncRead} to the given {@link AsyncProcedure}. Registers the
* given {@link AsyncRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link AsyncRead} will be transferred to the given {@link AsyncProcedure}
*
* @param request an instance of {@link AsyncRead}.
* @param procedure an instance of {@link AsyncProcedure}.
*/
void asyncRequest(AsyncRead request, AsyncProcedure procedure);
/**
* Asynchronously supplies the result determined from the given
* {@link AsyncRead} to the given {@link SyncProcedure}. Registers the given
* {@link AsyncRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link AsyncRead} will be transferred to the given {@link SyncProcedure}
*
* @param request an instance of {@link AsyncRead}.
* @param procedure an instance of {@link SyncProcedure}.
*/
void asyncRequest(AsyncRead request, SyncProcedure procedure);
/**
* Asynchronously supplies the result determined from the given
* {@link AsyncRead} to the given {@link Procedure}. Registers the given
* {@link AsyncRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link AsyncRead} will be transferred to the given {@link Procedure}
*
* @param request an instance of {@link AsyncRead}.
* @param procedure an instance of {@link Procedure}.
*/
void asyncRequest(AsyncRead request, Procedure procedure);
/**
* Asynchronously determines the result of the given {@link MultiRead} and
* registers the given {@link MultiRead} as a dependency of the ongoing
* request if any. This is usually invoked for the side-effects of the given
* {@link MultiRead} but can also be used for e.g. dependency registering or
* cache priming. All exceptions from request processing will be lost.
*
* @param request an instance of {@link MultiRead}.
*/
void asyncRequest(MultiRead request);
/**
* Asynchronously registers the given {@link AsyncMultiListener} (as
* identified by {@link Object#equals(Object)}) to track changes in the
* result determined from the given {@link MultiRead}. Registers the given
* {@link MultiRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link MultiRead} will be transferred to the given
* {@link AsyncMultiListener}.
*
* @param request an instance of {@link MultiRead}.
* @param procedure an instance of {@link AsyncMultiListener}.
*/
// void asyncRequest(MultiRead request, AsyncMultiListener procedure);
/**
* Asynchronously registers the given {@link SyncMultiListener} (as
* identified by {@link Object#equals(Object)}) to track changes in the
* result determined from the given {@link MultiRead}. Registers the given
* {@link MultiRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link MultiRead} will be transferred to the given
* {@link SyncMultiListener}
*
* @param request an instance of {@link MultiRead}.
* @param procedure an instance of {@link SyncMultiListener}.
*/
void asyncRequest(MultiRead request, SyncMultiListener procedure);
/**
* Asynchronously registers the given {@link MultiListener} (as identified
* by {@link Object#equals(Object)}) to track changes in the result
* determined from the given {@link MultiRead}. Registers the given
* {@link MultiRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link MultiRead} will be transferred to the given {@link MultiListener}
*
* @param request an instance of {@link MultiRead}.
* @param procedure an instance of {@link MultiListener}.
*/
void asyncRequest(MultiRead request, MultiListener procedure);
/**
* Asynchronously supplies the result determined from the given
* {@link MultiRead} to the given {@link AsyncMultiProcedure}. Registers the
* given {@link MultiRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link MultiRead} will be transferred to the given
* {@link AsyncMultiProcedure}
*
* @param request an instance of {@link MultiRead}.
* @param procedure an instance of {@link AsyncMultiProcedure}.
*/
// void asyncRequest(MultiRead request, AsyncMultiProcedure procedure);
/**
* Asynchronously supplies the result determined from the given
* {@link MultiRead} to the given {@link SyncMultiProcedure}. Registers the
* given {@link MultiRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link MultiRead} will be transferred to the given
* {@link SyncMultiProcedure}
*
* @param request an instance of {@link MultiRead}.
* @param procedure an instance of {@link SyncMultiProcedure}.
*/
void asyncRequest(MultiRead request, SyncMultiProcedure procedure);
/**
* Asynchronously supplies the result determined from the given
* {@link MultiRead} to the given {@link MultiProcedure}. Registers the
* given {@link MultiRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link MultiRead} will be transferred to the given {@link MultiProcedure}
*
* @param request an instance of {@link MultiRead}.
* @param procedure an instance of {@link MultiProcedure}.
*/
void asyncRequest(MultiRead request, MultiProcedure procedure);
/**
* Asynchronously determines the result of the given {@link AsyncMultiRead}
* and registers the given {@link AsyncMultiRead} as a dependency of the
* ongoing request if any. This is usually invoked for the side-effects of
* the given {@link AsyncMultiRead} but can also be used for e.g. dependency
* registering or cache priming. All exceptions from request processing will
* be lost.
*
* @param request an instance of {@link AsyncMultiRead}.
*/
void asyncRequest(AsyncMultiRead request);
/**
* Asynchronously registers the given {@link AsyncMultiListener} (as
* identified by {@link Object#equals(Object)}) to track changes in the
* result determined from the given {@link AsyncMultiRead}. Registers the
* given {@link AsyncMultiRead} as a dependency of the ongoing request if
* any. Exceptions due to the determination of the result of the given
* {@link AsyncMultiRead} will be transferred to the given
* {@link AsyncMultiListener}.
*
* @param request an instance of {@link AsyncMultiRead}.
* @param procedure an instance of {@link AsyncMultiListener}.
*/
void asyncRequest(AsyncMultiRead request, AsyncMultiListener procedure);
/**
* Asynchronously registers the given {@link SyncMultiListener} (as
* identified by {@link Object#equals(Object)}) to track changes in the
* result determined from the given {@link AsyncMultiRead}. Registers the
* given {@link AsyncMultiRead} as a dependency of the ongoing request if
* any. Exceptions due to the determination of the result of the given
* {@link AsyncMultiRead} will be transferred to the given
* {@link SyncMultiListener}
*
* @param request an instance of {@link AsyncMultiRead}.
* @param procedure an instance of {@link SyncMultiListener}.
*/
void asyncRequest(AsyncMultiRead request, SyncMultiListener procedure);
/**
* Asynchronously registers the given {@link MultiListener} (as identified
* by {@link Object#equals(Object)}) to track changes in the result
* determined from the given {@link AsyncMultiRead}. Registers the given
* {@link AsyncMultiRead} as a dependency of the ongoing request if any.
* Exceptions due to the determination of the result of the given
* {@link AsyncMultiRead} will be transferred to the given
* {@link MultiListener}
*
* @param request an instance of {@link AsyncMultiRead}.
* @param procedure an instance of {@link MultiListener}.
*/
void asyncRequest(AsyncMultiRead request, MultiListener procedure);
/**
* Asynchronously supplies the result determined from the given
* {@link AsyncMultiRead} to the given {@link AsyncMultiProcedure}.
* Registers the given {@link AsyncMultiRead} as a dependency of the ongoing
* request if any. Exceptions due to the determination of the result of the
* given {@link AsyncMultiRead} will be transferred to the given
* {@link AsyncMultiProcedure}
*
* @param request an instance of {@link AsyncMultiRead}.
* @param procedure an instance of {@link AsyncMultiProcedure}.
*/
void asyncRequest(AsyncMultiRead request, AsyncMultiProcedure procedure);
/**
* Asynchronously supplies the result determined from the given
* {@link AsyncMultiRead} to the given {@link SyncMultiProcedure}. Registers
* the given {@link AsyncMultiRead} as a dependency of the ongoing request
* if any. Exceptions due to the determination of the result of the given
* {@link AsyncMultiRead} will be transferred to the given
* {@link SyncMultiProcedure}
*
* @param request an instance of {@link AsyncMultiRead}.
* @param procedure an instance of {@link SyncMultiProcedure}.
*/
void asyncRequest(AsyncMultiRead request, SyncMultiProcedure procedure);
/**
* Asynchronously supplies the result determined from the given
* {@link AsyncMultiRead} to the given {@link MultiProcedure}. Registers the
* given {@link AsyncMultiRead} as a dependency of the ongoing request if
* any. Exceptions due to the determination of the result of the given
* {@link AsyncMultiRead} will be transferred to the given
* {@link MultiProcedure}
*
* @param request an instance of {@link AsyncMultiRead}.
* @param procedure an instance of {@link MultiProcedure}.
*/
void asyncRequest(AsyncMultiRead request, MultiProcedure procedure);
/**
* Asynchronously determines the result of the given {@link AsyncMultiRead}
* and registers the given {@link AsyncMultiRead} as a dependency of the
* ongoing request if any. This is usually invoked for the side-effects of
* the given {@link AsyncMultiRead} but can also be used for e.g. dependency
* registering or cache priming. All exceptions from request processing will
* be lost.
*
* @param request an instance of {@link AsyncMultiRead}.
*/
void asyncRequest(ExternalRead request);
void asyncRequest(ExternalRead request, Listener procedure);
void asyncRequest(ExternalRead request, Procedure procedure);
}