@Override protected Object invokeAsyncSignature( final Method method, final Object[] args, final int resultCallbackIndex, final IResultCallback<Object> resultCallback, final IExecutionCallback executionCallback) { final Transaction tx; if (transactionalService) { tx = GraphDBConfig.getGraphDbService().beginTx(); } else { tx = null; } final IResultCallback<Object> decoratedResultCallback = createDecoratedResultCallback(resultCallback, executionCallback, tx); args[resultCallbackIndex] = decoratedResultCallback; try { CapServiceToolkit.checkCanceled(executionCallback); return method.invoke(original, args); } catch (final Exception exception) { decoratedResultCallback.exception(exception); return null; } }
@Override protected Object invokeSyncSignature( final Method method, final Object[] args, final IExecutionCallback executionCallback) throws Throwable { if (transactionalService) { final Transaction tx = GraphDBConfig.getGraphDbService().beginTx(); try { CapServiceToolkit.checkCanceled(executionCallback); final Object result = method.invoke(original, args); CapServiceToolkit.checkCanceled(executionCallback); tx.success(); return result; } catch (final Throwable e) { tx.failure(); throw decorateException(e, executionCallback); } finally { tx.finish(); } } else { try { CapServiceToolkit.checkCanceled(executionCallback); final Object result = method.invoke(original, args); CapServiceToolkit.checkCanceled(executionCallback); return result; } catch (final Throwable e) { throw decorateException(e, executionCallback); } } }