private static void checkMongoClient(
      Configuration configuration, Class<?> mappedClass, String clientName, String dbName) {
    Configuration mongodbClientConfiguration =
        getMongoClientConfiguration(configuration, clientName);

    if (mongodbClientConfiguration.isEmpty()) {
      throw SeedException.createNew(MongoDbErrorCodes.UNKNOWN_CLIENT_SPECIFIED)
          .put("aggregate", mappedClass.getName())
          .put("clientName", clientName)
          .put("dbName", dbName);
    }

    boolean async = mongodbClientConfiguration.getBoolean("async", false);
    if (async) {
      throw SeedException.createNew(MorphiaErrorCodes.ERROR_ASYNC_CLIENT)
          .put("aggregate", mappedClass.getName())
          .put("clientName", clientName)
          .put("dbName", dbName);
    }

    String[] dbNames = mongodbClientConfiguration.getStringArray("databases");
    boolean found = false;
    for (String nameToCheck : dbNames) {
      if (nameToCheck.equals(resolveDatabaseAlias(mongodbClientConfiguration, dbName))) {
        found = true;
        break;
      }
    }
    if (!found) {
      throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATABASE_NAME)
          .put("aggregate", mappedClass.getName())
          .put("clientName", clientName)
          .put("dbName", dbName);
    }
  }
  /**
   * Returns an instance of the annotation MorphiaDatastore if the morphia configuration is ok.
   *
   * @param application Application
   * @param morphiaClass persistent morphia object
   * @return MorphiaDatastore
   */
  public static MorphiaDatastore getMongoDatastore(Application application, Class<?> morphiaClass) {
    Configuration morphiaEntityConfiguration =
        application.getConfiguration(morphiaClass).subset("morphia");
    if (morphiaEntityConfiguration.isEmpty()) {
      throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CONFIGURATION)
          .put("aggregate", morphiaClass.getName());
    }

    String clientName = morphiaEntityConfiguration.getString("clientName");
    if (clientName == null) {
      throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_CLIENT)
          .put("aggregate", morphiaClass.getName());
    }

    String dbName = morphiaEntityConfiguration.getString("dbName");
    if (dbName == null) {
      throw SeedException.createNew(MorphiaErrorCodes.UNKNOW_DATASTORE_DATABASE)
          .put("aggregate", morphiaClass.getName())
          .put("clientName", clientName);
    }

    checkMongoClient(application.getConfiguration(), morphiaClass, clientName, dbName);

    return new MorphiaDatastoreImpl(clientName, dbName);
  }
  @Override
  public void addBaseFileName(String fileName) {
    URL url = _classLoader.getResource(fileName);

    Configuration configuration = _addPropertiesSource(fileName, url, _baseCompositeConfiguration);

    if ((configuration != null) && !configuration.isEmpty()) {
      _baseConfigurationLoaded = true;
    }
  }