Class AbstractJdbiExecutor

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      <R,​X extends java.lang.Exception>
      java.util.concurrent.CompletionStage<R>
      inTransaction​(HandleCallback<R,​X> callback)
      A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients.
      <R,​X extends java.lang.Exception>
      java.util.concurrent.CompletionStage<R>
      inTransaction​(TransactionIsolationLevel level, HandleCallback<R,​X> callback)
      A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients.
      protected java.util.concurrent.CompletionStage<java.lang.Void> useExecute​(CheckedConsumer<Jdbi> callback)
      Single method through which all other use* methods converge.
      <E,​X extends java.lang.Exception>
      java.util.concurrent.CompletionStage<java.lang.Void>
      useExtension​(java.lang.Class<E> extensionType, ExtensionConsumer<E,​X> callback)
      A convenience method which opens an extension of the given type, and yields it to a callback.
      <X extends java.lang.Exception>
      java.util.concurrent.CompletionStage<java.lang.Void>
      useHandle​(HandleConsumer<X> consumer)
      A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients.
      <X extends java.lang.Exception>
      java.util.concurrent.CompletionStage<java.lang.Void>
      useTransaction​(HandleConsumer<X> callback)
      A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients.
      <X extends java.lang.Exception>
      java.util.concurrent.CompletionStage<java.lang.Void>
      useTransaction​(TransactionIsolationLevel level, HandleConsumer<X> callback)
      A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients.
      protected abstract <T> java.util.concurrent.CompletionStage<T> withExecute​(CheckedFunction<Jdbi,​T> callback)
      Single method through which all other with* methods converge.
      <R,​E,​X extends java.lang.Exception>
      java.util.concurrent.CompletionStage<R>
      withExtension​(java.lang.Class<E> extensionType, ExtensionCallback<R,​E,​X> callback)
      A convenience method which opens an extension of the given type, yields it to a callback, and returns the result of the callback.
      <R,​X extends java.lang.Exception>
      java.util.concurrent.CompletionStage<R>
      withHandle​(HandleCallback<R,​X> callback)
      A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractJdbiExecutor

        public AbstractJdbiExecutor()
    • Method Detail

      • withExecute

        protected abstract <T> java.util.concurrent.CompletionStage<T> withExecute​(CheckedFunction<Jdbi,​T> callback)
        Single method through which all other with* methods converge. Since useExecute also calls this, any implementation of AbstractJdbiExecutor only needs to implement this method
        Type Parameters:
        T - type returned by the callback
        Parameters:
        callback - the callback that takes a Jdbi instance and returns a value
        Returns:
        a completion stage that will complete when the handler returns a value or throws an exception
      • useExecute

        protected java.util.concurrent.CompletionStage<java.lang.Void> useExecute​(CheckedConsumer<Jdbi> callback)
        Single method through which all other use* methods converge. This method calls withExecute(CheckedFunction)
        Parameters:
        callback - the callback that takes a Jdbi instance
        Returns:
        a completion stage that will complete when the handler returns or throws an exception
      • withHandle

        public <R,​X extends java.lang.Exception> java.util.concurrent.CompletionStage<R> withHandle​(HandleCallback<R,​X> callback)
        Description copied from interface: JdbiExecutor
        A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients.

        The callback will be executed in a thread supplied by the executor

        Specified by:
        withHandle in interface JdbiExecutor
        Type Parameters:
        R - type returned by the callback
        X - exception type thrown by the callback, if any.
        Parameters:
        callback - A callback which will receive an open Handle
        Returns:
        a completion stage which completes when the callback returns a value or throws an exception
      • inTransaction

        public <R,​X extends java.lang.Exception> java.util.concurrent.CompletionStage<R> inTransaction​(HandleCallback<R,​X> callback)
        Description copied from interface: JdbiExecutor
        A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients. The handle will be in a transaction when the callback is invoked, and that transaction will be committed if the callback finishes normally, or rolled back if the callback raises an exception.

        The callback will be executed in a thread supplied by the executor

        Specified by:
        inTransaction in interface JdbiExecutor
        Type Parameters:
        R - type returned by the callback
        X - exception type thrown by the callback, if any.
        Parameters:
        callback - A callback which will receive an open Handle, in a transaction
        Returns:
        a completion stage which completes when the callback returns a value or throws an exception
      • inTransaction

        public <R,​X extends java.lang.Exception> java.util.concurrent.CompletionStage<R> inTransaction​(TransactionIsolationLevel level,
                                                                                                             HandleCallback<R,​X> callback)
        Description copied from interface: JdbiExecutor
        A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients. The handle will be in a transaction when the callback is invoked, and that transaction will be committed if the callback finishes normally, or rolled back if the callback raises an exception.

        This form accepts a transaction isolation level which will be applied to the connection for the scope of this transaction, after which the original isolation level will be restored.

        The callback will be executed in a thread supplied by the executor

        Specified by:
        inTransaction in interface JdbiExecutor
        Type Parameters:
        R - type returned by the callback
        X - exception type thrown by the callback, if any.
        Parameters:
        level - the transaction isolation level which will be applied to the connection for the scope of this transaction, after which the original isolation level will be restored.
        callback - A callback which will receive an open Handle, in a transaction
        Returns:
        a completion stage which completes when the callback returns a value or throws an exception
      • useHandle

        public <X extends java.lang.Exception> java.util.concurrent.CompletionStage<java.lang.Void> useHandle​(HandleConsumer<X> consumer)
        Description copied from interface: JdbiExecutor
        A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients.

        The callback will be executed in a thread supplied by the executor

        Specified by:
        useHandle in interface JdbiExecutor
        Type Parameters:
        X - exception type thrown by the callback, if any.
        Parameters:
        consumer - A callback which will receive an open Handle
        Returns:
        a completion stage which completes when the callback returns or throws an exception
      • useTransaction

        public <X extends java.lang.Exception> java.util.concurrent.CompletionStage<java.lang.Void> useTransaction​(HandleConsumer<X> callback)
        Description copied from interface: JdbiExecutor
        A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients. The handle will be in a transaction when the callback is invoked, and that transaction will be committed if the callback finishes normally, or rolled back if the callback raises an exception.

        The callback will be executed in a thread supplied by the executor

        Specified by:
        useTransaction in interface JdbiExecutor
        Type Parameters:
        X - exception type thrown by the callback, if any.
        Parameters:
        callback - A callback which will receive an open Handle, in a transaction
        Returns:
        a completion stage which completes when the callback returns or throws an exception
      • useTransaction

        public <X extends java.lang.Exception> java.util.concurrent.CompletionStage<java.lang.Void> useTransaction​(TransactionIsolationLevel level,
                                                                                                                   HandleConsumer<X> callback)
        Description copied from interface: JdbiExecutor
        A convenience function which manages the lifecycle of a handle and yields it to a callback for use by clients. The handle will be in a transaction when the callback is invoked, and that transaction will be committed if the callback finishes normally, or rolled back if the callback raises an exception.

        This form accepts a transaction isolation level which will be applied to the connection for the scope of this transaction, after which the original isolation level will be restored.

        The callback will be executed in a thread supplied by the executor

        Specified by:
        useTransaction in interface JdbiExecutor
        Type Parameters:
        X - exception type thrown by the callback, if any.
        Parameters:
        level - the transaction isolation level which will be applied to the connection for the scope of this transaction, after which the original isolation level will be restored.
        callback - A callback which will receive an open Handle, in a transaction
        Returns:
        a completion stage which completes when the callback returns or throws an exception
      • withExtension

        public <R,​E,​X extends java.lang.Exception> java.util.concurrent.CompletionStage<R> withExtension​(java.lang.Class<E> extensionType,
                                                                                                                     ExtensionCallback<R,​E,​X> callback)
        Description copied from interface: JdbiExecutor
        A convenience method which opens an extension of the given type, yields it to a callback, and returns the result of the callback. A handle is opened if needed by the extension, and closed before returning to the caller.

        The callback will be executed in a thread supplied by the executor

        Specified by:
        withExtension in interface JdbiExecutor
        Type Parameters:
        R - the return type
        E - the extension type
        X - the exception type optionally thrown by the callback
        Parameters:
        extensionType - the type of extension.
        callback - a callback which will receive the extension.
        Returns:
        a completion stage which completes when the callback returns a value or throws an exception, or will complete with NoSuchExtensionException if no ExtensionFactory is registered which supports the given extension type.
      • useExtension

        public <E,​X extends java.lang.Exception> java.util.concurrent.CompletionStage<java.lang.Void> useExtension​(java.lang.Class<E> extensionType,
                                                                                                                         ExtensionConsumer<E,​X> callback)
        Description copied from interface: JdbiExecutor
        A convenience method which opens an extension of the given type, and yields it to a callback. A handle is opened if needed by the extention, and closed before returning to the caller.

        The callback will be executed in a thread supplied by the executor

        Specified by:
        useExtension in interface JdbiExecutor
        Type Parameters:
        E - the extension type
        X - the exception type optionally thrown by the callback
        Parameters:
        extensionType - the type of extension
        callback - a callback which will receive the extension
        Returns:
        a completion stage which completes when the callback returns or throws an exception, or will complete with NoSuchExtensionException if no ExtensionFactory is registered which supports the given extension type.