Spring Data Key-Value

org.springframework.data.keyvalue.riak.core
Class AbstractRiakTemplate

java.lang.Object
  extended by org.springframework.web.client.support.RestGatewaySupport
      extended by org.springframework.data.keyvalue.riak.core.AbstractRiakTemplate
All Implemented Interfaces:
BeanClassLoaderAware, InitializingBean
Direct Known Subclasses:
AsyncRiakTemplate, RiakKeyValueTemplate, RiakTemplate

public abstract class AbstractRiakTemplate
extends RestGatewaySupport
implements InitializingBean, BeanClassLoaderAware

Base class for RiakTemplates that defines basic behaviour common to both kinds of templates (Key/Value and Bucket/Key/Value).

Author:
J. Brisbin <[email protected]>

Field Summary
protected  List<BucketKeyResolver> bucketKeyResolvers
          A list of resolvers to turn a single object into a BucketKeyPair.
protected  ConcurrentSkipListMap<BucketKeyPair,RiakValue<?>> cache
          For caching objects based on ETags.
protected  ClassLoader classLoader
          ClassLoader to use for saving/loading objects using the automatic converters.
protected  ConversionService conversionService
          For converting objects to/from other kinds of objects.
protected  QosParameters defaultQosParameters
          The default QosParameters to use for all operations through this template.
protected  Class<?> defaultType
          Default type to use when trying to deserialize objects and we can't otherwise tell what to do.
protected  String defaultUri
          The URI to use inside the RestTemplate.
protected  boolean groovyPresent
          Do we need to handle Groovy strings in the Jackson JSON processor?
protected static SimpleDateFormat httpDate
          For getting a java.util.Date from the Last-Modified header.
protected  org.apache.commons.logging.Log log
           
protected  String mapReduceUri
          The URI for the Riak Map/Reduce API.
protected static Pattern prefix
          Regex used to extract host, port, and prefix from the given URI.
protected  String RIAK_CLIENT_ID
          Client ID used by Riak to correlate updates.
protected static String RIAK_META_CLASSNAME
           
protected static String RIAK_VCLOCK
           
protected  boolean useCache
          Whether or not to use the ETag-based cache.
protected  ExecutorService workerPool
          ExecutorService to use for running asynchronous jobs.
 
Fields inherited from class org.springframework.web.client.support.RestGatewaySupport
logger
 
Constructor Summary
AbstractRiakTemplate()
          Take all the defaults.
AbstractRiakTemplate(ClientHttpRequestFactory requestFactory)
          Use the specified ClientHttpRequestFactory.
 
Method Summary
 void afterPropertiesSet()
           
protected
<K,T> T
checkCache(K key, Class<T> requiredType)
           
protected  HttpHeaders defaultHeaders(Map<String,?> metadata)
           
protected  MediaType extractMediaType(Object value)
           
protected  RiakMetaData extractMetaData(HttpHeaders headers)
           
protected  String extractQosParameters(QosParameters qosParams)
          Get a string that represents the QOS parameters, taken either from the specified object or from the template defaults.
protected
<T> RiakValue<T>
extractValue(ResponseEntity<?> response, Class<?> origType, Class<T> requiredType)
           
 ConversionService getConversionService()
           
 QosParameters getDefaultQosParameters()
           
 Class<?> getDefaultType()
          Get the default type to use if none can be inferred.
 String getDefaultUri()
           
 String getHost()
           
 boolean getIgnoreNotFound()
           
 String getMapReduceUri()
           
 Integer getPort()
           
 String getPrefix()
          Extract the prefix from the URI for use in creating links.
protected
<B,K> Class<?>
getType(B bucket, K key)
           
protected
<B,K> Class<?>
getType(B bucket, K key, ClassLoader classLoader)
           
 ExecutorService getWorkerPool()
           
 boolean isUseCache()
           
protected  BucketKeyPair resolveBucketKeyPair(Object key, Object val)
           
 void setBeanClassLoader(ClassLoader classLoader)
           
 void setConversionService(ConversionService conversionService)
          Specify the conversion service to use.
 void setDefaultQosParameters(QosParameters defaultQosParameters)
           
 void setDefaultType(Class<?> defaultType)
          Set the default type to use if none can be inferred.
 void setDefaultUri(String defaultUri)
           
 void setIgnoreNotFound(boolean b)
           
 void setMapReduceUri(String mapReduceUri)
           
 void setUseCache(boolean useCache)
           
 void setWorkerPool(ExecutorService workerPool)
           
 
Methods inherited from class org.springframework.web.client.support.RestGatewaySupport
getRestTemplate, setRestTemplate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RIAK_META_CLASSNAME

protected static final String RIAK_META_CLASSNAME
See Also:
Constant Field Values

