INTEXT-36 - Cleanup

* Convert spaces to tabs
* Upgrade to Gradle 1.5
* Change Group Id to 'org.springframework.integration'
* Add Sonar Runner plugin
* Reduce Sonar warnings
* Ensure ASL license header is present in all source files
* Fix XSD documentation not showing up in STS
This commit is contained in:
Gunnar Hillert
2013-04-02 16:14:23 -04:00
parent 1d2a5b5f06
commit 28759a6116
28 changed files with 1079 additions and 1041 deletions

View File

@@ -1,4 +1,4 @@
description = 'Spring Integration Voldemort Adapter'
description = 'Spring Integration Voldemort Support'
buildscript {
repositories {
@@ -14,7 +14,7 @@ apply from: "${rootProject.projectDir}/publish-maven.gradle"
apply plugin: 'eclipse'
apply plugin: 'idea'
group = 'org.springframework.integration.voldemort'
group = 'org.springframework.integration'
repositories {
maven { url 'http://repo.springsource.org/libs-milestone' }
@@ -100,6 +100,7 @@ reference {
}
apply plugin: 'sonar'
apply plugin: 'sonar-runner'
sonar {
@@ -262,5 +263,5 @@ task dist(dependsOn: assemble) {
task wrapper(type: Wrapper) {
description = 'Generates gradlew[.bat] scripts'
gradleVersion = '1.3'
gradleVersion = '1.5'
}

View File

@@ -1,6 +1,6 @@
#Wed Sep 05 13:34:36 EDT 2012
#Tue Apr 02 00:18:40 EDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.1-bin.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-1.5-bin.zip

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
##############################################################################
##
@@ -61,9 +61,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -101,7 +101,7 @@ if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT"
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

View File

@@ -1,90 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -1,65 +1,65 @@
/*
* Copyright 2002-2013 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.integration.voldemort.config.xml;
import org.springframework.beans.factory.config.TypedStringValue;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.ExpressionFactoryBean;
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.integration.voldemort.outbound.VoldemortStoringMessageHandler;
import org.w3c.dom.Element;
/**
* Parses Voldemort outbound adapter XML definition.
*
* @author Lukasz Antoniak
* @since 1.0
*/
public class VoldemortOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {
/**
* Produces "int-voldemort:outbound-channel-adapter" bean definition.
* <p />
* {@inheritDoc}
*/
@Override
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition( VoldemortStoringMessageHandler.class );
VoldemortParserUtils.processCommonAttributes( element, builder );
final boolean hasKey = element.hasAttribute( VoldemortParserUtils.STORE_KEY );
final boolean hasKeyExpression = element.hasAttribute( VoldemortParserUtils.STORE_KEY_EXPRESSION );
if ( hasKey && hasKeyExpression ) {
parserContext.getReaderContext().error( "At most one of '" + VoldemortParserUtils.STORE_KEY
+ "' or '" + VoldemortParserUtils.STORE_KEY_EXPRESSION + "' is allowed.", element );
}
if ( hasKey ) {
builder.addPropertyValue(
VoldemortParserUtils.KEY_PROPERTY,
new TypedStringValue( element.getAttribute( VoldemortParserUtils.STORE_KEY ) )
);
}
if ( hasKeyExpression ) {
RootBeanDefinition expressionDef = new RootBeanDefinition( ExpressionFactoryBean.class );
expressionDef.getConstructorArgumentValues().addGenericArgumentValue( element.getAttribute( VoldemortParserUtils.STORE_KEY_EXPRESSION ) );
builder.addPropertyValue( VoldemortParserUtils.KEY_EXPRESSION_PROPERTY, expressionDef );
}
IntegrationNamespaceUtils.setValueIfAttributeDefined( builder, element, VoldemortParserUtils.PERSIST_MODE );
return builder.getBeanDefinition();
}
}
/*
* Copyright 2002-2013 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.integration.voldemort.config.xml;
import org.springframework.beans.factory.config.TypedStringValue;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.ExpressionFactoryBean;
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.integration.voldemort.outbound.VoldemortStoringMessageHandler;
import org.w3c.dom.Element;
/**
* Parses Voldemort outbound adapter XML definition.
*
* @author Lukasz Antoniak
* @since 1.0
*/
public class VoldemortOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {
/**
* Produces "int-voldemort:outbound-channel-adapter" bean definition.
* <p />
* {@inheritDoc}
*/
@Override
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
final BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition( VoldemortStoringMessageHandler.class );
VoldemortParserUtils.processCommonAttributes( element, builder );
final boolean hasKey = element.hasAttribute( VoldemortParserUtils.STORE_KEY );
final boolean hasKeyExpression = element.hasAttribute( VoldemortParserUtils.STORE_KEY_EXPRESSION );
if ( hasKey && hasKeyExpression ) {
parserContext.getReaderContext().error( "At most one of '" + VoldemortParserUtils.STORE_KEY
+ "' or '" + VoldemortParserUtils.STORE_KEY_EXPRESSION + "' is allowed.", element );
}
if ( hasKey ) {
builder.addPropertyValue(
VoldemortParserUtils.KEY_PROPERTY,
new TypedStringValue( element.getAttribute( VoldemortParserUtils.STORE_KEY ) )
);
}
if ( hasKeyExpression ) {
RootBeanDefinition expressionDef = new RootBeanDefinition( ExpressionFactoryBean.class );
expressionDef.getConstructorArgumentValues().addGenericArgumentValue( element.getAttribute( VoldemortParserUtils.STORE_KEY_EXPRESSION ) );
builder.addPropertyValue( VoldemortParserUtils.KEY_EXPRESSION_PROPERTY, expressionDef );
}
IntegrationNamespaceUtils.setValueIfAttributeDefined( builder, element, VoldemortParserUtils.PERSIST_MODE );
return builder.getBeanDefinition();
}
}

View File

@@ -24,7 +24,7 @@ import org.w3c.dom.Element;
* @author Lukasz Antoniak
* @since 1.0
*/
abstract class VoldemortParserUtils {
public final class VoldemortParserUtils {
static final String STORE_CLIENT = "store-client";
static final String PERSIST_MODE = "persist-mode";
static final String SEARCH_KEY = "search-key";
@@ -37,6 +37,11 @@ abstract class VoldemortParserUtils {
static final String KEY_PROPERTY = "key";
static final String KEY_EXPRESSION_PROPERTY = "keyExpression";
/** Prevent instantiation. */
private VoldemortParserUtils() {
throw new AssertionError();
}
/**
* Handles "store-client" and "message-converter" attributes.
*/

View File

@@ -32,7 +32,9 @@ import voldemort.versioning.Versioned;
* @author Lukasz Antoniak
* @since 1.0
*/
public class VoldemortMessageSource extends IntegrationObjectSupport implements MessageSource {
public class VoldemortMessageSource extends IntegrationObjectSupport
implements MessageSource<Object> {
private final StoreClient client;
/**
@@ -65,15 +67,15 @@ public class VoldemortMessageSource extends IntegrationObjectSupport implements
@Override
@SuppressWarnings("unchecked")
public Message receive() {
public Message<Object> receive() {
final Object key = keyExpression.getValue( evaluationContext, Object.class );
final Versioned value = client.get( key );
final Versioned<?> value = client.get( key );
if ( value != null ) {
if ( deleteAfterPoll ) {
client.delete( key );
}
return MessageBuilder.withPayload( extractValue ? value.getValue() : value )
.setHeader( VoldemortHeaders.KEY, key ).build();
.setHeader(VoldemortHeaders.KEY, key ).build();
}
return null;
}

View File

@@ -1,112 +1,112 @@
/*
* Copyright 2002-2013 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.integration.voldemort.outbound;
import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.Message;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.voldemort.support.PersistMode;
import org.springframework.integration.voldemort.support.VoldemortHeaders;
import voldemort.client.StoreClient;
/**
* Voldemort outbound adapter implementation.
*
* @author Lukasz Antoniak
* @since 1.0
*/
public class VoldemortStoringMessageHandler extends AbstractMessageHandler {
private final StoreClient client;
private volatile StandardEvaluationContext evaluationContext;
private volatile Expression keyExpression = new SpelExpressionParser().parseExpression( "headers." + VoldemortHeaders.KEY );
private volatile PersistMode persistMode = PersistMode.PUT;
/**
* Creates new message sender.
*
* @param client Voldemort store client.
*/
public VoldemortStoringMessageHandler(StoreClient client) {
this.client = client;
}
@Override
protected void onInit() throws Exception {
super.onInit();
if ( getBeanFactory() != null ) {
evaluationContext = ExpressionUtils.createStandardEvaluationContext( getBeanFactory() );
}
else {
evaluationContext = ExpressionUtils.createStandardEvaluationContext();
}
}
@Override
@SuppressWarnings("unchecked")
protected void handleMessageInternal(Message<?> message) throws Exception {
final Object key = keyExpression.getValue( evaluationContext, message, Object.class );
switch ( determinePersistMode( message ) ) {
case PUT:
client.put( key, message.getPayload() );
break;
case DELETE:
client.delete( key );
break;
}
}
/**
* Computes desired persist mode for a given message. Default output adapter's configuration
* can be overridden with {@link VoldemortHeaders#PERSIST_MODE} message header which supports
* direct or text representation of {@link PersistMode} enumeration.
*
* @param message Spring Integration message.
* @return Persist mode.
*/
private PersistMode determinePersistMode(Message<?> message) {
final Object confValue = message.getHeaders().get( VoldemortHeaders.PERSIST_MODE );
if ( confValue instanceof PersistMode ) {
return (PersistMode) confValue;
}
else if ( confValue instanceof String ) {
return PersistMode.valueOf( (String) confValue );
}
return persistMode;
}
@Override
public String getComponentType() {
return "voldemort:outbound-channel-adapter";
}
public void setKey(String key) {
setKeyExpression( new LiteralExpression( key ) );
}
public void setKeyExpression(Expression keyExpression) {
this.keyExpression = keyExpression;
}
public void setPersistMode(PersistMode persistMode) {
this.persistMode = persistMode;
}
}
/*
* Copyright 2002-2013 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.integration.voldemort.outbound;
import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.Message;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.voldemort.support.PersistMode;
import org.springframework.integration.voldemort.support.VoldemortHeaders;
import voldemort.client.StoreClient;
/**
* Voldemort outbound adapter implementation.
*
* @author Lukasz Antoniak
* @since 1.0
*/
public class VoldemortStoringMessageHandler extends AbstractMessageHandler {
private final StoreClient client;
private volatile StandardEvaluationContext evaluationContext;
private volatile Expression keyExpression = new SpelExpressionParser().parseExpression( "headers." + VoldemortHeaders.KEY );
private volatile PersistMode persistMode = PersistMode.PUT;
/**
* Creates new message sender.
*
* @param client Voldemort store client.
*/
public VoldemortStoringMessageHandler(StoreClient client) {
this.client = client;
}
@Override
protected void onInit() throws Exception {
super.onInit();
if ( getBeanFactory() != null ) {
evaluationContext = ExpressionUtils.createStandardEvaluationContext( getBeanFactory() );
}
else {
evaluationContext = ExpressionUtils.createStandardEvaluationContext();
}
}
@Override
@SuppressWarnings("unchecked")
protected void handleMessageInternal(Message<?> message) throws Exception {
final Object key = keyExpression.getValue( evaluationContext, message, Object.class );
switch ( determinePersistMode( message ) ) {
case PUT:
client.put( key, message.getPayload() );
break;
case DELETE:
client.delete( key );
break;
}
}
/**
* Computes desired persist mode for a given message. Default output adapter's configuration
* can be overridden with {@link VoldemortHeaders#PERSIST_MODE} message header which supports
* direct or text representation of {@link PersistMode} enumeration.
*
* @param message Spring Integration message.
* @return Persist mode.
*/
private PersistMode determinePersistMode(Message<?> message) {
final Object confValue = message.getHeaders().get( VoldemortHeaders.PERSIST_MODE );
if ( confValue instanceof PersistMode ) {
return (PersistMode) confValue;
}
else if ( confValue instanceof String ) {
return PersistMode.valueOf( (String) confValue );
}
return persistMode;
}
@Override
public String getComponentType() {
return "voldemort:outbound-channel-adapter";
}
public void setKey(String key) {
setKeyExpression( new LiteralExpression( key ) );
}
public void setKeyExpression(Expression keyExpression) {
this.keyExpression = keyExpression;
}
public void setPersistMode(PersistMode persistMode) {
this.persistMode = persistMode;
}
}

View File

@@ -45,14 +45,14 @@ public class VoldemortMessageStore extends AbstractKeyValueMessageStore implemen
/**
* Key under which message store tracks all currently saved message identifiers.
*/
protected final static String MESSAGE_KEY_LIST = "MESSAGE_KEY_LIST";
protected static final String MESSAGE_KEY_LIST = "MESSAGE_KEY_LIST";
/**
* Key under which message store tracks all currently saved message group identifiers.
*/
protected final static String MESSAGE_GROUP_KEY_LIST = "MESSAGE_GROUP_KEY_LIST";
protected static final String MESSAGE_GROUP_KEY_LIST = "MESSAGE_GROUP_KEY_LIST";
private final static LockRegistry LOCK_REGISTRY = new DefaultLockRegistry();
private static final LockRegistry LOCK_REGISTRY = new DefaultLockRegistry();
private final StoreClient client;
@@ -99,7 +99,7 @@ public class VoldemortMessageStore extends AbstractKeyValueMessageStore implemen
}
}
catch ( SerializationException e ) {
throw new IllegalArgumentException( "Voldemort failed to serialize message with id: " + id + "." );
throw new IllegalArgumentException( "Voldemort failed to serialize message with id: " + id + ".", e );
}
finally {
messageLock.unlock();
@@ -181,7 +181,7 @@ public class VoldemortMessageStore extends AbstractKeyValueMessageStore implemen
/**
* Voldemort update action that adds given key to the list of currently saved identifiers.
*/
private static class AddKeyUpdateAction extends UpdateAction {
private static final class AddKeyUpdateAction extends UpdateAction {
private final Object id;
private final String keyListKey;
@@ -208,7 +208,7 @@ public class VoldemortMessageStore extends AbstractKeyValueMessageStore implemen
/**
* Voldemort update action that removes given key from the list of currently saved identifiers.
*/
private static class RemoveKeyUpdateAction extends UpdateAction {
private static final class RemoveKeyUpdateAction extends UpdateAction {
private final Object id;
private final String keyListKey;

View File

@@ -27,7 +27,7 @@ public abstract class VoldemortHeaders {
/**
* Header representing key under which message payload should be stored.
*/
public static final String KEY = PREFIX + "_key";
public static final String KEY = PREFIX + "key";
/**
* Overrides default output adapter's persist mode for a given message.

View File

@@ -1,187 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.springframework.org/schema/integration/voldemort"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
xmlns:integration="http://www.springframework.org/schema/integration"
targetNamespace="http://www.springframework.org/schema/integration/voldemort"
elementFormDefault="qualified" attributeFormDefault="unqualified">
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:tool="http://www.springframework.org/schema/tool"
xmlns:integration="http://www.springframework.org/schema/integration"
targetNamespace="http://www.springframework.org/schema/integration/voldemort"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
<xsd:import namespace="http://www.springframework.org/schema/integration"
schemaLocation="http://www.springframework.org/schema/integration/spring-integration.xsd"/>
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
<xsd:import namespace="http://www.springframework.org/schema/integration"
schemaLocation="http://www.springframework.org/schema/integration/spring-integration.xsd"/>
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines the configuration elements for the Spring Integration
Voldemort Adapter.
<xsd:annotation>
<xsd:documentation><![CDATA[
Defines the configuration elements for the Spring Integration
Voldemort Module.
]]></xsd:documentation>
</xsd:annotation>
</xsd:annotation>
<xsd:element name="outbound-channel-adapter">
<xsd:annotation>
<xsd:documentation>
Defines an Outbound Channel Adapter that writes messages to
Voldemort key-value store.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup ref="voldemortAdapterAttributes"/>
<xsd:attribute name="store-key" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Specifies the key for Voldemort store. If an expression
is needed, use 'store-key-expression' attribute.
Both options are mutually exclusive.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="store-key-expression" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Spring Expression Language statement used to determine
desired entry key in Voldemort store.
Default expression equals 'headers.voldemort_key'.
This attribute is mutually exclusive with 'store-key' attribute.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="persist-mode" use="optional" default="PUT">
<xsd:annotation>
<xsd:documentation>
Defines default persist mode for outbound-channel-adapter.
By default values are added or updated in the underlying
Voldemort database. Hereby behavior can be overridden using
VoldemortHeaders.PERSIST_MODE message header.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="persistMode xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="order">
<xsd:annotation>
<xsd:documentation>
Specifies the order for invocation when this endpoint is connected as a
subscriber to SubscribableChannel.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="outbound-channel-adapter">
<xsd:annotation>
<xsd:documentation>
Defines an Outbound Channel Adapter that writes messages to
Voldemort key-value store.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attributeGroup ref="voldemortAdapterAttributes"/>
<xsd:attribute name="store-key" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Specifies the key for the Voldemort store. If an expression
is needed, use the 'store-key-expression' attribute.
Both options are mutually exclusive.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="store-key-expression" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Spring Expression Language statement used to determine
the desired entry key into the Voldemort store.
Default expression equals 'headers.voldemort_key'.
This attribute is mutually exclusive with the 'store-key'
attribute.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="persist-mode" use="optional" default="PUT">
<xsd:annotation>
<xsd:documentation>
Defines the default persist mode for the outbound-channel-adapter.
Available modes are:
<xsd:element name="inbound-channel-adapter">
<xsd:annotation>
<xsd:documentation>
Defines an Inbound Channel Adapter that reads records from Voldemort
key-value store.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attributeGroup ref="voldemortAdapterAttributes"/>
<xsd:attribute name="search-key" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
String key that is being searched.
This attribute is mutually exclusive
with 'search-key-expression' attribute.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="search-key-expression" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Spring Expression Language statement that returns
desired entry key.
This attribute is mutually exclusive with 'search-key' attribute.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="delete-after-poll" default="false" use="optional">
<xsd:annotation>
<xsd:documentation>
Indicates whether returned object should be removed
from Voldemort database after polling into Spring
Integration channel.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string" />
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="extract-value" default="true" use="optional">
<xsd:annotation>
<xsd:documentation>
Flag controlling value extraction from Voldemort's
Versioned object.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string" />
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
- PUT
- DELETE
<xsd:attributeGroup name="voldemortAdapterAttributes">
<xsd:annotation>
<xsd:documentation>
Common configuration for Voldemort adapters.
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="id" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation>
Identifies the underlying Spring bean definition.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="channel" type="xsd:string" use="required">
<xsd:annotation>
<xsd:appinfo>
<xsd:documentation>
Reference to a MessageChannel that will be utilized to
"receive from" or "send to" messages depending on the
adapter type (e.g. inbound or outbound).
</xsd:documentation>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.MessageChannel"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="store-client" type="xsd:string" use="required">
<xsd:annotation>
<xsd:appinfo>
<xsd:documentation>
Native Voldemort store client.
</xsd:documentation>
<tool:annotation kind="ref">
<tool:expected-type type="voldemort.client.StoreClient"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="auto-startup" default="true" use="optional">
<xsd:annotation>
<xsd:documentation>
Flag to indicate that the component should start automatically
on startup (default true).
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
</xsd:attributeGroup>
By default values are added or updated in the underlying
Voldemort database (PUT). The specified behavior can be
overridden using the VoldemortHeaders.PERSIST_MODE message header.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="persistMode xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="order">
<xsd:annotation>
<xsd:documentation>
Specifies the order for invocation when this endpoint is
connected as a subscriber to SubscribableChannel.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="persistMode">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="PUT"/>
<xsd:enumeration value="DELETE"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="inbound-channel-adapter">
<xsd:annotation>
<xsd:documentation>
Defines an Inbound Channel Adapter that reads records from
the Voldemort key-value store.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
<xsd:attributeGroup ref="voldemortAdapterAttributes"/>
<xsd:attribute name="search-key" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
String key that is being searched for.
This attribute is mutually exclusive
with the 'search-key-expression' attribute.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="search-key-expression" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Spring Expression Language (SpEL) statement that
returns the desired entry key.
This attribute is mutually exclusive with the
'search-key' attribute.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="delete-after-poll" default="false" use="optional">
<xsd:annotation>
<xsd:documentation>
Indicates whether returned objects should be removed
from the Voldemort database after polling. Defaults to
'false'.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string" />
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="extract-value" default="true" use="optional">
<xsd:annotation>
<xsd:documentation>
Flag controlling the value extraction from Voldemort's
Versioned object. Defaults to 'true'.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string" />
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:attributeGroup name="voldemortAdapterAttributes">
<xsd:annotation>
<xsd:documentation>
Common configuration for Voldemort adapters.
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="id" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation>
Identifies the underlying Spring bean definition.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="channel" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>
Reference to a MessageChannel that will be utilized to
"receive from" or "send to" messages depending on the
adapter type (e.g. inbound or outbound).
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="org.springframework.integration.MessageChannel"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="store-client" type="xsd:string" use="required">
<xsd:annotation>
<xsd:documentation>
Native Voldemort store client. Needs to be an implementation
of 'voldemort.client.StoreClient'.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
<tool:expected-type type="voldemort.client.StoreClient"/>
</tool:annotation>
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="auto-startup" default="true" use="optional">
<xsd:annotation>
<xsd:documentation>
Flag indicating that the component should start automatically
on startup (default is 'true').
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string"/>
</xsd:simpleType>
</xsd:attribute>
</xsd:attributeGroup>
<xsd:simpleType name="persistMode">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="PUT"/>
<xsd:enumeration value="DELETE"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>

View File

@@ -1,101 +1,101 @@
/*
* Copyright 2002-2013 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.integration.voldemort.test;
import java.io.File;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import voldemort.server.VoldemortConfig;
import voldemort.server.VoldemortServer;
/**
* Base class for functional test cases. Handles embedded Voldemort server startup and shutdown.
*
* @author Lukasz Antoniak
* @since 1.0
*/
public abstract class BaseFunctionalTestCase {
protected VoldemortServer server = null;
/**
* Starts Voldemort embedded server.
*/
@Before
public void setUp() throws Exception {
final VoldemortConfig config = configureServer();
server = new VoldemortServer( config );
server.start();
}
/**
* Stops Voldemort embedded server.
*/
@After
public void tearDown() throws Exception {
if ( server != null && server.isStarted() ) {
server.stop();
}
}
/**
* Review cluster.xml and stores.xml configuration files.
*
* @return Voldemort embedded server configuration.
*/
protected VoldemortConfig configureServer() throws Exception {
final File voldemortHome = new File( System.getProperty( "java.io.tmpdir" ), "voldemort" );
FileUtils.deleteDirectory( voldemortHome );
final Properties properties = new Properties();
properties.put( "node.id", "0" );
properties.put( "voldemort.home", voldemortHome.getAbsolutePath() );
addConfigOptions( properties );
final VoldemortConfig config = new VoldemortConfig( properties );
final File metadata = new File( config.getMetadataDirectory() );
FileUtils.forceMkdir( metadata );
FileUtils.copyFileToDirectory( getClusterConfiguration(), metadata );
FileUtils.copyFileToDirectory( getStoreConfiguration(), metadata );
return config;
}
/**
* @return Voldemort cluster configuration descriptor.
*/
protected File getClusterConfiguration() {
return new File( "src/test/resources/cluster.xml" );
}
/**
* @return Voldemort store configuration descriptor.
*/
protected File getStoreConfiguration() {
return new File( "src/test/resources/stores.xml" );
}
/**
* Subclasses may want to setup specific server configuration parameters.
*
* @param properties Voldemort server configuration properties.
*/
protected void addConfigOptions(Properties properties) {
}
}
/*
* Copyright 2002-2013 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.integration.voldemort.test;
import java.io.File;
import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import voldemort.server.VoldemortConfig;
import voldemort.server.VoldemortServer;
/**
* Base class for functional test cases. Handles embedded Voldemort server startup and shutdown.
*
* @author Lukasz Antoniak
* @since 1.0
*/
public abstract class BaseFunctionalTestCase {
protected VoldemortServer server = null;
/**
* Starts Voldemort embedded server.
*/
@Before
public void setUp() throws Exception {
final VoldemortConfig config = configureServer();
server = new VoldemortServer( config );
server.start();
}
/**
* Stops Voldemort embedded server.
*/
@After
public void tearDown() throws Exception {
if ( server != null && server.isStarted() ) {
server.stop();
}
}
/**
* Review cluster.xml and stores.xml configuration files.
*
* @return Voldemort embedded server configuration.
*/
protected VoldemortConfig configureServer() throws Exception {
final File voldemortHome = new File( System.getProperty( "java.io.tmpdir" ), "voldemort" );
FileUtils.deleteDirectory( voldemortHome );
final Properties properties = new Properties();
properties.put( "node.id", "0" );
properties.put( "voldemort.home", voldemortHome.getAbsolutePath() );
addConfigOptions( properties );
final VoldemortConfig config = new VoldemortConfig( properties );
final File metadata = new File( config.getMetadataDirectory() );
FileUtils.forceMkdir( metadata );
FileUtils.copyFileToDirectory( getClusterConfiguration(), metadata );
FileUtils.copyFileToDirectory( getStoreConfiguration(), metadata );
return config;
}
/**
* @return Voldemort cluster configuration descriptor.
*/
protected File getClusterConfiguration() {
return new File( "src/test/resources/cluster.xml" );
}
/**
* @return Voldemort store configuration descriptor.
*/
protected File getStoreConfiguration() {
return new File( "src/test/resources/stores.xml" );
}
/**
* Subclasses may want to setup specific server configuration parameters.
*
* @param properties Voldemort server configuration properties.
*/
protected void addConfigOptions(Properties properties) {
}
}

View File

@@ -18,7 +18,7 @@ package org.springframework.integration.voldemort.test.domain;
import java.io.Serializable;
/**
* Sample object with composite key persisted in Voldemort database.
* Sample object with composite key persisted to Voldemort database.
*
* @author Lukasz Antoniak
* @since 1.0

View File

@@ -1,89 +1,89 @@
/*
* Copyright 2002-2013 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.integration.voldemort.test.domain;
import java.io.Serializable;
/**
* Sample object persisted in Voldemort database.
*
* @author Lukasz Antoniak
* @since 1.0
*/
public class Person implements Serializable {
private static final long serialVersionUID = -9092199331950213292L;
private String id;
private String firstName;
private String lastName;
public Person(String id, String firstName, String lastName) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public boolean equals(Object o) {
if ( this == o ) return true;
if ( !( o instanceof Person ) ) return false;
Person person = (Person) o;
if ( id != null ? !id.equals( person.id ) : person.id != null ) return false;
if ( firstName != null ? !firstName.equals( person.firstName ) : person.firstName != null ) return false;
if ( lastName != null ? !lastName.equals( person.lastName ) : person.lastName != null ) return false;
return true;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + ( firstName != null ? firstName.hashCode() : 0 );
result = 31 * result + ( lastName != null ? lastName.hashCode() : 0 );
return result;
}
@Override
public String toString() {
return "Person(id = " + id + ", firstName = " + firstName + ", lastName = " + lastName + ")";
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
/*
* Copyright 2002-2013 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.integration.voldemort.test.domain;
import java.io.Serializable;
/**
* Sample object persisted in Voldemort database.
*
* @author Lukasz Antoniak
* @since 1.0
*/
public class Person implements Serializable {
private static final long serialVersionUID = -9092199331950213292L;
private String id;
private String firstName;
private String lastName;
public Person(String id, String firstName, String lastName) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
}
@Override
public boolean equals(Object o) {
if ( this == o ) return true;
if ( !( o instanceof Person ) ) return false;
Person person = (Person) o;
if ( id != null ? !id.equals( person.id ) : person.id != null ) return false;
if ( firstName != null ? !firstName.equals( person.firstName ) : person.firstName != null ) return false;
if ( lastName != null ? !lastName.equals( person.lastName ) : person.lastName != null ) return false;
return true;
}
@Override
public int hashCode() {
int result = id != null ? id.hashCode() : 0;
result = 31 * result + ( firstName != null ? firstName.hashCode() : 0 );
result = 31 * result + ( lastName != null ? lastName.hashCode() : 0 );
return result;
}
@Override
public String toString() {
return "Person(id = " + id + ", firstName = " + firstName + ", lastName = " + lastName + ")";
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}

View File

@@ -1,177 +1,177 @@
/*
* Copyright 2002-2013 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.integration.voldemort.test.outbound;
import junit.framework.Assert;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.voldemort.support.PersistMode;
import org.springframework.integration.voldemort.support.VoldemortHeaders;
import org.springframework.integration.voldemort.test.BaseFunctionalTestCase;
import org.springframework.integration.voldemort.test.domain.Person;
import voldemort.client.StoreClient;
import voldemort.versioning.Versioned;
/**
* Voldemort basic outbound adapter tests.
*
* @author Lukasz Antoniak
* @since 1.0
*/
@SuppressWarnings("unchecked")
public class VoldemortOutboundAdapterTest extends BaseFunctionalTestCase {
@Test
public void testPutObject() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageChannel voldemortOutboundPutChannel = context.getBean( "voldemortOutboundPutChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
// when
final Message<Person> message = MessageBuilder.withPayload( lukasz ).setHeader( VoldemortHeaders.KEY, lukasz.getId() ).build();
voldemortOutboundPutChannel.send( message );
// then
final Versioned found = storeClient.get( lukasz.getId() );
Assert.assertEquals( lukasz, found.getValue() );
context.close();
}
@Test
public void testPutObjectsConstantKey() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageChannel voldemortOutboundChannel = context.getBean( "voldemortOutboundPutConstantKeyChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
// when
final Message<Person> firstMessage = MessageBuilder.withPayload( lukasz ).build();
voldemortOutboundChannel.send( firstMessage );
// then
Assert.assertEquals( lukasz, storeClient.get( "constant-key" ).getValue() );
// given
final Person tomasz = new Person( "2", "Tomasz", "Antoniak" );
// when
final Message<Person> secondMessage = MessageBuilder.withPayload( tomasz ).build();
voldemortOutboundChannel.send( secondMessage );
// then
Assert.assertEquals( tomasz, storeClient.get( "constant-key" ).getValue() );
context.close();
}
@Test
public void testDeleteObject() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageChannel voldemortOutboundDeleteChannel = context.getBean( "voldemortOutboundDeleteChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
storeClient.put( lukasz.getId(), lukasz );
// when
final Message<Person> message = MessageBuilder.withPayload( lukasz ).build();
voldemortOutboundDeleteChannel.send( message );
// then
final Versioned found = storeClient.get( lukasz.getId() );
Assert.assertNull( found );
context.close();
}
@Test
public void testOverridePersistMode() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageChannel voldemortOutboundDeleteChannel = context.getBean( "voldemortOutboundDeleteChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
// when
// Overriding output adapter's persist mode.
final Message<Person> message = MessageBuilder.withPayload( lukasz )
.setHeader( VoldemortHeaders.PERSIST_MODE, PersistMode.PUT ).build();
voldemortOutboundDeleteChannel.send( message );
// then
final Versioned found = storeClient.get( lukasz.getId() );
Assert.assertEquals( lukasz, found.getValue() );
context.close();
}
@Test
public void testStoppedAdapter() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final MessageChannel voldemortStoppedChannel = context.getBean( "voldemortStoppedChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
// when
final Message<Person> message = MessageBuilder.withPayload( lukasz ).build();
try {
voldemortStoppedChannel.send( message );
}
catch ( MessageDeliveryException e ) {
return;
}
finally {
context.close();
}
Assert.fail();
}
@Test
public void testOrder() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageUpdatingServiceActivator messageUpdater = context.getBean( "messageUpdater", MessageUpdatingServiceActivator.class );
final MessageChannel voldemortOrderChannel = context.getBean( "voldemortOrderChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "lukasz", "Lukasz", "Antoniak" );
final Person copy = new Person( "lukasz", "Lukasz", "Antoniak" );
// when
final Message<Person> message = MessageBuilder.withPayload( lukasz ).build();
voldemortOrderChannel.send( message );
// then
messageUpdater.updatePerson( copy );
final Versioned found = storeClient.get( lukasz.getId() );
Assert.assertEquals( copy, found.getValue() );
context.close();
}
}
/*
* Copyright 2002-2013 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.integration.voldemort.test.outbound;
import junit.framework.Assert;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.voldemort.support.PersistMode;
import org.springframework.integration.voldemort.support.VoldemortHeaders;
import org.springframework.integration.voldemort.test.BaseFunctionalTestCase;
import org.springframework.integration.voldemort.test.domain.Person;
import voldemort.client.StoreClient;
import voldemort.versioning.Versioned;
/**
* Voldemort basic outbound adapter tests.
*
* @author Lukasz Antoniak
* @since 1.0
*/
@SuppressWarnings("unchecked")
public class VoldemortOutboundAdapterTest extends BaseFunctionalTestCase {
@Test
public void testPutObject() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageChannel voldemortOutboundPutChannel = context.getBean( "voldemortOutboundPutChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
// when
final Message<Person> message = MessageBuilder.withPayload( lukasz ).setHeader( VoldemortHeaders.KEY, lukasz.getId() ).build();
voldemortOutboundPutChannel.send( message );
// then
final Versioned found = storeClient.get( lukasz.getId() );
Assert.assertEquals( lukasz, found.getValue() );
context.close();
}
@Test
public void testPutObjectsConstantKey() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageChannel voldemortOutboundChannel = context.getBean( "voldemortOutboundPutConstantKeyChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
// when
final Message<Person> firstMessage = MessageBuilder.withPayload( lukasz ).build();
voldemortOutboundChannel.send( firstMessage );
// then
Assert.assertEquals( lukasz, storeClient.get( "constant-key" ).getValue() );
// given
final Person tomasz = new Person( "2", "Tomasz", "Antoniak" );
// when
final Message<Person> secondMessage = MessageBuilder.withPayload( tomasz ).build();
voldemortOutboundChannel.send( secondMessage );
// then
Assert.assertEquals( tomasz, storeClient.get( "constant-key" ).getValue() );
context.close();
}
@Test
public void testDeleteObject() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageChannel voldemortOutboundDeleteChannel = context.getBean( "voldemortOutboundDeleteChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
storeClient.put( lukasz.getId(), lukasz );
// when
final Message<Person> message = MessageBuilder.withPayload( lukasz ).build();
voldemortOutboundDeleteChannel.send( message );
// then
final Versioned found = storeClient.get( lukasz.getId() );
Assert.assertNull( found );
context.close();
}
@Test
public void testOverridePersistMode() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageChannel voldemortOutboundDeleteChannel = context.getBean( "voldemortOutboundDeleteChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
// when
// Overriding output adapter's persist mode.
final Message<Person> message = MessageBuilder.withPayload( lukasz )
.setHeader( VoldemortHeaders.PERSIST_MODE, PersistMode.PUT ).build();
voldemortOutboundDeleteChannel.send( message );
// then
final Versioned found = storeClient.get( lukasz.getId() );
Assert.assertEquals( lukasz, found.getValue() );
context.close();
}
@Test
public void testStoppedAdapter() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final MessageChannel voldemortStoppedChannel = context.getBean( "voldemortStoppedChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "1", "Lukasz", "Antoniak" );
// when
final Message<Person> message = MessageBuilder.withPayload( lukasz ).build();
try {
voldemortStoppedChannel.send( message );
}
catch ( MessageDeliveryException e ) {
return;
}
finally {
context.close();
}
Assert.fail();
}
@Test
public void testOrder() {
final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "VoldemortOutboundAdapterTest-context.xml", getClass() );
final StoreClient storeClient = context.getBean( "storeClient", StoreClient.class );
final MessageUpdatingServiceActivator messageUpdater = context.getBean( "messageUpdater", MessageUpdatingServiceActivator.class );
final MessageChannel voldemortOrderChannel = context.getBean( "voldemortOrderChannel", MessageChannel.class );
// given
final Person lukasz = new Person( "lukasz", "Lukasz", "Antoniak" );
final Person copy = new Person( "lukasz", "Lukasz", "Antoniak" );
// when
final Message<Person> message = MessageBuilder.withPayload( lukasz ).build();
voldemortOrderChannel.send( message );
// then
messageUpdater.updatePerson( copy );
final Versioned found = storeClient.get( lukasz.getId() );
Assert.assertEquals( copy, found.getValue() );
context.close();
}
}

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2002-2013 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.integration.voldemort.test.store;
import java.io.File;

View File

@@ -32,7 +32,6 @@ import org.springframework.integration.voldemort.test.BaseFunctionalTestCase;
* @author Lukasz Antoniak
* @since 1.0
*/
@SuppressWarnings("unchecked")
public class VoldemortMessageStoreAggregationTest extends BaseFunctionalTestCase {
@Override
protected File getStoreConfiguration() {

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<cluster>
<name>test-cluster</name>
<server>
<id>0</id>
<host>localhost</host>
<http-port>8080</http-port>
<socket-port>6666</socket-port>
<admin-port>6667</admin-port>
<partitions>0, 1</partitions>
</server>
</cluster>
<?xml version="1.0" encoding="UTF-8"?>
<cluster>
<name>test-cluster</name>
<server>
<id>0</id>
<host>localhost</host>
<http-port>8080</http-port>
<socket-port>6666</socket-port>
<admin-port>6667</admin-port>
<partitions>0, 1</partitions>
</server>
</cluster>

View File

@@ -1,16 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="config" class="voldemort.client.ClientConfig">
<property name="bootstrapUrls" value="tcp://localhost:6666" />
</bean>
<bean id="clientFactory" class="voldemort.client.SocketStoreClientFactory" destroy-method="close">
<constructor-arg name="config" ref="config" />
</bean>
<bean id="storeClient" factory-bean="clientFactory" factory-method="getStoreClient">
<constructor-arg value="test-store" />
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="config" class="voldemort.client.ClientConfig">
<property name="bootstrapUrls" value="tcp://localhost:6666" />
</bean>
<bean id="clientFactory" class="voldemort.client.SocketStoreClientFactory" destroy-method="close">
<constructor-arg name="config" ref="config" />
</bean>
<bean id="storeClient" factory-bean="clientFactory" factory-method="getStoreClient">
<constructor-arg value="test-store" />
</bean>
</beans>

View File

@@ -1,25 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-voldemort="http://www.springframework.org/schema/integration/voldemort"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/voldemort http://www.springframework.org/schema/integration/voldemort/spring-integration-voldemort.xsd">
<import resource="../common-test-context.xml" />
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-voldemort="http://www.springframework.org/schema/integration/voldemort"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/voldemort http://www.springframework.org/schema/integration/voldemort/spring-integration-voldemort.xsd">
<bean id="objectStoreClient" factory-bean="clientFactory" factory-method="getStoreClient">
<constructor-arg value="test-object-store" />
</bean>
<import resource="../common-test-context.xml" />
<int:channel id="voldemortInboundChannel">
<int:queue />
</int:channel>
<bean id="objectStoreClient" factory-bean="clientFactory" factory-method="getStoreClient">
<constructor-arg value="test-object-store" />
</bean>
<bean id="keyProducer" class="org.springframework.integration.voldemort.test.inbound.ObjectKeyTest$ObjectKeyProducer" />
<int:channel id="voldemortInboundChannel">
<int:queue />
</int:channel>
<int-voldemort:inbound-channel-adapter id="voldemortInObjectKey" channel="voldemortInboundChannel"
search-key-expression="@keyProducer.value" store-client="objectStoreClient">
<int:poller fixed-rate="1000" />
</int-voldemort:inbound-channel-adapter>
</beans>
<bean id="keyProducer" class="org.springframework.integration.voldemort.test.inbound.ObjectKeyTest$ObjectKeyProducer" />
<int-voldemort:inbound-channel-adapter id="voldemortInObjectKey" channel="voldemortInboundChannel"
search-key-expression="@keyProducer.value" store-client="objectStoreClient">
<int:poller fixed-rate="1000" />
</int-voldemort:inbound-channel-adapter>
</beans>

View File

@@ -1,30 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-voldemort="http://www.springframework.org/schema/integration/voldemort"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/voldemort http://www.springframework.org/schema/integration/voldemort/spring-integration-voldemort.xsd">
<import resource="../common-test-context.xml" />
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-voldemort="http://www.springframework.org/schema/integration/voldemort"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/voldemort http://www.springframework.org/schema/integration/voldemort/spring-integration-voldemort.xsd">
<int:channel id="voldemortInboundChannel">
<int:queue />
</int:channel>
<import resource="../common-test-context.xml" />
<int-voldemort:inbound-channel-adapter id="voldemortInKey" channel="voldemortInboundChannel" search-key="lukasz"
store-client="storeClient">
<int:poller fixed-rate="1000" />
</int-voldemort:inbound-channel-adapter>
<int:channel id="voldemortInboundChannel">
<int:queue />
</int:channel>
<int-voldemort:inbound-channel-adapter id="voldemortInExpr" channel="voldemortInboundChannel"
search-key-expression="new String('KINGA').toLowerCase()"
store-client="storeClient" extract-value="false">
<int:poller fixed-rate="1000" />
</int-voldemort:inbound-channel-adapter>
<int-voldemort:inbound-channel-adapter id="voldemortInKey" channel="voldemortInboundChannel" search-key="lukasz"
store-client="storeClient">
<int:poller fixed-rate="1000" />
</int-voldemort:inbound-channel-adapter>
<int-voldemort:inbound-channel-adapter id="voldemortInDelete" channel="voldemortInboundChannel" search-key="robert"
store-client="storeClient" delete-after-poll="true">
<int:poller fixed-rate="1000" />
</int-voldemort:inbound-channel-adapter>
</beans>
<int-voldemort:inbound-channel-adapter id="voldemortInExpr" channel="voldemortInboundChannel"
search-key-expression="new String('KINGA').toLowerCase()"
store-client="storeClient" extract-value="false">
<int:poller fixed-rate="1000" />
</int-voldemort:inbound-channel-adapter>
<int-voldemort:inbound-channel-adapter id="voldemortInDelete" channel="voldemortInboundChannel" search-key="robert"
store-client="storeClient" delete-after-poll="true">
<int:poller fixed-rate="1000" />
</int-voldemort:inbound-channel-adapter>
</beans>

View File

@@ -1,19 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-voldemort="http://www.springframework.org/schema/integration/voldemort"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/voldemort http://www.springframework.org/schema/integration/voldemort/spring-integration-voldemort.xsd">
<import resource="../common-test-context.xml" />
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-voldemort="http://www.springframework.org/schema/integration/voldemort"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/voldemort http://www.springframework.org/schema/integration/voldemort/spring-integration-voldemort.xsd">
<bean id="objectStoreClient" factory-bean="clientFactory" factory-method="getStoreClient">
<constructor-arg value="test-object-store" />
</bean>
<import resource="../common-test-context.xml" />
<int:channel id="voldemortOutboundPutChannel" />
<bean id="objectStoreClient" factory-bean="clientFactory" factory-method="getStoreClient">
<constructor-arg value="test-object-store" />
</bean>
<int-voldemort:outbound-channel-adapter id="voldemortPut" channel="voldemortOutboundPutChannel"
store-client="objectStoreClient" />
</beans>
<int:channel id="voldemortOutboundPutChannel" />
<int-voldemort:outbound-channel-adapter id="voldemortPut" channel="voldemortOutboundPutChannel"
store-client="objectStoreClient" />
</beans>

View File

@@ -1,42 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-voldemort="http://www.springframework.org/schema/integration/voldemort"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/voldemort http://www.springframework.org/schema/integration/voldemort/spring-integration-voldemort.xsd">
<import resource="../common-test-context.xml" />
<int:channel id="voldemortOutboundPutChannel" />
<int:channel id="voldemortOutboundPutConstantKeyChannel" />
<int:channel id="voldemortOutboundDeleteChannel" />
<int:channel id="voldemortStoppedChannel" />
<int:channel id="voldemortOrderChannel" />
<int-voldemort:outbound-channel-adapter id="voldemortPut" channel="voldemortOutboundPutChannel"
store-client="storeClient" />
<int-voldemort:outbound-channel-adapter id="voldemortPutSingleKey" channel="voldemortOutboundPutConstantKeyChannel"
store-key="constant-key" store-client="storeClient" />
<int-voldemort:outbound-channel-adapter id="voldemortDelete" channel="voldemortOutboundDeleteChannel"
store-client="storeClient" store-key-expression="payload.id"
persist-mode="DELETE" />
<int-voldemort:outbound-channel-adapter id="voldemortStopped" channel="voldemortOutboundPutChannel"
store-client="storeClient"
auto-startup="false" />
<bean id="messageUpdater" class="org.springframework.integration.voldemort.test.outbound.MessageUpdatingServiceActivator" />
<int-voldemort:outbound-channel-adapter id="voldemortOrder" channel="voldemortOrderChannel" order="2"
store-client="storeClient" store-key-expression="payload.id" />
<int:service-activator id="testingServiceActivator" input-channel="voldemortOrderChannel" order="1"
ref="messageUpdater" method="updateMessage" />
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-voldemort="http://www.springframework.org/schema/integration/voldemort"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/voldemort http://www.springframework.org/schema/integration/voldemort/spring-integration-voldemort.xsd">
<import resource="../common-test-context.xml" />
<int:channel id="voldemortOutboundPutChannel" />
<int:channel id="voldemortOutboundPutConstantKeyChannel" />
<int:channel id="voldemortOutboundDeleteChannel" />
<int:channel id="voldemortStoppedChannel" />
<int:channel id="voldemortOrderChannel" />
<int-voldemort:outbound-channel-adapter id="voldemortPut" channel="voldemortOutboundPutChannel"
store-client="storeClient" />
<int-voldemort:outbound-channel-adapter id="voldemortPutSingleKey" channel="voldemortOutboundPutConstantKeyChannel"
store-key="constant-key" store-client="storeClient" />
<int-voldemort:outbound-channel-adapter id="voldemortDelete" channel="voldemortOutboundDeleteChannel"
store-client="storeClient" store-key-expression="payload.id"
persist-mode="DELETE" />
<int-voldemort:outbound-channel-adapter id="voldemortStopped" channel="voldemortOutboundPutChannel"
store-client="storeClient"
auto-startup="false" />
<bean id="messageUpdater" class="org.springframework.integration.voldemort.test.outbound.MessageUpdatingServiceActivator" />
<int-voldemort:outbound-channel-adapter id="voldemortOrder" channel="voldemortOrderChannel" order="2"
store-client="storeClient" store-key-expression="payload.id" />
<int:service-activator id="testingServiceActivator" input-channel="voldemortOrderChannel" order="1"
ref="messageUpdater" method="updateMessage" />
</beans>

View File

@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
<import resource="store-test-context.xml" />
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
<int:aggregator input-channel="inputChannel" output-channel="outputChannel" message-store="voldemortMessageStore" />
<import resource="store-test-context.xml" />
<int:channel id="outputChannel">
<int:queue />
</int:channel>
</beans>
<int:aggregator input-channel="inputChannel" output-channel="outputChannel" message-store="voldemortMessageStore" />
<int:channel id="outputChannel">
<int:queue />
</int:channel>
</beans>

View File

@@ -1,25 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="config" class="voldemort.client.ClientConfig">
<property name="bootstrapUrls" value="tcp://localhost:6666" />
</bean>
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="clientFactory" class="voldemort.client.SocketStoreClientFactory" destroy-method="close">
<constructor-arg name="config" ref="config" />
</bean>
<bean id="config" class="voldemort.client.ClientConfig">
<property name="bootstrapUrls" value="tcp://localhost:6666" />
</bean>
<bean id="messageStoreClient" scope="prototype" factory-bean="clientFactory" factory-method="getStoreClient">
<constructor-arg value="test-message-store" />
</bean>
<bean id="clientFactory" class="voldemort.client.SocketStoreClientFactory" destroy-method="close">
<constructor-arg name="config" ref="config" />
</bean>
<bean id="voldemortMessageStore" class="org.springframework.integration.voldemort.store.VoldemortMessageStore">
<constructor-arg name="client" ref="messageStoreClient" />
</bean>
<bean id="messageStoreClient" scope="prototype" factory-bean="clientFactory" factory-method="getStoreClient">
<constructor-arg value="test-message-store" />
</bean>
<bean id="voldemortMessageStorePrototype" scope="prototype"
class="org.springframework.integration.voldemort.store.VoldemortMessageStore">
<constructor-arg name="client" ref="messageStoreClient" />
</bean>
</beans>
<bean id="voldemortMessageStore" class="org.springframework.integration.voldemort.store.VoldemortMessageStore">
<constructor-arg name="client" ref="messageStoreClient" />
</bean>
<bean id="voldemortMessageStorePrototype" scope="prototype"
class="org.springframework.integration.voldemort.store.VoldemortMessageStore">
<constructor-arg name="client" ref="messageStoreClient" />
</bean>
</beans>

View File

@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<stores>
<store>
<name>test-message-store</name>
<owners>lukasz.antoniak@gmail.com</owners>
<persistence>bdb</persistence>
<routing>client</routing>
<replication-factor>1</replication-factor>
<required-reads>1</required-reads>
<required-writes>1</required-writes>
<key-serializer>
<type>string</type>
<schema-info>UTF-8</schema-info>
</key-serializer>
<value-serializer>
<type>java-serialization</type>
</value-serializer>
</store>
</stores>
<store>
<name>test-message-store</name>
<owners>lukasz.antoniak@gmail.com</owners>
<persistence>bdb</persistence>
<routing>client</routing>
<replication-factor>1</replication-factor>
<required-reads>1</required-reads>
<required-writes>1</required-writes>
<key-serializer>
<type>string</type>
<schema-info>UTF-8</schema-info>
</key-serializer>
<value-serializer>
<type>java-serialization</type>
</value-serializer>
</store>
</stores>

View File

@@ -1,34 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<stores>
<store>
<name>test-store</name>
<owners>lukasz.antoniak@gmail.com</owners>
<persistence>bdb</persistence>
<routing>client</routing>
<replication-factor>1</replication-factor>
<required-reads>1</required-reads>
<required-writes>1</required-writes>
<key-serializer>
<type>string</type>
<schema-info>UTF-8</schema-info>
</key-serializer>
<value-serializer>
<type>java-serialization</type>
</value-serializer>
</store>
<store>
<name>test-object-store</name>
<owners>lukasz.antoniak@gmail.com</owners>
<persistence>bdb</persistence>
<routing>client</routing>
<replication-factor>1</replication-factor>
<required-reads>1</required-reads>
<required-writes>1</required-writes>
<key-serializer>
<type>java-serialization</type>
</key-serializer>
<value-serializer>
<type>java-serialization</type>
</value-serializer>
</store>
</stores>
<?xml version="1.0" encoding="UTF-8"?>
<stores>
<store>
<name>test-store</name>
<owners>lukasz.antoniak@gmail.com</owners>
<persistence>bdb</persistence>
<routing>client</routing>
<replication-factor>1</replication-factor>
<required-reads>1</required-reads>
<required-writes>1</required-writes>
<key-serializer>
<type>string</type>
<schema-info>UTF-8</schema-info>
</key-serializer>
<value-serializer>
<type>java-serialization</type>
</value-serializer>
</store>
<store>
<name>test-object-store</name>
<owners>lukasz.antoniak@gmail.com</owners>
<persistence>bdb</persistence>
<routing>client</routing>
<replication-factor>1</replication-factor>
<required-reads>1</required-reads>
<required-writes>1</required-writes>
<key-serializer>
<type>java-serialization</type>
</key-serializer>
<value-serializer>
<type>java-serialization</type>
</value-serializer>
</store>
</stores>