public Object invoke(HandleDing h, Object target, Object[] args, MethodProxy mp) { final Handle handle = h.getHandle(); final HandleCallback<?> callback = (HandleCallback<?>) args[0]; try { return callback.withHandle(handle); } catch (Exception e) { throw new CallbackFailedException(e); } } }
@Override public Object invoke(HandleDing h, Object target, Object[] args, MethodProxy mp) { final Handle handle = h.getHandle(); final HandleCallback<?> callback = (HandleCallback<?>) args[0]; try { return callback.withHandle(handle); } catch (Exception e) { throw new CallbackFailedException(e); } } }
private <T> T performCallback(final HandleCallback<T> callback) { if (transactionHandle != null) { try { return callback.withHandle(transactionHandle); } catch (Exception e) { throw new CallbackFailedException(e); } } else { return migratoryContext.getDBI().withHandle(callback); } }
/** * A convenience function which manages the lifecycle of a handle and yields it to a callback * for use by clients. * * @param callback A callback which will receive an open Handle * * @return the value returned by callback * * @throws CallbackFailedException Will be thrown if callback raises an exception. This exception will * wrap the exception thrown by the callback. */ public <ReturnType> ReturnType withHandle(HandleCallback<ReturnType> callback) throws CallbackFailedException { final Handle h = this.open(); try { return callback.withHandle(h); } catch (Exception e) { throw new CallbackFailedException(e); } finally { h.close(); } }
/** * A convenience function which manages the lifecycle of a handle and yields it to a callback * for use by clients. * * @param callback A callback which will receive an open Handle * * @return the value returned by callback * * @throws CallbackFailedException Will be thrown if callback raises an exception. This exception will * wrap the exception thrown by the callback. */ @Override public <ReturnType> ReturnType withHandle(HandleCallback<ReturnType> callback) throws CallbackFailedException { final Handle h = this.open(); try { return callback.withHandle(h); } catch (Exception e) { throw new CallbackFailedException(e); } finally { h.close(); } }