org.ektorp.impl
Class StdCouchDbInstance

java.lang.Object
  extended by org.ektorp.impl.StdCouchDbInstance
All Implemented Interfaces:
CouchDbInstance

public class StdCouchDbInstance
extends Object
implements CouchDbInstance

Author:
henrik lundgren

Constructor Summary
StdCouchDbInstance(HttpClient client)
           
StdCouchDbInstance(HttpClient client, ObjectMapperFactory of)
           
 
Method Summary
 boolean checkIfDbExists(DbPath db)
           
 boolean checkIfDbExists(String path)
           
 CouchDbConnector createConnector(String path, boolean createIfNotExists)
           
 void createDatabase(DbPath db)
           
 void createDatabase(String path)
           
 boolean createDatabaseIfNotExists(DbPath db)
           
 boolean createDatabaseIfNotExists(String path)
           
 String deleteConfiguration(String section, String key)
          Delete the configuration key in the specified section
 void deleteDatabase(String path)
           
 Collection<ActiveTask> getActiveTasks()
           
 List<String> getAllDatabases()
           
<T> T
getConfiguration(Class<T> c)
          Get the full configuration of this instance
<T> T
getConfiguration(Class<T> c, String section)
          Get the configuration of this instance within the specified section
<T> T
getConfiguration(Class<T> c, String section, String key)
          Get the configuration of this instance for this specific section and key
 String getConfiguration(String section, String key)
          Convenience method to get specific configuration item
 HttpClient getConnection()
          Convenience method for accessing the underlying HttpClient.
 ObjectMapperFactory getObjectMapperFactory()
           
 CouchDbConnector getReplicatorConnector()
          Returns the Couch _replicator database
 ReplicationStatus replicate(ReplicationCommand cmd)
           
 String setConfiguration(String section, String key, String value)
          Update the configuration key in the specified section with the specified value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StdCouchDbInstance

public StdCouchDbInstance(HttpClient client)

StdCouchDbInstance

public StdCouchDbInstance(HttpClient client,
                          ObjectMapperFactory of)
Method Detail

getObjectMapperFactory

public ObjectMapperFactory getObjectMapperFactory()

createDatabase

public void createDatabase(String path)
Specified by:
createDatabase in interface CouchDbInstance

createDatabase

public void createDatabase(DbPath db)
Specified by:
createDatabase in interface CouchDbInstance

createDatabaseIfNotExists

public boolean createDatabaseIfNotExists(String path)
Specified by:
createDatabaseIfNotExists in interface CouchDbInstance

createDatabaseIfNotExists

public boolean createDatabaseIfNotExists(DbPath db)
Specified by:
createDatabaseIfNotExists in interface CouchDbInstance

deleteDatabase

public void deleteDatabase(String path)
Specified by:
deleteDatabase in interface CouchDbInstance

checkIfDbExists

public boolean checkIfDbExists(String path)
Specified by:
checkIfDbExists in interface CouchDbInstance

checkIfDbExists

public boolean checkIfDbExists(DbPath db)
Specified by:
checkIfDbExists in interface CouchDbInstance
Returns:
true if the database exists.

getAllDatabases

public List<String> getAllDatabases()
Specified by:
getAllDatabases in interface CouchDbInstance
Returns:
the names of all databases residing in this instance.

replicate

public ReplicationStatus replicate(ReplicationCommand cmd)
Specified by:
replicate in interface CouchDbInstance

getConnection

public HttpClient getConnection()
Description copied from interface: CouchDbInstance
Convenience method for accessing the underlying HttpClient. Preferably used wrapped in a org.ektorp.http.RestTemplate.

Specified by:
getConnection in interface CouchDbInstance
Returns:

createConnector

public CouchDbConnector createConnector(String path,
                                        boolean createIfNotExists)
Specified by:
createConnector in interface CouchDbInstance
Returns:

getReplicatorConnector

public CouchDbConnector getReplicatorConnector()
Description copied from interface: CouchDbInstance
Returns the Couch _replicator database

Specified by:
getReplicatorConnector in interface CouchDbInstance
Returns:
CouchDbConnector a connector to the replicator database

getConfiguration

public <T> T getConfiguration(Class<T> c)
Description copied from interface: CouchDbInstance
Get the full configuration of this instance

Specified by:
getConfiguration in interface CouchDbInstance
Parameters:
c - the type to return the configuration in (Map, JsonNode, POJO)
Returns:

getConfiguration

public <T> T getConfiguration(Class<T> c,
                              String section)
Description copied from interface: CouchDbInstance
Get the configuration of this instance within the specified section

Specified by:
getConfiguration in interface CouchDbInstance
Parameters:
c - the type to return the configuration in (Map, JsonNode, POJO)
Returns:

getConfiguration

public <T> T getConfiguration(Class<T> c,
                              String section,
                              String key)
Description copied from interface: CouchDbInstance
Get the configuration of this instance for this specific section and key

Specified by:
getConfiguration in interface CouchDbInstance
Parameters:
c - the type to return the configuration in (Map, JsonNode, POJO)
Returns:

getConfiguration

public String getConfiguration(String section,
                               String key)
Description copied from interface: CouchDbInstance
Convenience method to get specific configuration item

Specified by:
getConfiguration in interface CouchDbInstance
Returns:
the configuration value for the specified key in the specified section

setConfiguration

public String setConfiguration(String section,
                               String key,
                               String value)
Description copied from interface: CouchDbInstance
Update the configuration key in the specified section with the specified value

Specified by:
setConfiguration in interface CouchDbInstance
value - the value to set (all config values are Strings in CouchDB)
Returns:
the previous value for this key

deleteConfiguration

public String deleteConfiguration(String section,
                                  String key)
Description copied from interface: CouchDbInstance
Delete the configuration key in the specified section

Specified by:
deleteConfiguration in interface CouchDbInstance
Returns:
the previous value for this key

getActiveTasks

public Collection<ActiveTask> getActiveTasks()
Specified by:
getActiveTasks in interface CouchDbInstance
Returns:
all active tasks


Copyright © 2017. All rights reserved.