diff --git a/.classpath b/.classpath
new file mode 100644
index 000000000..23fb3b56a
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
index de8921796..5c643ec33 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ src/ant/.ant-targets-upload-dist.xml
*.iml
*.ipr
*.iws
+*.log
diff --git a/.project b/.project
new file mode 100644
index 000000000..97c950f78
--- /dev/null
+++ b/.project
@@ -0,0 +1,34 @@
+
+
+ spring-data-redis
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ com.springsource.sts.gradle.core.nature
+ org.eclipse.jdt.core.javanature
+
+
+
+ 1309881117241
+
+ 10
+
+ org.eclipse.ui.ide.orFilterMatcher
+
+
+ org.eclipse.ui.ide.multiFilter
+ 1.0-projectRelativePath-equals-true-false-E:docs
+
+
+
+
+
+
diff --git a/spring-data-redis/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
similarity index 94%
rename from spring-data-redis/.settings/org.eclipse.jdt.core.prefs
rename to .settings/org.eclipse.jdt.core.prefs
index 9811d21e9..429280cd1 100644
--- a/spring-data-redis/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,13 +1,12 @@
-#
-#Fri Jul 01 15:44:20 EEST 2011
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+#Tue Jul 05 18:51:57 EEST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/.settings/org.maven.ide.eclipse.prefs b/.settings/org.maven.ide.eclipse.prefs
deleted file mode 100644
index fc929aaef..000000000
--- a/.settings/org.maven.ide.eclipse.prefs
+++ /dev/null
@@ -1,9 +0,0 @@
-#Mon Oct 11 17:02:20 EDT 2010
-activeProfiles=
-eclipse.preferences.version=1
-fullBuildGoals=process-test-resources
-includeModules=false
-resolveWorkspaceProjects=true
-resourceFilterGoals=process-resources resources\:testResources
-skipCompilerPlugin=true
-version=1
diff --git a/README.md b/README.md
index 60347ea60..acc1b8830 100644
--- a/README.md
+++ b/README.md
@@ -45,9 +45,9 @@ For those in a hurry:
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
+
-
diff --git a/build.gradle b/build.gradle
index 2546282d0..bb051fa3c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,6 @@
// used for artifact names, building doc upload urls, etc.
-description = 'Spring Data Key Value'
-abbreviation = 'DATAKV'
+description = 'Spring Data Redis'
+abbreviation = 'DATAREDIS'
apply plugin: 'base'
apply plugin: 'idea'
@@ -30,7 +30,7 @@ buildscript {
}
allprojects {
- group = 'org.springframework.data'
+ group = 'org.springframework.data.redis'
version = '1.0.0.BUILD-SNAPSHOT'
releaseBuild = version.endsWith('RELEASE')
@@ -48,49 +48,63 @@ allprojects {
mavenRepo name: "sonatype-snapshot", urls: "http://oss.sonatype.org/content/repositories/snapshots"
mavenRepo name: "jboss", urls: "http://repository.jboss.org/maven2/"
mavenRepo name: "java.net", urls: "http://download.java.net/maven/2/"
+ mavenRepo name: "ext-snapshots", urls: "http://springframework.svn.sourceforge.net/svnroot/springframework/repos/repo-ext/"
}
+
}
-javaprojects = subprojects.findAll {
- project -> project.path.startsWith(':spring-data-')
+
+apply plugin: "java"
+apply plugin: "maven"
+apply plugin: 'eclipse' // `gradle eclipse` to generate .classpath/.project
+apply plugin: 'idea' // `gradle idea` to generate .ipr/.iml
+apply plugin: 'docbook'
+apply plugin: 'bundlor' // all core projects should be OSGi-compliant
+
+bundlor.useProjectProps = true
+[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:-serial"]
+
+// Common dependencies
+dependencies {
+ // Logging
+ compile "org.slf4j:slf4j-api:$slf4jVersion"
+ compile "org.slf4j:jcl-over-slf4j:$slf4jVersion"
+ runtime "log4j:log4j:$log4jVersion"
+ runtime "org.slf4j:slf4j-log4j12:$slf4jVersion"
+
+ // Spring Framework
+ compile("org.springframework:spring-core:$springVersion") {
+ exclude module: "commons-logging"
+ }
+ compile "org.springframework:spring-beans:$springVersion"
+ compile "org.springframework:spring-context:$springVersion"
+ compile "org.springframework:spring-context-support:$springVersion"
+ compile "org.springframework:spring-tx:$springVersion"
+ compile("org.springframework:spring-oxm:$springVersion") { optional = true }
+
+ // Redis Drivers
+ compile "redis.clients:jedis:$jedisVersion"
+ compile("org.jredis:jredis-anthonylauzon:$jredisVersion") { optional = true }
+ compile("org.idevlab:rjc:$rjcVersion") { optional = true }
+
+ // Mappers
+ compile("org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion") { optional = true }
+ compile("commons-beanutils:commons-beanutils-core:1.8.3") { optional = true }
+
+ // Testing
+ testCompile "junit:junit:$junitVersion"
+ testCompile "org.springframework:spring-test:$springVersion"
+ testCompile "org.mockito:mockito-all:$mockitoVersion"
+ testCompile("javax.annotation:jsr250-api:1.0") { optional = true }
+ testCompile("com.thoughtworks.xstream:xstream:1.3") { optional = true }
}
-configure(javaprojects) {
- apply plugin: "java"
- apply plugin: "maven"
- apply plugin: 'eclipse' // `gradle eclipse` to generate .classpath/.project
- apply plugin: 'idea' // `gradle idea` to generate .ipr/.iml
- apply plugin: 'docbook'
- apply plugin: 'bundlor' // all core projects should be OSGi-compliant
+javaprojects = rootProject
- bundlor.useProjectProps = true
- [compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:-serial"]
-
- // Common dependencies
- dependencies {
- // Logging
- compile "org.slf4j:slf4j-api:$slf4jVersion"
- compile "org.slf4j:jcl-over-slf4j:$slf4jVersion"
- runtime "log4j:log4j:$log4jVersion"
- runtime "org.slf4j:slf4j-log4j12:$slf4jVersion"
- // Spring Framework
- compile("org.springframework:spring-core:$springVersion") {
- exclude module: "commons-logging"
- }
- compile "org.springframework:spring-beans:$springVersion"
- compile "org.springframework:spring-context:$springVersion"
- compile "org.springframework:spring-context-support:$springVersion"
- compile "org.springframework:spring-tx:$springVersion"
- // Jackson JSON Mapper
- compile "org.codehaus.jackson:jackson-mapper-asl:$jacksonVersion"
- // Testing
- testCompile "junit:junit:$junitVersion"
- testCompile "org.springframework:spring-test:$springVersion"
- testCompile "org.mockito:mockito-all:$mockitoVersion"
- }
-
- apply from: "$rootDir/maven.gradle"
-}
+sourceCompatibility = 1.6
+targetCompatibility = 1.6
+
+apply from: "$rootDir/maven.gradle"
ideaProject {
withXml { provider ->
@@ -122,9 +136,6 @@ task dist(type: Zip) {
include 'reference/**/*'
include 'api/**/*'
}
- into('dist') {
- from javaprojects.collect {project -> project.libsDir }
- }
}
doLast {
ant.checksum(file: archivePath, algorithm: 'SHA1', fileext: '.sha1')
@@ -137,4 +148,6 @@ task uploadDist(type: org.springframework.gradle.tasks.S3DistroUpload, dependsOn
archiveFile = dist.archivePath
projectKey = 'DATAKV'
projectName = 'Spring Data Key Value'
-}
\ No newline at end of file
+}
+
+defaultTasks 'clean', 'build'
\ No newline at end of file
diff --git a/docs/.classpath b/docs/.classpath
new file mode 100644
index 000000000..0e5f210c1
--- /dev/null
+++ b/docs/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/spring-data-keyvalue-core/.project b/docs/.project
similarity index 78%
rename from spring-data-keyvalue-core/.project
rename to docs/.project
index 145c84059..b14fc0d5c 100644
--- a/spring-data-keyvalue-core/.project
+++ b/docs/.project
@@ -1,6 +1,6 @@
- spring-data-core
+ spring-data-redis.docs
@@ -12,6 +12,7 @@
+ com.springsource.sts.gradle.core.natureorg.eclipse.jdt.core.javanature
diff --git a/docs/build.gradle b/docs/build.gradle
index ebdf04155..8c8c2156c 100644
--- a/docs/build.gradle
+++ b/docs/build.gradle
@@ -1,4 +1,3 @@
-import org.apache.tools.ant.filters.FixCrLfFilter
import org.apache.tools.ant.filters.ReplaceTokens
// -----------------------------------------------------------------------------
@@ -10,7 +9,6 @@ apply plugin: 'docbook'
assemble.dependsOn = ['api', 'docbook']
-
[docbookHtml, docbookFoPdf, docbookHtmlSingle]*.group = 'Documentation'
[docbookHtml, docbookFoPdf, docbookHtmlSingle]*.sourceFileName = 'index.xml'
[docbookHtml, docbookFoPdf, docbookHtmlSingle]*.sourceDirectory = new File(projectDir, 'src/reference/docbook')
@@ -46,7 +44,6 @@ task reference (type: Copy) {
dependsOn 'docbook'
description = "Builds aggregated DocBook"
group = "Documentation"
- logger.info("Version is " + version)
destinationDir = buildDir
with(refSpec)
}
@@ -71,9 +68,7 @@ task api(type: Javadoc) {
breakIterator = true
showFromProtected()
groups = [
- 'Spring Data Key Value Core': ['org.springframework.data.keyvalue*'],
- 'Spring Data Redis Support' : ['org.springframework.data.keyvalue.redis*'],
- 'Spring Data Riak Support' : ['org.springframework.data.keyvalue.riak*']
+ 'Spring Data Redis Support' : ['org.springframework.data.redis*'],
]
links = [
diff --git a/docs/src/api/javadoc.options b/docs/src/api/javadoc.options
index 04964ca74..432e5b85e 100644
--- a/docs/src/api/javadoc.options
+++ b/docs/src/api/javadoc.options
@@ -5,9 +5,9 @@
-quiet
-docfilessubdirs
-group "Spring Data Key Value Core" "org.springframework.data.keyvalue*"
--group "Spring Data Redis Support" "org.springframework.data.keyvalue.redis*"
+-group "Spring Data Redis Support" "org.springframework.data.redis*"
-group "Spring Data Riak Support" "org.springframework.data.keyvalue.riak*"
-link http://static.springframework.org/spring/docs/3.0.x/javadoc-api
-link http://download.oracle.com/javase/6/docs/api/
--exclude org.springframework.data.keyvalue.redis.config
+-exclude org.springframework.data.redis.config
diff --git a/docs/src/reference/docbook/reference/redis-messaging.xml b/docs/src/reference/docbook/reference/redis-messaging.xml
index 7bfbc8508..e7b21e9b7 100644
--- a/docs/src/reference/docbook/reference/redis-messaging.xml
+++ b/docs/src/reference/docbook/reference/redis-messaging.xml
@@ -15,8 +15,8 @@
listener containers that is used to create Message-Driven POJOs
(MDPs) and for synchronous reception, the RedisConnection contract.
- The package org.springframework.data.keyvalue.redis.connection and
- org.springframework.data.keyvalue.redis.listener provide
+ The package org.springframework.data.redis.connection and
+ org.springframework.data.redis.listener provide
the core functionality for using Redis messaging.
@@ -168,20 +168,20 @@ template.convertAndSend("hello!", "world");]]>
is displayed below:<!-- this is the Message Driven POJO (MDP) -->
-<bean id="messageListener" class="org.springframework.data.keyvalue.redis.listener.adapter.MessageListenerAdapter">
+<bean id="messageListener" class="org.springframework.data.redis.listener.adapter.MessageListenerAdapter">
<constructor-arg>
<bean class="redisexample.DefaultMessageDelegate"/>
</constructor-arg>
</bean>
<!-- and this is the message listener container... -->
-<bean id="redisContainer" class="org.springframework.data.keyvalue.redis.listener.RedisMessageListenerContainer">
+<bean id="redisContainer" class="org.springframework.data.redis.listener.RedisMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="messageListeners">
<!-- map of listeners and their associated topics (channels or/and patterns) -->
<map>
<entry key-ref="messageListener">
- <bean class="org.springframework.data.keyvalue.redis.listener.ChannelTopic">
+ <bean class="org.springframework.data.redis.listener.ChannelTopic">
<constructor-arg value="chatroom">
</bean>
</entry>
diff --git a/docs/src/reference/docbook/reference/redis.xml b/docs/src/reference/docbook/reference/redis.xml
index df2ece116..607dc2cca 100644
--- a/docs/src/reference/docbook/reference/redis.xml
+++ b/docs/src/reference/docbook/reference/redis.xml
@@ -46,7 +46,7 @@
One of the first tasks when using Redis and Spring is to connect to the store through the IoC container. To do that, a Java connector (or binding) is required;
currently SDKV has support for Jedis and JRedis. No matter the library one chooses, there only one set of SDKV API that one needs to use that behaves consistently
- across all connectors, namely the org.springframework.data.keyvalue.redis.connection package and its
+ across all connectors, namely the org.springframework.data.redis.connection package and its
RedisConnection and RedisConnectionFactory interfaces for working respectively for retrieving active
connection to Redis.
@@ -86,7 +86,7 @@
Configuring Jedis connectorJedis is one of the connectors supported by the Key Value module through the
- org.springframework.data.keyvalue.redis.connection.jedis package. In its simples form, the Jedis configuration looks as follow:
+ org.springframework.data.redis.connection.jedis package. In its simples form, the Jedis configuration looks as follow:
-
+ ]]>For production use however, one might want to tweak the settings such as the host or password:
@@ -107,7 +107,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
]]>
@@ -117,7 +117,7 @@
Configuring JRedis connectorJRedis is another popular, open-source connector supported by SDKV through the
- org.springframework.data.keyvalue.redis.connection.jredis package.
+ org.springframework.data.redis.connection.jredis package.
Since JRedis itself does not support (yet) Redis 2.x commands, SDKV uses an updated fork available
here.
@@ -130,7 +130,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
]]>
@@ -149,7 +149,7 @@
Configuring RJC connectorRJC is the third, open-source connector supported by SDKV through the
- org.springframework.data.keyvalue.redis.connection.rjc package.
+ org.springframework.data.redis.connection.rjc package.
Similar to the other connectors, a typical RJC configuration can looks like this:
@@ -160,7 +160,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
]]>
@@ -180,7 +180,7 @@
Working with Objects through RedisTemplate
- Most users are likely to use RedisTemplate and its coresponding package org.springframework.data.keyvalue.redis.core - the
+ Most users are likely to use RedisTemplate and its coresponding package org.springframework.data.redis.core - the
template is in fact the central class of the Redis module due to its rich feature set.
The template offers a high-level abstraction for Redis interaction - while RedisConnection offer low level methods that accept and return
binary values (byte arrays), the template takes care of serialization and connection management, freeing the user from dealing with such details.
@@ -256,7 +256,7 @@
Out of the box, RedisTemplate uses a Java-based serializer for most of its operations. This means that any object written or read by the template will be
serializer/deserialized through Java. The serialization mechanism can be easily changed on the template and the Redis module offers several implementations available in the
- org.springframework.data.keyvalue.redis.serializer package - see for more information.
+ org.springframework.data.redis.serializer package - see for more information.
Note that the template requires all keys to be non-null - values can be null as long as the underlying
serializer accepts them; read the javadoc of each serializer for more information.
@@ -270,11 +270,11 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-
...
@@ -314,10 +314,10 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-
...
@@ -355,7 +355,7 @@
From the framework perspective, the data stored in Redis are just bytes. While Redis itself supports various types, for the most part these refer to the way the data is stored
rather then what it represents. It is up to the user to decide whether the information gets translated into Strings or any other objects. The conversion between the user (custom)
types and raw data (and vice-versa) is handled in SDKV Redis through the RedisSerializer interface
- (package org.springframework.data.keyvalue.redis.serializer) which as the name implies, takes care of the serialization process. Multiple implementations are
+ (package org.springframework.data.redis.serializer) which as the name implies, takes care of the serialization process. Multiple implementations are
available out of the box, two of which have been already mentioned before in this documentation: the StringRedisSerializer and
the JdkSerializationRedisSerializer. However one can use OxmSerializer for Object/XML mapping through Spring 3
OXM support or JacksonJsonRedisSerializer for storing
@@ -368,7 +368,7 @@
Support Classes
- Package org.springframework.data.keyvalue.redis.support offers various reusable components that rely on Redis as a backing store. Curently the package contains
+ Package org.springframework.data.redis.support offers various reusable components that rely on Redis as a backing store. Curently the package contains
various JDK-based interface implementations on top of Redis such as atomic
counters and JDK Collections.
@@ -385,7 +385,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
-
+
diff --git a/gradle.properties b/gradle.properties
index f5a5999b1..97bec7ca3 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -12,9 +12,22 @@ jacksonVersion = 1.6.4
junitVersion = 4.8.1
mockitoVersion = 1.8.5
+# Drivers
+jedisVersion = 2.0.0
+jredisVersion = 03122010
+rjcVersion= 0.6.4
+
+# Manifest properties
+
+## OSGi ranges
+spring.range = "[3.0.0, 4.0.0)"
+jedis.range = "[2.0.0, 2.0.0]"
+jackson.range = "[1.6, 2.0.0)"
+rjc.range = "[0.6.4, 0.6.4]"
# --------------------
# Project wide version
# --------------------
springDataKeyValueVersion=1.0.0.BUILD-SNAPSHOT
-version = 'springDataKeyValueVersion'
\ No newline at end of file
+version = 'springDataKeyValueVersion'
+
diff --git a/settings.gradle b/settings.gradle
index 78739438f..bb02d8dfa 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,8 +1,5 @@
-rootProject.name = 'spring-data-key-value'
+rootProject.name = 'spring-data-redis'
include 'docs'
-include "spring-data-keyvalue-core",
- "spring-data-redis",
- "spring-data-riak"
-
+
docs = findProject(':docs')
\ No newline at end of file
diff --git a/spring-data-keyvalue-core/.classpath b/spring-data-keyvalue-core/.classpath
deleted file mode 100644
index e49979c1c..000000000
--- a/spring-data-keyvalue-core/.classpath
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-data-keyvalue-core/.settings/org.eclipse.jdt.core.prefs b/spring-data-keyvalue-core/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index f924903e3..000000000
--- a/spring-data-keyvalue-core/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-#Thu Apr 21 21:26:44 EEST 2011
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.source=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
diff --git a/spring-data-keyvalue-core/build.gradle b/spring-data-keyvalue-core/build.gradle
deleted file mode 100644
index e69de29bb..000000000
diff --git a/spring-data-keyvalue-core/src/main/java/org/springframework/data/keyvalue/UncategorizedKeyvalueStoreException.java b/spring-data-keyvalue-core/src/main/java/org/springframework/data/keyvalue/UncategorizedKeyvalueStoreException.java
deleted file mode 100644
index c65d6ac1f..000000000
--- a/spring-data-keyvalue-core/src/main/java/org/springframework/data/keyvalue/UncategorizedKeyvalueStoreException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2010 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.data.keyvalue;
-
-import org.springframework.dao.UncategorizedDataAccessException;
-
-public class UncategorizedKeyvalueStoreException extends UncategorizedDataAccessException {
-
- public UncategorizedKeyvalueStoreException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
-}
diff --git a/spring-data-keyvalue-core/template.mf b/spring-data-keyvalue-core/template.mf
deleted file mode 100644
index d553c5f67..000000000
--- a/spring-data-keyvalue-core/template.mf
+++ /dev/null
@@ -1,19 +0,0 @@
-Bundle-SymbolicName: org.springframework.data.keyvalue
-Bundle-Name: Spring data Key-Value
-Bundle-Vendor: SpringSource
-Bundle-ManifestVersion: 2
-Import-Package:
- sun.reflect;version="0";resolution:=optional
-Import-Template:
- org.springframework.beans.*;version="[3.0.0, 4.0.0)",
- org.springframework.core.*;version="[3.0.0, 4.0.0)",
- org.springframework.dao.*;version="[3.0.0, 4.0.0)",
- org.springframework.util.*;version="[3.0.0, 4.0.0)",
- org.springframework.data.core.*;version="[1.0.0, 2.0.0)",
- org.springframework.data.core.*;version="[1.0.0, 2.0.0)",
- org.springframework.data.persistence.*;version="[1.0.0, 2.0.0)",
- org.aopalliance.*;version="[1.0.0, 2.0.0)";resolution:=optional,
- org.apache.commons.logging.*;version="[1.1.1, 2.0.0)",
- org.w3c.dom.*;version="0"
-
-
diff --git a/spring-data-redis/.classpath b/spring-data-redis/.classpath
deleted file mode 100644
index 3848cd547..000000000
--- a/spring-data-redis/.classpath
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/spring-data-redis/.gitignore b/spring-data-redis/.gitignore
deleted file mode 100644
index 7ee4e668b..000000000
--- a/spring-data-redis/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-
-*.log
\ No newline at end of file
diff --git a/spring-data-redis/.project b/spring-data-redis/.project
deleted file mode 100644
index 7ab2483ad..000000000
--- a/spring-data-redis/.project
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
- spring-data-redis
-
-
-
- org.eclipse.jdt.core.javanature
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
diff --git a/spring-data-redis/build.gradle b/spring-data-redis/build.gradle
deleted file mode 100644
index cd6427bf6..000000000
--- a/spring-data-redis/build.gradle
+++ /dev/null
@@ -1,17 +0,0 @@
-repositories {
- mavenRepo name: "ext-snapshots", urls: "http://springframework.svn.sourceforge.net/svnroot/springframework/repos/repo-ext/"
-}
-
-dependencies {
- compile project(":spring-data-keyvalue-core")
- compile "redis.clients:jedis:$jedisVersion"
- compile("org.jredis:jredis-anthonylauzon:$jredisVersion") { optional = true }
- compile("org.idevlab:rjc:$rjcVersion") { optional = true }
- compile("org.springframework:spring-oxm:$springVersion") { optional = true }
- compile("commons-beanutils:commons-beanutils-core:1.8.3") { optional = true }
- testCompile("javax.annotation:jsr250-api:1.0") { optional = true }
- testCompile("com.thoughtworks.xstream:xstream:1.3") { optional = true }
-}
-
-sourceCompatibility = 1.6
-targetCompatibility = 1.6
\ No newline at end of file
diff --git a/spring-data-redis/gradle.properties b/spring-data-redis/gradle.properties
deleted file mode 100644
index 74a43fc38..000000000
--- a/spring-data-redis/gradle.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-# Dependencies properties
-jedisVersion = 2.0.0
-jredisVersion = 03122010
-rjcVersion= 0.6.4
-
-
-# Manifest properties
-
-## OSGi ranges
-spring.range = "[3.0.0, 4.0.0)"
-jedis.range = "[2.0.0, 2.0.0]"
-jackson.range = "[1.6, 2.0.0)"
-rjc.range = "[0.6.4, 0.6.4]"
diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/core/query/package-info.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/core/query/package-info.java
deleted file mode 100644
index 3a0c87b28..000000000
--- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/core/query/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * Query package for Redis template.
- */
-package org.springframework.data.keyvalue.redis.core.query;
-
diff --git a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/support/collections/package-info.java b/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/support/collections/package-info.java
deleted file mode 100644
index e00eeab04..000000000
--- a/spring-data-redis/src/main/java/org/springframework/data/keyvalue/redis/support/collections/package-info.java
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * Package providing implementations for most of the {@code java.util} collections on top of Redis.
- *
- * For indexed collections, such as {@link java.util.List}, {@link java.util.Queue} or {@link java.util.Deque}
- * consider {@link org.springframework.data.keyvalue.redis.support.collections.RedisList}.
- * For collections without duplicates the obvious candidate is {@link org.springframework.data.keyvalue.redis.support.collections.RedisSet}. Use
- * {@link org.springframework.data.keyvalue.redis.support.collections.RedisZSet} if a
- * certain order is required.
- * Lastly, for key/value associations {@link org.springframework.data.keyvalue.redis.support.collections.RedisMap} providing a Map-like abstraction on top of a Redis hash.
- */
-package org.springframework.data.keyvalue.redis.support.collections;
-
diff --git a/spring-data-redis/src/main/resources/META-INF/spring.schemas b/spring-data-redis/src/main/resources/META-INF/spring.schemas
deleted file mode 100644
index fea927201..000000000
--- a/spring-data-redis/src/main/resources/META-INF/spring.schemas
+++ /dev/null
@@ -1,2 +0,0 @@
-http\://www.springframework.org/schema/redis/spring-redis-1.0.xsd=org/springframework/data/keyvalue/redis/config/spring-redis-1.0.xsd
-http\://www.springframework.org/schema/redis/spring-redis.xsd=org/springframework/data/keyvalue/redis/config/spring-redis-1.0.xsd
\ No newline at end of file
diff --git a/spring-data-riak/README.md b/spring-data-riak/README.md
deleted file mode 100644
index 33f5303de..000000000
--- a/spring-data-riak/README.md
+++ /dev/null
@@ -1,107 +0,0 @@
-# Spring Data support for Riak
-
-The spring-data-riak module strives to make working with Riak painless by providing
-the developer several different ways to easily access or store data using the Riak
-Key/Value store.
-
-## Recent Changes:
-
-* 12/22/2010: Added async Map/Reduce support to AsyncRiakTemplate and Groovy DSL
-* 12/20/2010: AsyncRiakTemplate and Groovy DSL
-
-### Groovy DSL
-
-One cool new feature just added is a Groovy DSL for data access using SDKV/Riak:
-
- def riak = new RiakBuilder(riakTemplate)
- def result = null
-
- riak.set(bucket: "test", key: "test", qos: [dw: "all"], value: obj, wait: 3000L) {
- completed(when: { it.integer == 12 }) { result = it.test }
- completed { result = "otherwise" }
-
- failed { it.printStackTrace() }
- }
-
-The Groovy DSL will respond to the following methods:
-
-* set
-* setAsBytes
-* put
-* get
-* getAsBytes
-* getAsType
-* containsKey
-* delete
-* foreach
-
-Each completed or failed closure can be accompanied by a "guard" closure. For example,
-to process an entry differently, based on the type:
-
- riak.get(bucket: "test", key: "test") {
- completed(when: { it instanceof Map }) { processMap(it) }
- completed(when: { it instanceof String }) { processString(it) }
- completed(when: { it instanceof byte[] }) { processBytes(it) }
- completed { result = "otherwise" }
-
- failed { it.printStackTrace() }
- }
-
-You can nest them, of course. To insert data and then delete all keys from a bucket:
-
- riak {
- put(bucket: "test", value: [test: "value 1"])
- put(bucket: "test", value: [test: "value 2"])
- put(bucket: "test", value: [test: "value 3"])
-
- foreach(bucket: "test") {
- completed { v, meta ->
- delete(bucket: meta.bucket, key: meta.key)
- }
- failed { it.printStackTrace() }
- }
- }
-
-You can also use a "default" bucket by nesting your operations inside an arbitrary block. In
-the example below, the `test{}` closure sets a default bucket of "test" and all the
-subsequent operations check for this if a `bucket` is not specified (you can override the
-default by specifying a `bucket` property on the operation itself).
-
-The Groovy DSL for Riak now has Map/Reduce support. You build up a Map/Reduce job using the
-closures shown in the example. You can pass static arguments to the phases, as well. You can
-also specify a `wait` timeout on the `mapreduce` closure, just like with the other operations.
-
- riak {
- test {
- put(value: [test: "value"])
- put(value: [test: "value"])
- put(value: [test: "value"])
- put(value: [test: "value"])
-
- mapreduce {
- query {
- map(arg: [test: "arg", alist: [1, 2, 3, 4]]) {
- source "function(v){ return [1]; }"
- }
- reduce {
- source "function(v){ return Riak.reduceSum(v); }"
- }
- }
- completed { println "result $it" }
- failed { it.printStackTrace() }
- }
- }
- }
-
-Some things to note here:
-
-* The Groovy DSL utilizes the new AsyncRiakTemplate, so all closure calls happen
- asynchronously. By default, the operation will block indefinitely. To not block at all
- and continue on immediately, set the `wait` to `0`. To block until a specified timeout,
- set the `wait` to the number of milliseconds to wait for the operation to complete before
- timing out and throwing an exception.
-* Callbacks are defined as either `completed` or `failed` closures. In addition to the
- closure, you can define a "guard" closure, which is called before the main closure and
- should return non-null or Boolean `true` if the closure should be executed or null or
- Boolean `false` if the closure is to be skipped. This functionality is inspired by the
- use of [the guard expression in Erlang case statements](http://en.wikibooks.org/wiki/Erlang_Programming/guards).
\ No newline at end of file
diff --git a/spring-data-riak/build.gradle b/spring-data-riak/build.gradle
deleted file mode 100644
index 0610d27c2..000000000
--- a/spring-data-riak/build.gradle
+++ /dev/null
@@ -1,9 +0,0 @@
-dependencies {
- compile project(":spring-data-keyvalue-core")
- compile "org.codehaus.groovy:groovy-all:1.7.6"
- compile "javax.mail:mail:1.4.1"
- compile "javax.activation:activation:1.1.1"
- compile "commons-cli:commons-cli:1.2"
-
- compile "org.springframework:spring-web:$springVersion"
-}
diff --git a/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/DataStoreConnectionFailureException.java b/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/DataStoreConnectionFailureException.java
deleted file mode 100644
index b9c56ad5c..000000000
--- a/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/DataStoreConnectionFailureException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2010 by J. Brisbin
- * Portions (c) 2010 by NPC International, Inc. or the
- * original author(s).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.data.keyvalue.riak;
-
-import org.springframework.dao.DataAccessResourceFailureException;
-
-/**
- * @author J. Brisbin
- */
-public class DataStoreConnectionFailureException extends DataAccessResourceFailureException {
-
- public static final long serialVersionUID = 1L;
-
- public DataStoreConnectionFailureException(String msg) {
- super(msg);
- }
-
- public DataStoreConnectionFailureException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
-}
diff --git a/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/DataStoreOperationException.java b/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/DataStoreOperationException.java
deleted file mode 100644
index 9dfe893a2..000000000
--- a/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/DataStoreOperationException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2010 by J. Brisbin
- * Portions (c) 2010 by NPC International, Inc. or the
- * original author(s).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.data.keyvalue.riak;
-
-import org.springframework.dao.DataAccessException;
-
-/**
- * @author J. Brisbin
- */
-public class DataStoreOperationException extends DataAccessException {
-
- public static final long serialVersionUID = 1L;
-
- public DataStoreOperationException(String msg) {
- super(msg);
- }
-
- public DataStoreOperationException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
-}
diff --git a/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/convert/KeyValueStoreMetaData.java b/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/convert/KeyValueStoreMetaData.java
deleted file mode 100644
index 40f8d66f5..000000000
--- a/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/convert/KeyValueStoreMetaData.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2010 by J. Brisbin
- * Portions (c) 2010 by NPC International, Inc. or the
- * original author(s).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.data.keyvalue.riak.convert;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Specify the bucket in which to store the annotated object, overriding the
- * default classname method of deriving bucket name.
- *
- * @author J. Brisbin
- */
-@Retention(RetentionPolicy.RUNTIME)
-public @interface KeyValueStoreMetaData {
-
- /**
- * The bucket in which to store an instance of this object.
- *
- * @return
- */
- String bucket();
-
- /**
- * The media type in which to covert and store this object.
- *
- * @return
- */
- String mediaType() default "application/json";
-
-}
diff --git a/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/core/AbstractRiakTemplate.java b/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/core/AbstractRiakTemplate.java
deleted file mode 100644
index 85b50f641..000000000
--- a/spring-data-riak/src/main/java/org/springframework/data/keyvalue/riak/core/AbstractRiakTemplate.java
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- * Copyright (c) 2010 by J. Brisbin
- * Portions (c) 2010 by NPC International, Inc. or the
- * original author(s).
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.data.keyvalue.riak.core;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codehaus.groovy.runtime.GStringImpl;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.ser.CustomSerializerFactory;
-import org.codehaus.jackson.map.ser.ToStringSerializer;
-import org.springframework.beans.factory.BeanClassLoaderAware;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.convert.ConversionService;
-import org.springframework.core.convert.support.ConversionServiceFactory;
-import org.springframework.data.keyvalue.riak.DataStoreOperationException;
-import org.springframework.data.keyvalue.riak.convert.KeyValueStoreMetaData;
-import org.springframework.data.keyvalue.riak.util.Ignore404sErrorHandler;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpInputMessage;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
-import org.springframework.http.client.ClientHttpRequestFactory;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
-import org.springframework.util.Assert;
-import org.springframework.util.ClassUtils;
-import org.springframework.util.StringUtils;
-import org.springframework.web.client.DefaultResponseErrorHandler;
-import org.springframework.web.client.ResourceAccessException;
-import org.springframework.web.client.RestTemplate;
-import org.springframework.web.client.support.RestGatewaySupport;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.concurrent.ConcurrentSkipListMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Base class for RiakTemplates that defines basic behaviour common to both kinds of templates
- * (Key/Value and Bucket/Key/Value).
- *
- * @author J. Brisbin
- */
-public abstract class AbstractRiakTemplate extends RestGatewaySupport implements InitializingBean, BeanClassLoaderAware {
-
- protected static final String RIAK_META_CLASSNAME = "X-Riak-Meta-ClassName";
- protected static final String RIAK_VCLOCK = "X-Riak-Vclock";
-
- /**
- * Regex used to extract host, port, and prefix from the given URI.
- */
- protected static final Pattern prefix = Pattern.compile(
- "http[s]?://(\\S+):([0-9]+)/(\\S+)/\\{bucket\\}(\\S+)");
- /**
- * Do we need to handle Groovy strings in the Jackson JSON processor?
- */
- protected final boolean groovyPresent = ClassUtils.isPresent(
- "org.codehaus.groovy.runtime.GStringImpl",
- getClass().getClassLoader());
- /**
- * For getting a java.util.Date from the Last-Modified header.
- */
- protected static SimpleDateFormat httpDate = new SimpleDateFormat(
- "EEE, d MMM yyyy HH:mm:ss z");
-
- protected final Log log = LogFactory.getLog(getClass());
-
- /**
- * Client ID used by Riak to correlate updates.
- */
- protected final String RIAK_CLIENT_ID = getClass().getName() + "/1.0";
-
- /**
- * For converting objects to/from other kinds of objects.
- */
- protected ConversionService conversionService = ConversionServiceFactory
- .createDefaultConversionService();
- /**
- * For caching objects based on ETags.
- */
- protected ConcurrentSkipListMap> cache = new ConcurrentSkipListMap>();
- /**
- * Whether or not to use the ETag-based cache.
- */
- protected boolean useCache = true;
- /**
- * The URI to use inside the RestTemplate.
- */
- protected String defaultUri = "http://localhost:8098/riak/{bucket}/{key}";
- /**
- * The URI for the Riak Map/Reduce API.
- */
- protected String mapReduceUri = "http://localhost:8098/mapred";
- /**
- * A list of resolvers to turn a single object into a {@link BucketKeyPair}.
- */
- protected List bucketKeyResolvers = new ArrayList();
- /**
- * The default QosParameters to use for all operations through this template.
- */
- protected QosParameters defaultQosParameters = null;
- /**
- * {@link java.util.concurrent.ExecutorService} to use for running asynchronous jobs.
- */
- protected ExecutorService workerPool = Executors.newCachedThreadPool();
- /**
- * Default type to use when trying to deserialize objects and we can't otherwise tell what to
- * do.
- */
- protected Class> defaultType = String.class;
- /**
- * ClassLoader to use for saving/loading objects using the automatic converters.
- */
- protected ClassLoader classLoader = null;
-
- /**
- * Take all the defaults.
- */
- public AbstractRiakTemplate() {
- setRestTemplate(new RestTemplate());
- }
-
- /**
- * Use the specified {@link org.springframework.http.client.ClientHttpRequestFactory}.
- *
- * @param requestFactory
- */
- public AbstractRiakTemplate(ClientHttpRequestFactory requestFactory) {
- super(requestFactory);
- setRestTemplate(new RestTemplate());
- }
-
- public ConversionService getConversionService() {
- return conversionService;
- }
-
- /**
- * Specify the conversion service to use.
- *
- * @param conversionService
- */
- public void setConversionService(ConversionService conversionService) {
- this.conversionService = conversionService;
- }
-
- public String getDefaultUri() {
- return defaultUri;
- }
-
- public void setDefaultUri(String defaultUri) {
- this.defaultUri = defaultUri;
- }
-
- public String getMapReduceUri() {
- return mapReduceUri;
- }
-
- public void setMapReduceUri(String mapReduceUri) {
- this.mapReduceUri = mapReduceUri;
- }
-
- public boolean isUseCache() {
- return useCache;
- }
-
- public void setUseCache(boolean useCache) {
- this.useCache = useCache;
- }
-
- public QosParameters getDefaultQosParameters() {
- return defaultQosParameters;
- }
-
- public void setDefaultQosParameters(QosParameters defaultQosParameters) {
- this.defaultQosParameters = defaultQosParameters;
- }
-
- public ExecutorService getWorkerPool() {
- return workerPool;
- }
-
- public void setWorkerPool(ExecutorService workerPool) {
- this.workerPool = workerPool;
- }
-
- public void setIgnoreNotFound(boolean b) {
- if (b) {
- getRestTemplate().setErrorHandler(new Ignore404sErrorHandler());
- } else {
- if (getRestTemplate().getErrorHandler() instanceof Ignore404sErrorHandler) {
- getRestTemplate().setErrorHandler(new DefaultResponseErrorHandler());
- }
- }
- }
-
- public boolean getIgnoreNotFound() {
- return (getRestTemplate().getErrorHandler() instanceof Ignore404sErrorHandler);
- }
-
- /**
- * Get the default type to use if none can be inferred.
- *
- * @return
- */
- public Class> getDefaultType() {
- return defaultType;
- }
-
- /**
- * Set the default type to use if none can be inferred.
- *
- * @param defaultType
- */
- public void setDefaultType(Class> defaultType) {
- this.defaultType = defaultType;
- }
-
- public void setBeanClassLoader(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- public String getHost() {
- Matcher m = prefix.matcher(defaultUri);
- if (m.matches()) {
- return m.group(1);
- }
- return "localhost";
- }
-
- public Integer getPort() {
- Matcher m = prefix.matcher(defaultUri);
- if (m.matches()) {
- return new Integer(m.group(2));
- }
- return 8098;
- }
-
- /**
- * Extract the prefix from the URI for use in creating links.
- *
- * @return
- */
- public String getPrefix() {
- Matcher m = prefix.matcher(defaultUri);
- if (m.matches()) {
- return "/" + m.group(3);
- }
- return "/riak";
- }
-
- public void afterPropertiesSet() throws Exception {
- Assert.notNull(conversionService,
- "Must specify a valid ConversionService.");
-
- List> converters = getRestTemplate().getMessageConverters();
- ObjectMapper mapper = new ObjectMapper();
- CustomSerializerFactory fac = new CustomSerializerFactory();
- if (groovyPresent) {
- // Native conversion for Groovy GString objects
- fac.addSpecificMapping(GStringImpl.class, ToStringSerializer.instance);
- }
- mapper.setSerializerFactory(fac);
- for (HttpMessageConverter converter : converters) {
- if (converter instanceof MappingJacksonHttpMessageConverter) {
- ((MappingJacksonHttpMessageConverter) converter).setObjectMapper(
- mapper);
- }
- }
- }
-
- /*----------------- Utilities -----------------*/
-
- @SuppressWarnings({"unchecked"})
- protected BucketKeyPair resolveBucketKeyPair(Object key, Object val) {
- BucketKeyResolver resolver = null;
- for (BucketKeyResolver r : bucketKeyResolvers) {
- if (r.canResolve(key)) {
- resolver = r;
- break;
- }
- }
- if (null == resolver) {
- resolver = new SimpleBucketKeyResolver();
- }
-
- BucketKeyPair bucketKeyPair = resolver.resolve(key);
- if (null == bucketKeyPair.getBucket() && null != val) {
- // No bucket specified, check for an annotation that specified bucket name.
- Annotation meta = (val instanceof Class ? (Class) val : val.getClass()).getAnnotation(
- org.springframework.data.keyvalue.riak.convert.KeyValueStoreMetaData.class);
- if (null != meta) {
- String bucket = ((KeyValueStoreMetaData) meta).bucket();
- if (null != bucket) {
- return new SimpleBucketKeyPair(bucket,
- bucketKeyPair.getKey());
- }
- }
- }
- return bucketKeyPair;
- }
-
- protected MediaType extractMediaType(Object value) {
- MediaType mediaType = (value instanceof byte[] ? MediaType.APPLICATION_OCTET_STREAM : MediaType.APPLICATION_JSON);
- if (null != value && value.getClass().getAnnotations().length > 0) {
- KeyValueStoreMetaData meta = value.getClass()
- .getAnnotation(KeyValueStoreMetaData.class);
- if (null != meta) {
- // Use the media type specified on the annotation.
- mediaType = MediaType.parseMediaType(meta.mediaType());
- }
- }
- return mediaType;
- }
-
- protected RiakMetaData extractMetaData(HttpHeaders headers) throws
- IOException {
- Map props = new LinkedHashMap();
- for (Map.Entry> entry : headers.entrySet()) {
- List val = entry.getValue();
- Object prop = (1 == val.size() ? val.get(0) : val);
- try {
- if (entry.getKey().equals("Last-Modified") || entry.getKey()
- .equals("Date")) {
- prop = httpDate.parse(val.get(0));
- }
- } catch (ParseException e) {
- log.error(e.getMessage(), e);
- }
-
- if (entry.getKey().equals("Link")) {
- List links = new ArrayList();
- for (String link : entry.getValue()) {
- String[] parts = link.split(",");
- for (String part : parts) {
- String s = part.replaceAll("<(.+)>; rel=\"(\\S+)\"[,]?", "").trim();
- if (!"".equals(s)) {
- links.add(s);
- }
- }
- }
- props.put("Link", links);
- } else {
- props.put(entry.getKey().toString(), prop);
- }
- }
- props.put("ETag", headers.getETag());
- RiakMetaData meta = new RiakMetaData(headers.getContentType(), props);
-
- return meta;
- }
-
- @SuppressWarnings({"unchecked"})
- protected RiakValue extractValue(final ResponseEntity> response, Class> origType,
- Class requiredType) throws
- IOException {
- if (response.hasBody()) {
- RiakMetaData meta = extractMetaData(response.getHeaders());
- Object o = response.getBody();
- if (!origType.equals(requiredType)) {
- if (conversionService.canConvert(origType, requiredType)) {
- o = conversionService.convert(o, requiredType);
- } else {
- if (o instanceof byte[] || o instanceof String) {
- // Peek inside, see if it's a string of something we recognize
- String s = (o instanceof byte[] ? new String((byte[]) o) : (String) o);
- if (s.charAt(0) == '{' || s.charAt(0) == '[') {
- // Looks like it might be a JSON string. Use the JSON converter
- for (HttpMessageConverter conv : getRestTemplate().getMessageConverters()) {
- if (conv instanceof MappingJacksonHttpMessageConverter) {
- o = conv.read(requiredType, new HttpInputMessage() {
- public InputStream getBody() throws IOException {
- Object body = response.getBody();
- return new ByteArrayInputStream(
- (body instanceof byte[] ? (byte[]) body : ((String) body)
- .getBytes()));
- }
-
- public HttpHeaders getHeaders() {
- return response.getHeaders();
- }
- });
- break;
- }
- }
-
- }
- } else {
- throw new DataStoreOperationException(
- "Cannot convert object of type " + origType + " to type " + requiredType);
- }
- }
- }
- return new RiakValue((T) o, meta);
- }
- return null;
- }
-
- @SuppressWarnings({"unchecked"})
- protected T checkCache(K key, Class requiredType) {
- BucketKeyPair bucketKeyPair = resolveBucketKeyPair(key, requiredType);
- RiakValue> obj = cache.get(bucketKeyPair);
- if (null != obj) {
- String bucketName = (null != bucketKeyPair.getBucket() ? bucketKeyPair.getBucket()
- .toString() : requiredType.getName());
- RestTemplate restTemplate = getRestTemplate();
- try {
- HttpHeaders resp = restTemplate.headForHeaders(defaultUri,
- bucketName,
- bucketKeyPair.getKey());
- if (!obj.getMetaData()
- .getProperties()
- .get("ETag")
- .toString()
- .equals(resp.getETag())) {
- obj = null;
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Returning CACHED object: " + obj);
- }
- }
- } catch (ResourceAccessException ignored) {
- return null;
- }
- }
-
- if (null != obj && obj.getClass() == requiredType) {
- return (T) obj.get();
- } else {
- return null;
- }
- }
-
- /**
- * Get a string that represents the QOS parameters, taken either from the specified object or
- * from the template defaults.
- *
- * @param qosParams
- * @return
- */
- protected String extractQosParameters(QosParameters qosParams) {
- List params = new LinkedList();
- if (null != qosParams.getReadThreshold()) {
- params.add(String.format("r=%s", qosParams.