com.ch.mongo.MongoConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ch-mongo Show documentation
Show all versions of ch-mongo Show documentation
Persistence services for mongo collections.
The newest version!
package com.ch.mongo;
import java.util.logging.Logger;
import com.ch.config.ConfigProperties;
import com.ch.constants.Constant;
import com.ch.exception.DAOException;
import com.ch.exception.PropertyNotFoundException;
import com.ch.service.impl.DocumentStoreService;
public class MongoConfig {
private static final Logger LOGGER = Logger.getLogger(DocumentStoreService.class.getName());
private String mongoUsername;
private String mongoURI;
private String mongoHost;
private int mongoPort;
private String mongoPassword;
private String mongoDBName;
public String getMongoUsername() {
return mongoUsername;
}
public String getMongoURI() {
return mongoURI;
}
public String getMongoHost() {
return mongoHost;
}
public int getMongoPort() {
return mongoPort;
}
public String getMongoPassword() {
return mongoPassword;
}
public String getMongoDBName() {
return mongoDBName;
}
public MongoConfig(ConfigProperties configProperties) throws DAOException {
try {
//Find if mongoURI is specified if yet use it.
mongoURI = configProperties.getProperty(Constant.MONGO_DB_URI);
mongoDBName = configProperties.getProperty(Constant.MONGO_DBNAME);
} catch (PropertyNotFoundException e) {
LOGGER.warning("property " + Constant.MONGO_DB_URI + " not found. Trying to find other properties ");
try {
mongoHost = configProperties.getProperty(Constant.MONGO_DB_HOST);
mongoPort = Integer.valueOf(configProperties.getProperty(Constant.MONGO_DB_PORT));
mongoUsername = configProperties.getProperty(Constant.MONGO_DB_USERNAME);
mongoPassword = configProperties.getProperty(Constant.MONGO_DB_PASSWORD);
mongoDBName = configProperties.getProperty(Constant.MONGO_DBNAME);
} catch (PropertyNotFoundException e1) {
//Throwing first exception for mongoURI
throw new DAOException("Mongo connection parameter not found ", e);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy