- }
-
- }
-
- @Override
- public String toString() {
- if(request == null) return "DISCARDED";
- else return request.toString() + " - " + statusOrException;
- }
-
- public Object get(ReadGraphImpl graph, QueryProcessor processor, Object procedure) throws DatabaseException {
- if(procedure != null) performFromCache(graph, processor, procedure);
- checkAndThrow();
- return getResult();
- }
-
- @Override
- boolean isImmutable(ReadGraphImpl graph) throws DatabaseException {
- if(request instanceof ReadExt) {
- return ((ReadExt)request).isImmutable(graph);
- }
- return false;
- }
+ AsyncProcedure<T> proc = (AsyncProcedure<T>) procedure;
+
+ if (isExcepted()) {
+ if(proc != null) {
+ try {
+ proc.exception(graph, (Throwable) getResult());
+ } catch (Throwable t) {
+ LOGGER.error("performFromCache proc.exception failed", t);
+ }
+ }
+ Throwable t = (Throwable) getResult();
+ if(t instanceof DatabaseException) {
+ throw (DatabaseException)t;
+ } else {
+ throw new DatabaseException(t);
+ }
+ } else {
+ if(proc != null) {
+ try {
+ proc.execute(graph, (T) getResult());
+ } catch (Throwable t) {
+ LOGGER.error("performFromCache proc.execute failed", t);
+ }
+ }
+ return (T)getResult();
+ }
+
+ }
+
+ @Override
+ public String toString() {
+ if (id == null)
+ return "DISCARDED";
+ else
+ return id.toString() + " - " + statusOrException;
+ }
+
+ public Object get(ReadGraphImpl graph, AsyncProcedure<T> procedure) throws DatabaseException {
+ if (procedure != null)
+ performFromCache(graph, procedure);
+ checkAndThrow();
+ return getResult();
+ }
+
+ @Override
+ boolean isImmutable(ReadGraphImpl graph) throws DatabaseException {
+ if (id instanceof ReadExt) {
+ return ((ReadExt) id).isImmutable(graph);
+ }
+ return false;
+ }
+
+ @Override
+ public void execute(AsyncReadGraph graph, T result) {
+ setResult(result);
+ setReady();
+ }
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable throwable) {
+ except(throwable);
+ }
+
+ @Override
+ public String classId() {
+ return null;
+ }