All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.jooby.internal.jdbi.HandleProvider Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
/**
 * Jooby https://jooby.io
 * Apache License Version 2.0 https://jooby.io/LICENSE.txt
 * Copyright 2014 Edgar Espina
 */
package io.jooby.internal.jdbi;

import io.jooby.RequestScope;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Jdbi;

import javax.inject.Provider;

public class HandleProvider implements Provider {
  private Jdbi jdbi;

  public HandleProvider(Jdbi jdbi) {
    this.jdbi = jdbi;
  }

  @Override public Handle get() {
    Handle handle = RequestScope.get(jdbi);
    if (handle == null) {
      handle = jdbi.open();
    }
    return handle;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy