* @return a DataContext object that matches the request
*/
public static UpdateableDataContext createCouchDbDataContext(String hostname, Integer port, String username,
String password, SimpleTableDef[] tableDefs) {
Builder httpClientBuilder = new Builder();
httpClientBuilder.host(hostname);
if (port != null) {
httpClientBuilder.port(port);
}
if (username != null) {
httpClientBuilder.username(username);
}
if (password != null) {
httpClientBuilder.password(password);
}
// increased timeouts (20 sec) - metamodel typically does quite some
// batching so it might take a bit of time to provide a connection.
httpClientBuilder.connectionTimeout(20000);
httpClientBuilder.socketTimeout(20000);
if (tableDefs == null || tableDefs.length == 0) {
return new CouchDbDataContext(httpClientBuilder);
}
return new CouchDbDataContext(httpClientBuilder, tableDefs);