0

Is there a way to tell JDBI I want to use a specific plugin (SqlObjectPlugin in my case) throughout my entire application, without having to re-specify upon each use? Throughout my application code I have the following:

var jdbi = Jdbi.create(dataSource);
jdbi.installPlugin(new SqlObjectPlugin());  // <== I want to make this part DRY

I'm tired of having that second boilerplate line repeated all over my code.

To the JDBI devs: I totally love the product! thx! :)

Vahid Pazirandeh
  • 1,552
  • 3
  • 13
  • 29

1 Answers1

0

You have two options, which of the is best depends on the code of your application:

  1. Instantiate Jdbi once and reuse it everywhere (using DI, static singleton, etc)
  2. Use org.jdbi.v3.core.Jdbi#installPlugins, which, according to documentation, uses the ServiceLoader API to detect and install plugins automagically. Some people consider this feature dangerous; some consider it essential -- use at your own risk. But you still would need to call this method every time.
Yurii Melnychuk
  • 858
  • 1
  • 5
  • 11