Package com.rapleaf.jack.test_project

Source Code of com.rapleaf.jack.test_project.DatabasesImpl

/**
* Autogenerated by Jack
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
*/
package com.rapleaf.jack.test_project;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Map;

import org.jvyaml.YAML;

import com.rapleaf.jack.BaseDatabaseConnection;
import com.rapleaf.jack.DatabaseConnection;
import com.rapleaf.jack.test_project.database_1.IDatabase1;
import com.rapleaf.jack.test_project.database_1.impl.Database1Impl;

public class DatabasesImpl implements IDatabases {
  private static final IDatabases mockDatabases = new MockDatabasesImpl();
  private final IDatabase1 database1;

  public DatabasesImpl(BaseDatabaseConnection database1_connection) {
    this.database1 = new Database1Impl(database1_connection, this);
  }

  public DatabasesImpl() {
    // load database info from config folder
    Map env_info;
    try {
      env_info  = (Map)YAML.load(new FileReader("config/environment.yml"));
    } catch (FileNotFoundException e) {
      throw new RuntimeException(e);
    }
    Boolean use_mock = (Boolean)env_info.get("use_mock_db");
    if (use_mock != null && use_mock) {
      this.database1 = mockDatabases.getDatabase1();
    } else {
      this.database1 = new Database1Impl(new DatabaseConnection("database1"), this);
    }
  }

  public IDatabase1 getDatabase1() {
    return database1;
  }
}
TOP

Related Classes of com.rapleaf.jack.test_project.DatabasesImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.