RIAK_VCLOCK

protected static final String RIAK_VCLOCK
See Also:
Constant Field Values

prefix

protected static final Pattern prefix
Regex used to extract host, port, and prefix from the given URI.


groovyPresent

protected final boolean groovyPresent
Do we need to handle Groovy strings in the Jackson JSON processor?


httpDate

protected static SimpleDateFormat httpDate
For getting a java.util.Date from the Last-Modified header.


log

protected final org.apache.commons.logging.Log log

RIAK_CLIENT_ID

protected final String RIAK_CLIENT_ID
Client ID used by Riak to correlate updates.


conversionService

protected ConversionService conversionService
For converting objects to/from other kinds of objects.


cache

protected ConcurrentSkipListMap<BucketKeyPair,RiakValue<?>> cache
For caching objects based on ETags.


useCache

protected boolean useCache
Whether or not to use the ETag-based cache.


defaultUri

protected String defaultUri
The URI to use inside the RestTemplate.


mapReduceUri

protected String mapReduceUri
The URI for the Riak Map/Reduce API.


bucketKeyResolvers

protected List<BucketKeyResolver> bucketKeyResolvers
A list of resolvers to turn a single object into a BucketKeyPair.


defaultQosParameters

protected QosParameters defaultQosParameters
The default QosParameters to use for all operations through this template.


workerPool

protected ExecutorService workerPool
ExecutorService to use for running asynchronous jobs.


defaultType

protected Class<?> defaultType
Default type to use when trying to deserialize objects and we can't otherwise tell what to do.


classLoader

protected ClassLoader classLoader
ClassLoader to use for saving/loading objects using the automatic converters.

Constructor Detail

AbstractRiakTemplate

public AbstractRiakTemplate()
Take all the defaults.


AbstractRiakTemplate

public AbstractRiakTemplate(ClientHttpRequestFactory requestFactory)
Use the specified ClientHttpRequestFactory.

Parameters:
requestFactory -
Method Detail

getConversionService

public ConversionService getConversionService()

setConversionService

public void setConversionService(ConversionService conversionService)
Specify the conversion service to use.

Parameters:
conversionService -

getDefaultUri

public String getDefaultUri()

setDefaultUri

public void setDefaultUri(String defaultUri)

getMapReduceUri

public String getMapReduceUri()

setMapReduceUri

public void setMapReduceUri(String mapReduceUri)

isUseCache

public boolean isUseCache()

setUseCache

public void setUseCache(boolean useCache)

getDefaultQosParameters

public QosParameters getDefaultQosParameters()

setDefaultQosParameters

public void setDefaultQosParameters(QosParameters defaultQosParameters)

getWorkerPool

public ExecutorService getWorkerPool()

setWorkerPool

public void setWorkerPool(ExecutorService workerPool)

setIgnoreNotFound

public void setIgnoreNotFound(boolean b)

getIgnoreNotFound

public boolean getIgnoreNotFound()

getDefaultType

public Class<?> getDefaultType()
Get the default type to use if none can be inferred.

Returns:

setDefaultType

public void setDefaultType(Class<?> defaultType)
Set the default type to use if none can be inferred.

Parameters:
defaultType -

setBeanClassLoader

public void setBeanClassLoader(ClassLoader classLoader)
Specified by:
setBeanClassLoader in interface BeanClassLoaderAware

getHost

public String getHost()

getPort

public Integer getPort()

getPrefix

public String getPrefix()
Extract the prefix from the URI for use in creating links.

Returns:

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

resolveBucketKeyPair

protected BucketKeyPair resolveBucketKeyPair(Object key,
                                             Object val)

extractMediaType

protected MediaType extractMediaType(Object value)

extractMetaData

protected RiakMetaData extractMetaData(HttpHeaders headers)
                                throws IOException
Throws:
IOException

extractValue

protected <T> RiakValue<T> extractValue(ResponseEntity<?> response,
                                        Class<?> origType,
                                        Class<T> requiredType)
                             throws IOException
Throws:
IOException

checkCache

protected <K,T> T checkCache(K key,
                             Class<T> requiredType)

extractQosParameters

protected String extractQosParameters(QosParameters qosParams)
Get a string that represents the QOS parameters, taken either from the specified object or from the template defaults.

Parameters:
qosParams -
Returns:

defaultHeaders

protected HttpHeaders defaultHeaders(Map<String,?> metadata)

getType

protected <B,K> Class<?> getType(B bucket,
                                 K key)

getType

protected <B,K> Class<?> getType(B bucket,
                                 K key,
                                 ClassLoader classLoader)

Spring Data Key-Value

Copyright © 2010-2011 SpringSource. All Rights Reserved.