- @Override
- final public <T> T syncRequest(final AsyncRead<T> request,
- final AsyncProcedure<T> procedure) throws DatabaseException {
-
- assert (request != null);
-
- // System.out.println("syncRequest " + request + " syncParent=" +
- // syncParent);
-
- ListenerBase listener = getListenerBase(procedure);
-
- if (parent != null || listener != null || ((request.getFlags() & RequestFlags.SCHEDULE) > 0)) {
-
- Object syncParent = request;
-
-// final ReadGraphImpl newGraph = newSync();
-
- final ResultCallWrappedSingleQueryProcedure4<T> wrapper = new ResultCallWrappedSingleQueryProcedure4<T>(
- procedure, request);
-
- processor.query(this, request, parent, wrapper, listener);
-
-// newGraph.waitAsync(syncParent);
-
- Throwable e = wrapper.getException();
- if (e != null) {
- // The request was async - produce meaningful stack trace by
- // wrapping
- if (e instanceof DatabaseException)
- throw (DatabaseException) e;
- else
- throw new DatabaseException(e);
- }
-
- return wrapper.getResult();
-
- } else {
-
- // System.out.println("direct call " + request );
-
- // Do not set the sync state.parent for external threads
- Object syncParent = request;
-
-// final ReadGraphImpl newGraph = newSync();
-
- final ResultCallWrappedSingleQueryProcedure4<T> wrapper = new ResultCallWrappedSingleQueryProcedure4<T>(
- procedure, request);
-
- try {
-
- processor.tryQuery(this, request, wrapper);
-
- } catch (Throwable t) {
-
- wrapper.exception(this, t);
-
- }
-
- Throwable e = wrapper.getException();
- if (e != null) {
- // The request was async - produce meaningful stack trace by
- // wrapping
- if (e instanceof DatabaseException)
- throw (DatabaseException) e;
- else
- throw new DatabaseException(e);
- }
-
- return wrapper.getResult();
-
- }
-
- }
-
- final private <T> void syncRequest(final AsyncRead<T> request, final AsyncReadProcedure<T> procedure) throws DatabaseException {
-
- assert (request != null);
-
- // System.out.println("syncRequest " + request + " syncParent=" +
- // syncParent);
-
- ListenerBase listener = getListenerBase(procedure);
-
- if (parent != null || listener != null || ((request.getFlags() & RequestFlags.SCHEDULE) > 0)) {
-
-// final ReadGraphImpl newGraph = newSync();
-
- final ResultCallWrappedSingleQueryProcedure4<T> wrapper = new ResultCallWrappedSingleQueryProcedure4<T>(
- procedure, request);
-
- processor.query(this, request, parent, wrapper, listener);
-
- } else {
-
- try {
-
-// final ReadGraphImpl newGraph = newSync();
- processor.tryQuery(this, request, procedure);
-// newGraph.waitAsync(null);
- waitAsyncProcedure(procedure);
-
- } catch (Throwable t) {
- if(Development.DEVELOPMENT) {
- if(Development.<Boolean>getProperty(DevelopmentKeys.WRITEGRAPH_EXCEPTION_STACKTRACES, Bindings.BOOLEAN)) {
- t.printStackTrace();
- }
- }
- procedure.exception(this, t);
- waitAsyncProcedure(procedure);
- }
-
- }
-
- }