public class CouchDbClient extends CouchDbClientBase
This class is the main object to use to gain access to the APIs.
Create a new client instance:
CouchDbClient dbClient = new CouchDbClient();
Start using the API by the client:
Documents CRUD APIs is accessed by the client directly, eg.: dbClient.find(Foo.class, "doc-id")
View APIs dbClient.view()
Change Notifications dbClient.changes()
Replication dbClient.replication() and dbClient.replicator()
DB server dbClient.context()
Design documents dbClient.design()
At the end of a client usage; it's useful to call: shutdown() to ensure proper release of resources.
CouchDbClientAndroidhost, httpClient, log| Constructor and Description |
|---|
CouchDbClient()
Constructs a new instance of this class, expects a configuration file named
couchdb.properties to be available in your application default classpath. |
CouchDbClient(CouchDbProperties properties)
Constructs a new instance of this class.
|
CouchDbClient(java.lang.String configFileName)
Constructs a new instance of this class.
|
CouchDbClient(java.lang.String dbName,
boolean createDbIfNotExist,
java.lang.String protocol,
java.lang.String host,
int port,
java.lang.String username,
java.lang.String password)
Constructs a new instance of this class.
|
| Modifier and Type | Method and Description |
|---|---|
private org.apache.http.impl.conn.PoolingHttpClientConnectionManager |
createConnectionManager(CouchDbProperties props,
org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> registry) |
(package private) org.apache.http.protocol.HttpContext |
createContext() |
(package private) org.apache.http.client.HttpClient |
createHttpClient(CouchDbProperties props) |
private org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> |
createRegistry(CouchDbProperties props) |
private void |
registerInterceptors(org.apache.http.impl.client.HttpClientBuilder clientBuilder)
Adds request/response interceptors for logging and validation.
|
void |
shutdown()
Shuts down the connection manager used by this client instance.
|
batch, bulk, changes, contains, context, delete, design, executeRequest, find, find, find, find, find, findAny, get, get, get, getBaseUri, getDBUri, getGson, head, invokeUpdateHandler, invokeUpdateHandler, post, post, put, put, remove, remove, replication, replicator, save, saveAttachment, saveAttachment, setGsonBuilder, syncDesignDocsWithDb, update, validate, viewpublic CouchDbClient()
couchdb.properties to be available in your application default classpath.public CouchDbClient(java.lang.String configFileName)
configFileName - The configuration file name.public CouchDbClient(java.lang.String dbName,
boolean createDbIfNotExist,
java.lang.String protocol,
java.lang.String host,
int port,
java.lang.String username,
java.lang.String password)
dbName - The database name.createDbIfNotExist - To create a new database if it does not already exist.protocol - The protocol to use (i.e http or https)host - The database host addressport - The database listening portusername - The Username credentialpassword - The Password credentialpublic CouchDbClient(CouchDbProperties properties)
properties - An object containing configuration properties.CouchDbProperties}org.apache.http.client.HttpClient createHttpClient(CouchDbProperties props)
createHttpClient in class CouchDbClientBaseCloseableHttpClient instance.org.apache.http.protocol.HttpContext createContext()
createContext in class CouchDbClientBaseHttpContext instance for HTTP request execution.private org.apache.http.impl.conn.PoolingHttpClientConnectionManager createConnectionManager(CouchDbProperties props, org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> registry)
private org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> createRegistry(CouchDbProperties props) throws java.security.KeyManagementException, java.security.NoSuchAlgorithmException, java.security.KeyStoreException
java.security.KeyManagementExceptionjava.security.NoSuchAlgorithmExceptionjava.security.KeyStoreExceptionprivate void registerInterceptors(org.apache.http.impl.client.HttpClientBuilder clientBuilder)
clientBuilder - public void shutdown()
CouchDbClientBaseshutdown in class CouchDbClientBase