commit 23e31f3a88f6611ab553ac5d6ec62bea1389d841 Author: trisberg Date: Wed Jul 21 14:48:12 2010 -0400 starting Redis common abstractions diff --git a/.classpath b/.classpath new file mode 100644 index 000000000..1179fbd4e --- /dev/null +++ b/.classpath @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..b83d22266 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/.project b/.project new file mode 100644 index 000000000..4d06a21ca --- /dev/null +++ b/.project @@ -0,0 +1,13 @@ + + datastore-keyvalue + + + + + org.eclipse.jdt.core.javabuilder + + + + org.eclipse.jdt.core.javanature + + \ No newline at end of file diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..2554ff467 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Tue Jul 20 17:19:08 EDT 2010 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..14d157550 --- /dev/null +++ b/pom.xml @@ -0,0 +1,117 @@ + + + 4.0.0 + org.springframework.datastore + datastore-keyvalue + Spring Datastore Document + jar + 1.0.0.CI-SNAPSHOT + + + UTF-8 + 3.0.0.RELEASE + 1.6.0 + + + + + junit + junit + 4.8.1 + test + + + + log4j + log4j + 1.2.15 + + + + javax.mail + mail + + + javax.jms + jms + + + com.sun.jdmk + jmxtools + + + com.sun.jmx + jmxri + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.slf4j + slf4j-log4j12 + ${slf4j.version} + + + + + org.jredis + jredis-core-all + a.0-SNAPSHOT + + + + + org.springframework + org.springframework.core + ${spring.version} + + + org.springframework + org.springframework.test + ${spring.version} + test + + + org.springframework + org.springframework.context + ${spring.version} + + + org.springframework + org.springframework.transaction + ${spring.version} + + + + org.springframework.data + data-commons + 1.0.0.CI-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.5 + 1.5 + + + + + + \ No newline at end of file diff --git a/src/main/java/org/springframework/datastore/keyvalue/redis/RedisConnectionFactory.java b/src/main/java/org/springframework/datastore/keyvalue/redis/RedisConnectionFactory.java new file mode 100644 index 000000000..837d6dc20 --- /dev/null +++ b/src/main/java/org/springframework/datastore/keyvalue/redis/RedisConnectionFactory.java @@ -0,0 +1,55 @@ +/* + * 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.datastore.keyvalue.redis; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.datastore.core.DatastoreConnectionFactory; + +import org.jredis.JRedis; +import org.jredis.ri.alphazero.JRedisClient; + +/** + * Convenient factory for configuring Redis. + * + * @author Thomas Risberg + * @since 1.0 + */ +public class RedisConnectionFactory implements DatastoreConnectionFactory, InitializingBean { + + /** + * Logger, available to subclasses. + */ + protected final Log logger = LogFactory.getLog(getClass()); + + + public RedisConnectionFactory() { + super(); + } + + public void afterPropertiesSet() throws Exception { + // apply defaults - convenient when used to configure for tests + // in an application context + } + + public JRedis getConnection() { + return new JRedisClient(); + } + +} diff --git a/src/main/java/org/springframework/datastore/keyvalue/redis/RedisDatastoreTemplate.java b/src/main/java/org/springframework/datastore/keyvalue/redis/RedisDatastoreTemplate.java new file mode 100644 index 000000000..8db0753f4 --- /dev/null +++ b/src/main/java/org/springframework/datastore/keyvalue/redis/RedisDatastoreTemplate.java @@ -0,0 +1,27 @@ +package org.springframework.datastore.keyvalue.redis; + + +import java.util.List; + +import org.jredis.JRedis; +import org.springframework.data.core.DataMapper; +import org.springframework.data.core.QueryDefinition; +import org.springframework.datastore.core.AbstractDatastoreTemplate; + +public class RedisDatastoreTemplate extends AbstractDatastoreTemplate { + + + public RedisDatastoreTemplate() { + super(); + setDatastoreConnectionFactory(new RedisConnectionFactory()); + } + + + @Override + public List query(QueryDefinition arg0, DataMapper arg1) { + return null; + } + + + +}