Skip to content

Java: Standardize hooks + middleware implementation with other languages - #1519

Open
brandur wants to merge 1 commit into
masterfrom
brandur-java-plugin-fix
Open

brandur wants to merge 1 commit into
masterfrom
brandur-java-plugin-fix

Conversation

@brandur

@brandur brandur commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

I noticed today that Java had been done something a little weird in that
instead of hooks/middleware like in Go, we ended up with a broad
Extension interface that does everything.

Here, give Java a more normal implementation compared to other
languages. We have specific hooks/middleware like:

public interface HookInsertBegin extends Hook {
  /**
   * Runs in the insertion's transaction. Throwing fails and rolls back the insertion, including
   * application writes made using this connection. Options are the caller's overrides, before
   * merging with job-type defaults.
   */
  void insertBegin(Connection connection, JobType<?> type, Object args, InsertOptions options)
      throws Exception;
}

Which extends from a base like Hook:

public interface Hook extends Plugin {}

Which extends from Plugin so that everything can be set together:

public interface Plugin {}

I noticed today that Java had been done something a little weird in that
instead of hooks/middleware like in Go, we ended up with a broad
`Extension` interface that does everything.

Here, give Java a more normal implementation compared to other
languages. We have specific hooks/middleware like:

    public interface HookInsertBegin extends Hook {
      /**
       * Runs in the insertion's transaction. Throwing fails and rolls back the insertion, including
       * application writes made using this connection. Options are the caller's overrides, before
       * merging with job-type defaults.
       */
      void insertBegin(Connection connection, JobType<?> type, Object args, InsertOptions options)
          throws Exception;
    }

Which extends from a base like `Hook`:

    public interface Hook extends Plugin {}

Which extends from `Plugin` so that everything can be set together:

    public interface Plugin {}
@brandur
brandur requested a review from bgentry October 18, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant