/**
 * DaoFactory contains necessary Daos (Singleton)
 *
 * @author Turlygazy
 */
public class DaoFactory {

  // Takes connection from ConnectionPool
  private static Connection connection = ConnectionPool.getConnection();
  private static DaoFactory daoFactory = new DaoFactory();

  private DaoFactory() {}

  // initialization of connection
  public DaoFactory(Connection connection) {
    this.connection = connection;
  }

  /** @return connection */
  public static DaoFactory getFactory() {
    return daoFactory;
  }

  public OrderDao getOrderDao() {
    return new OrderDao(connection);
  }

  public DishDao getDishDao() {
    return new DishDao(connection);
  }

  public ReviewDao getReviewDao() {
    return new ReviewDao(connection);
  }

  public UserDao getUserDao() {
    return new UserDao(connection);
  }

  public void close() {
    ConnectionPool.releaseConnection(connection);
  }
}
 public void close() {
   ConnectionPool.releaseConnection(connection);
 }