/** * Constructs a new instance of this class. * @param configFileName The configuration file name. */ public CouchDbClient(String configFileName) { super(new CouchDbConfig(configFileName)); }
private int getPropertyAsInt(String key, boolean isRequired) { String prop = getProperty(key, isRequired); return (prop != null) ? Integer.parseInt(prop) : 0; } }
private void readProperties() { try { // required dbProperties = new CouchDbProperties(); dbProperties.setDbName(getProperty("couchdb.name", true)); dbProperties.setCreateDbIfNotExist(new Boolean(getProperty("couchdb.createdb.if-not-exist", true))); dbProperties.setProtocol(getProperty("couchdb.protocol", true)); dbProperties.setHost(getProperty("couchdb.host", true)); dbProperties.setPort(Integer.parseInt(getProperty("couchdb.port", true))); dbProperties.setUsername(getProperty("couchdb.username", true)); dbProperties.setPassword(getProperty("couchdb.password", true)); // optional dbProperties.setPath(getProperty("couchdb.path", false)); dbProperties.setSocketTimeout(getPropertyAsInt("couchdb.http.socket.timeout", false)); dbProperties.setConnectionTimeout(getPropertyAsInt("couchdb.http.connection.timeout", false)); dbProperties.setMaxConnections(getPropertyAsInt("couchdb.max.connections", false)); dbProperties.setProxyHost(getProperty("couchdb.proxy.host", false)); dbProperties.setProxyPort(getPropertyAsInt("couchdb.proxy.port", false)); } catch (Exception e) { throw new IllegalStateException(e); } properties = null; }
public CouchDbConfig(String configFile) { this.configFile = configFile; try { InputStream instream = CouchDbConfig.class.getClassLoader().getResourceAsStream(configFile); properties.load(instream); } catch (Exception e) { String msg = "Could not read configuration file from the classpath: " + configFile; log.error(msg); throw new IllegalStateException(msg, e); } readProperties(); }
CouchDbClientBase(CouchDbConfig config) { final CouchDbProperties props = config.getProperties(); this.httpClient = createHttpClient(props); this.gson = initGson(new GsonBuilder()); this.host = new HttpHost(props.getHost(), props.getPort(), props.getProtocol()); final String path = props.getPath() != null ? props.getPath() : ""; this.baseURI = buildUri().scheme(props.getProtocol()).host(props.getHost()).port(props.getPort()).path("/").path(path).build(); this.dbURI = buildUri(baseURI).path(props.getDbName()).path("/").build(); this.context = new CouchDbContext(this, props); this.design = new CouchDbDesign(this); }
/** * Constructs a new client instance. * @param configFileName The configuration file */ public CouchDbClientAndroid(String configFileName) { super(new CouchDbConfig(configFileName)); }
/** * Constructs a new client instance. * @param properties An object containing configuration properties. */ public CouchDbClientAndroid(CouchDbProperties properties) { super(new CouchDbConfig(properties)); }
/** * Constructs a new instance of this class. * @param properties An object containing configuration properties. * @see CouchDbProperties */ public CouchDbClient(CouchDbProperties properties) { super(new CouchDbConfig(properties)); }
CouchDbClientBase() { this(new CouchDbConfig()); }
/** * Constructs a new client instance. * @param dbName The database name. * @param createDbIfNotExist To create a new database if it does not already exist. * @param protocol The protocol to use (i.e http or https) * @param host The database host address * @param port The database listening port * @param username The Username credential * @param password The Password credential */ public CouchDbClientAndroid(String dbName, boolean createDbIfNotExist, String protocol, String host, int port, String username, String password) { super(new CouchDbConfig(new CouchDbProperties(dbName, createDbIfNotExist, protocol, host, port, username, password))); }
/** * Constructs a new instance of this class. * @param dbName The database name. * @param createDbIfNotExist To create a new database if it does not already exist. * @param protocol The protocol to use (i.e http or https) * @param host The database host address * @param port The database listening port * @param username The Username credential * @param password The Password credential */ public CouchDbClient(String dbName, boolean createDbIfNotExist, String protocol, String host, int port, String username, String password) { super(new CouchDbConfig(new CouchDbProperties(dbName, createDbIfNotExist, protocol, host, port, username, password))); }