Spring Data Couchbase

org.springframework.data.couchbase.core
Class CouchbaseFactoryBean

java.lang.Object
  extended by org.springframework.data.couchbase.core.CouchbaseFactoryBean
All Implemented Interfaces:
DisposableBean, FactoryBean<com.couchbase.client.CouchbaseClient>, InitializingBean, PersistenceExceptionTranslator

public class CouchbaseFactoryBean
extends Object
implements FactoryBean<com.couchbase.client.CouchbaseClient>, InitializingBean, DisposableBean, PersistenceExceptionTranslator

Convenient Factory for configuring a CouchbaseClient. To set the properties correctly on the CouchbaseClient a CouchbaseConnectionFactoryBuilder is used. After all properties are set, the client is constructed and used.

Author:
Michael Nitschinger

Field Summary
static String DEFAULT_BUCKET
          Defines the default bucket name to be used if no other bucket name is supplied.
static String DEFAULT_DESTROY_METHOD
          The name of the default shutdown method to call when the context is destroyed.
static String DEFAULT_LOGGER_PROPERTY
          Use SLF4J as the default logger if not instructed otherwise.
static String DEFAULT_NODE
          Defines the default hostname to be used if no other list is supplied.
static String DEFAULT_PASSWORD
          Defines the password of the default bucket.
 
Constructor Summary
CouchbaseFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
          Instantiate the CouchbaseClient.
 void destroy()
          Shutdown the client when the bean is destroyed.
 com.couchbase.client.CouchbaseClient getObject()
          Return the underlying CouchbaseClient.
 Class<?> getObjectType()
          Returns the object type of the client.
 boolean isSingleton()
          The client should be returned as a singleton.
 void setBucket(String bucket)
          Set the bucket to be used.
 void setFailureMode(String mode)
          Set the failure mode if memcached buckets are used.
 void setHost(String hosts)
          Set the array of nodes from a delimited list of hosts.
 void setNodes(URI[] nodes)
          Set the nodes as an array of URIs.
 void setObservePollInterval(int interval)
          Set the observe poll interval in miliseconds.
 void setObservePollMax(int max)
          Set the maximum number of polls.
 void setOpQueueMaxBlockTime(int time)
          Set the operation queue maximum block time in miliseconds.
 void setOpTimeout(int timeout)
          Set the operation timeout in miliseconds.
 void setPassword(String password)
          Set the password.
 void setReconnectThresholdTime(int time)
          Set the reconnect threshold time in seconds.
 void setViewTimeout(int timeout)
          Set the view timeout in miliseconds.
 DataAccessException translateExceptionIfPossible(RuntimeException ex)
          Translate exception if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NODE

public static final String DEFAULT_NODE
Defines the default hostname to be used if no other list is supplied.

See Also:
Constant Field Values

DEFAULT_BUCKET

public static final String DEFAULT_BUCKET
Defines the default bucket name to be used if no other bucket name is supplied.

See Also:
Constant Field Values

DEFAULT_PASSWORD

public static final String DEFAULT_PASSWORD
Defines the password of the default bucket.

See Also:
Constant Field Values

DEFAULT_DESTROY_METHOD

public static final String DEFAULT_DESTROY_METHOD
The name of the default shutdown method to call when the context is destroyed.

See Also:
Constant Field Values

DEFAULT_LOGGER_PROPERTY

public static final String DEFAULT_LOGGER_PROPERTY
Use SLF4J as the default logger if not instructed otherwise.

See Also:
Constant Field Values
Constructor Detail

CouchbaseFactoryBean

public CouchbaseFactoryBean()
Method Detail

setObservePollInterval

public void setObservePollInterval(int interval)
Set the observe poll interval in miliseconds.

Parameters:
interval - the observe poll interval.

setObservePollMax

public void setObservePollMax(int max)
Set the maximum number of polls.

Parameters:
max - the maximum number of polls.

setReconnectThresholdTime

public void setReconnectThresholdTime(int time)
Set the reconnect threshold time in seconds.

Parameters:
time - the reconnect threshold time.

setViewTimeout

public void setViewTimeout(int timeout)
Set the view timeout in miliseconds.

Parameters:
timeout - the view timeout.

setFailureMode

public void setFailureMode(String mode)
Set the failure mode if memcached buckets are used. See the proper values of FailureMode to use.

Parameters:
mode - the failure mode.

setOpTimeout

public void setOpTimeout(int timeout)
Set the operation timeout in miliseconds.

Parameters:
timeout - the operation timeout.

setOpQueueMaxBlockTime

public void setOpQueueMaxBlockTime(int time)
Set the operation queue maximum block time in miliseconds.

Parameters:
time - the operation queue maximum block time.

destroy

public void destroy()
             throws Exception
Shutdown the client when the bean is destroyed.

Specified by:
destroy in interface DisposableBean
Throws:
Exception - if shutdown failed.

getObject

public com.couchbase.client.CouchbaseClient getObject()
                                               throws Exception
Return the underlying CouchbaseClient.

Specified by:
getObject in interface FactoryBean<com.couchbase.client.CouchbaseClient>
Returns:
the client object.
Throws:
Exception - if returning the client failed.

getObjectType

public Class<?> getObjectType()
Returns the object type of the client.

Specified by:
getObjectType in interface FactoryBean<com.couchbase.client.CouchbaseClient>
Returns:
the CouchbaseClient class.

isSingleton

public boolean isSingleton()
The client should be returned as a singleton.

Specified by:
isSingleton in interface FactoryBean<com.couchbase.client.CouchbaseClient>
Returns:
returns true.

setBucket

public void setBucket(String bucket)
Set the bucket to be used.

Parameters:
bucket - the bucket to use.

setPassword

public void setPassword(String password)
Set the password.

Parameters:
password - the password to use.

setHost

public void setHost(String hosts)
Set the array of nodes from a delimited list of hosts.

Parameters:
hosts - a comma separated list of hosts.

setNodes

public void setNodes(URI[] nodes)
Set the nodes as an array of URIs.

Parameters:
nodes - the nodes to connect to.

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Instantiate the CouchbaseClient.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception - if something goes wrong during instantiation.

translateExceptionIfPossible

public DataAccessException translateExceptionIfPossible(RuntimeException ex)
Translate exception if possible.

Specified by:
translateExceptionIfPossible in interface PersistenceExceptionTranslator
Parameters:
ex - the exception to translate.
Returns:
the translate exception.

Spring Data Couchbase

Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.