-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/src/reference/resources/xsl/pdf-custom.xsl b/docs/src/reference/resources/xsl/pdf-custom.xsl
deleted file mode 100644
index 9b94a030..00000000
--- a/docs/src/reference/resources/xsl/pdf-custom.xsl
+++ /dev/null
@@ -1,522 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- '1'
- images/admon/
- .png
-
-
-
-
- 24pt
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -5em
- -5em
-
-
-
-
-
- book toc,title
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Spring GemFire
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
- 0
- 0
- 0
- 1
-
-
-
-
- 0
- 0
- 0
-
-
-
- false
-
-
- 11
- 8
-
-
- 1.4
-
-
-
- left
- bold
-
-
- pt
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0.8em
- 0.8em
- 0.8em
-
-
- pt
-
- 0.1em
- 0.1em
- 0.1em
-
-
- 0.6em
- 0.6em
- 0.6em
-
-
- pt
-
- 0.1em
- 0.1em
- 0.1em
-
-
- 0.4em
- 0.4em
- 0.4em
-
-
- pt
-
- 0.1em
- 0.1em
- 0.1em
-
-
- 0.3em
- 0.3em
- 0.3em
-
-
- pt
-
- 0.1em
- 0.1em
- 0.1em
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 4pt
- 4pt
- 4pt
- 4pt
-
-
-
- 0.1pt
- 0.1pt
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- pt
-
-
-
-
- 1em
- 1em
- 1em
- 0.1em
- 0.1em
- 0.1em
-
- #444444
- solid
- 0.1pt
- 0.5em
- 0.5em
- 0.5em
- 0.5em
- 0.5em
- 0.5em
-
-
-
- 1
-
- #F0F0F0
-
-
-
- 0.1em
- 0.1em
- 0.1em
- 0.1em
- 0.1em
- 0.1em
-
-
-
- 0.5em
- 0.5em
- 0.5em
- 0.1em
- 0.1em
- 0.1em
- always
-
-
-
-
-
- normal
- italic
-
-
- pt
-
- false
- 0.1em
- 0.1em
- 0.1em
-
-
-
-
-
- 0
- 1
-
-
- 90
-
-
-
-
-
- figure after
- example after
- equation before
- table before
- procedure before
-
-
-
- 1
-
- 0pt
-
-
- 3
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/gradle.properties b/gradle.properties
index fc45ddf2..d3ceb21a 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -7,7 +7,7 @@ slf4jVersion = 1.6.4
# Common libraries
springVersion = 3.1.1.RELEASE
springDataCommonsVersion = 1.3.0.BUILD-SNAPSHOT
-gemfireVersion = 6.6.2
+gemfireVersion = 6.6.3
# Testing
junitVersion = 4.8.1
@@ -23,4 +23,4 @@ gemfire.range = "[6.5, 7.0)"
# --------------------
# Project wide version
# --------------------
-springGemfireVersion=1.1.1.BUILD-SNAPSHOT
+springGemfireVersion=1.2.0.BUILD-SNAPSHOT
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 45bfb5c8..e3b3376e 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f1c7bed2..fd3d2363 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Jul 19 18:42:40 EEST 2011
+#Sun Jul 01 21:12:28 EEST 2012
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://repo.gradle.org/gradle/distributions/gradle-1.0-milestone-3-bin.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-bin.zip
diff --git a/gradlew b/gradlew
index d8809f15..cf126509 100755
--- a/gradlew
+++ b/gradlew
@@ -1,16 +1,16 @@
#!/bin/bash
##############################################################################
-## ##
-## Gradle wrapper script for UN*X ##
-## ##
+##
+## Gradle start up script for UN*X
+##
##############################################################################
-# Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
-# GRADLE_OPTS="$GRADLE_OPTS -Xmx512m"
-# JAVA_OPTS="$JAVA_OPTS -Xmx512m"
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
-GRADLE_APP_NAME=Gradle
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -42,54 +42,51 @@ case "`uname`" in
;;
esac
-# Attempt to set JAVA_HOME if it's not already set.
-if [ -z "$JAVA_HOME" ] ; then
- if $darwin ; then
- [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home"
- [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
- else
- javaExecutable="`which javac`"
- [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- export JAVA_HOME="$javaHome"
- fi
-fi
-
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
- [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"`
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
-STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
-CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar
-WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties
-# Determine the Java command to use to start the JVM.
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
else
- JAVACMD="java"
+ PRG=`dirname "$PRG"`"/$link"
fi
-fi
-if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/"
+APP_HOME="`pwd -P`"
+cd "$SAVED"
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
-fi
-if [ -z "$JAVA_HOME" ] ; then
- warn "JAVA_HOME environment variable is not set"
fi
# Increase the maximum file descriptors if we can.
@@ -108,15 +105,14 @@ if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
fi
fi
-# For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name
+# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
- JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME"
-# we may also want to set -Xdock:image
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
- JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"`
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
@@ -143,7 +139,7 @@ if $cygwin ; then
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
- done
+ done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
@@ -158,11 +154,11 @@ if $cygwin ; then
esac
fi
-GRADLE_APP_BASE_NAME=`basename "$0"`
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-exec "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
- -classpath "$CLASSPATH" \
- -Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \
- -Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \
- $STARTER_MAIN_CLASS \
- "$@"
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 479fdddb..8a0b282a 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,24 +1,37 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
-@rem ##
-@rem Gradle startup script for Windows ##
-@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 Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
-@rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512m
-@rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512m
+@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=.\
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
@rem Find java.exe
-set JAVA_EXE=java.exe
-if not defined JAVA_HOME goto init
+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
@@ -29,14 +42,14 @@ 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.
-echo.
-goto end
+
+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
+if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -56,27 +69,22 @@ set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
-set STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
-set CLASSPATH=%DIRNAME%\gradle\wrapper\gradle-wrapper.jar
-set WRAPPER_PROPERTIES=%DIRNAME%\gradle\wrapper\gradle-wrapper.properties
-
-set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%"
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS%
+"%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
-if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1
-
+: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 "%ERRORLEVEL%"
-exit /b "%ERRORLEVEL%"
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
-:omega
\ No newline at end of file
+:omega
diff --git a/maven.gradle b/maven.gradle
index 4c5d933f..fbf2ac92 100644
--- a/maven.gradle
+++ b/maven.gradle
@@ -1,145 +1,64 @@
apply plugin: 'maven'
-// Create a source jar for uploading
-task sourceJar(type: Jar, dependsOn: jar) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
+ext.optionalDeps = []
+ext.providedDeps = []
-// Create a javadoc jar for uploading
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-artifacts {
- archives sourceJar
- archives javadocJar
-}
-
-// Configuration for SpringSource s3 maven deployer
-configurations {
- deployerJars
-}
-dependencies {
- deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE"
-}
-
-// Remove the archive configuration from the runtime configuration, so that anything added to archives
-// (such as the source jar) is no longer included in the runtime classpath
-configurations.default.extendsFrom = [configurations.runtime] as Set
-// Add the main jar into the default configuration
-artifacts { 'default' jar }
-
-gradle.taskGraph.whenReady {graph ->
- if (graph.hasTask(uploadArchives)) {
- // check properties defined and fail early
- s3AccessKey
- s3SecretAccessKey
- }
-}
-
-def deployer = null
-
-uploadArchives {
- description = "Maven deploy of archives artifacts to SpringSource Maven repos" // url appended below
- group = "Distribution"
- // Maven deployment
- def releaseRepositoryUrl = "file://${project.properties.mavenSyncRepoDir}"
- def milestoneRepositoryUrl = 's3://maven.springframework.org/milestone'
- def snapshotRepositoryUrl = 's3://maven.springframework.org/snapshot'
-
- // add a configuration with a classpath that includes our s3 maven deployer
- configurations { deployerJars }
- dependencies {
- deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE"
- }
-
- deployer = repositories.mavenDeployer {
- configuration = configurations.deployerJars
- // releaseBuild
- if (releaseBuild) {
- logger.info("Deploying to local Maven repo " + releaseRepositoryUrl)
- // "mavenSyncRepoDir" should be set in properties
- repository(url: releaseRepositoryUrl)
- } else {
- s3credentials = [userName: project.properties.s3AccessKey, passphrase: project.properties.s3SecretAccessKey]
- repository(url: milestoneRepositoryUrl) {
- authentication(s3credentials)
- }
- snapshotRepository(url: snapshotRepositoryUrl) {
- authentication(s3credentials)
- }
- }
- }
-
- customizePom(deployer.pom)
-}
+ext.optional = { optionalDeps << it }
+ext.provided = { providedDeps << it }
install {
- customizePom(repositories.mavenInstaller.pom)
+ repositories.mavenInstaller {
+ customizePom(pom, project)
+ }
}
-def customizePom(pom) {
- def optionalDeps = ['log4j','jsr250-api']
-
- //pom.scopeMappings.addMapping(10, configurations.provided, 'provided')
- pom.whenConfigured { p ->
- // Remove test scope dependencies from published poms
- p.dependencies = p.dependencies.findAll {it.scope != 'test'}
-
- // Flag optional deps
- def opDeps = configurations.testRuntime.allDependencies.findAll { gradleDep ->
- gradleDep.asDynamicObject.hasProperty('optional') && gradleDep.optional
+def customizePom(pom, gradleProject) {
+ pom.whenConfigured { generatedPom ->
+ // respect 'optional' and 'provided' dependencies
+ gradleProject.optionalDeps.each { dep ->
+ generatedPom.dependencies.find { it.artifactId == dep.name }?.optional = true
+ }
+ gradleProject.providedDeps.each { dep ->
+ generatedPom.dependencies.find { it.artifactId == dep.name }?.scope = 'provided'
}
- p.dependencies.findAll { dep ->
- optionalDeps.contains(dep.artifactId) ||
- dep.groupId.startsWith('org.slf4j') ||
- opDeps.any { op ->
- (dep.groupId == op.group && dep.artifactId == op.name)
- }
- }*.optional = true
-
- p.groupId = "org.springframework.data"
- }
-
- pom.project {
- name = project.description
- description = project.description
- url = 'http://github.com/SpringSource/spring-gemfire'
- organization {
- name = 'SpringSource'
- url = 'http://www.springsource.org/spring-gemfire'
+ // eliminate test-scoped dependencies (no need in maven central poms)
+ generatedPom.dependencies.removeAll { dep ->
+ dep.scope == 'test'
}
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution 'repo'
- }
- }
- scm {
+ // add all items necessary for maven central publication
+ generatedPom.project {
+ name = gradleProject.description
+ description = gradleProject.description
url = 'http://github.com/SpringSource/spring-gemfire'
- connection = 'scm:git:git://github.com/SpringSource/spring-gemfire'
- developerConnection = 'scm:git:git://github.com/SpringSource/spring-gemfire'
- }
- developers {
- developer {
- id = 'costin'
- name = 'Costin Leau'
- email = 'cleau@vmware.com'
+ organization {
+ name = 'SpringSource'
+ url = 'http://www.springsource.org/spring-gemfire'
}
- }
-
- // similar to Spring's configuration
- dependencies {
- dependency {
- artifactId = groupId = 'commons-logging'
- scope = 'compile'
- optional = 'true'
- version = '1.1.1'
+ licenses {
+ license {
+ name 'The Apache Software License, Version 2.0'
+ url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ distribution 'repo'
+ }
+ }
+ scm {
+ url = 'http://github.com/SpringSource/spring-gemfire'
+ connection = 'scm:git:git://github.com/SpringSource/spring-gemfire'
+ developerConnection = 'scm:git:git://github.com/SpringSource/spring-gemfire'
+ }
+ developers {
+ developer {
+ id = 'costin'
+ name = 'Costin Leau'
+ email = 'cleau@vmware.com'
+ }
+ developer {
+ id = 'dturanski'
+ name = 'David Turanski'
+ email = 'dturanski@vmware.com'
+ }
}
}
}
diff --git a/samples/hello-world/build.gradle b/samples/hello-world/build.gradle
index 7fab5087..789093dc 100644
--- a/samples/hello-world/build.gradle
+++ b/samples/hello-world/build.gradle
@@ -3,43 +3,35 @@ description = 'Spring Data GemFire Samples - Hello World'
apply plugin: 'base'
apply plugin: 'idea'
apply plugin: 'java'
-apply plugin: 'eclipse' // `gradle eclipse` to generate .classpath/.project
+apply plugin: 'eclipse'
+apply plugin: 'application'
[compileJava, compileTestJava]*.options*.compilerArgs = ["-Xlint:-serial"]
-
repositories {
- mavenLocal()
- mavenCentral()
// Public Spring artefacts
- mavenRepo name: "springsource-org-release", urls: "http://repository.springsource.com/maven/bundles/release"
- mavenRepo name: "spring-release", urls: "http://maven.springframework.org/release"
- mavenRepo name: "spring-milestone", urls: "http://maven.springframework.org/milestone"
- mavenRepo name: "spring-snapshot", urls: "http://maven.springframework.org/snapshot"
- mavenRepo name: "sonatype-snapshot", urls: "http://oss.sonatype.org/content/repositories/snapshots"
- mavenRepo name: "ext-snapshots", urls: "http://springframework.svn.sourceforge.net/svnroot/springframework/repos/repo-ext/"
- mavenRepo name: "gemfire-release-repo", urls: "http://dist.gemstone.com/maven/release"
+ maven { url "http://repo.springsource.org/libs-snapshot" }
+ mavenLocal()
}
dependencies {
compile "org.springframework.data:spring-data-gemfire:$version"
compile "javax.inject:javax.inject:1"
compile "javax.annotation:jsr250-api:1.0"
+
+ runtime "log4j:log4j:$log4jVersion"
+ runtime "org.slf4j:slf4j-log4j12:$slf4jVersion"
testCompile "junit:junit:$junitVersion"
testCompile "org.springframework:spring-test:$springVersion"
}
-sourceCompatibility = 1.5
-targetCompatibility = 1.5
-
-task run(type: JavaExec) {
- description = 'Runs the application'
- main = "org.springframework.data.gemfire.samples.helloworld.Main"
- classpath = sourceSets.main.runtimeClasspath
- standardInput = System.in
- systemProperties['java.net.preferIPv4Stack'] = 'true'
+run {
+ main = "org.springframework.data.gemfire.samples.helloworld.Main"
+ classpath = sourceSets.main.runtimeClasspath
+ standardInput = System.in
+ systemProperties['java.net.preferIPv4Stack'] = 'true'
}
defaultTasks 'run'
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index c493e64a..f79b008d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,5 +1 @@
rootProject.name = 'spring-data-gemfire'
-
-include 'docs'
-
-docs = findProject(':docs')
\ No newline at end of file
diff --git a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java
index 478d5d1b..d0922b23 100644
--- a/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/CacheFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
@@ -16,6 +16,9 @@
package org.springframework.data.gemfire;
+import java.io.File;
+import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.apache.commons.logging.Log;
@@ -33,33 +36,44 @@ import org.springframework.dao.DataAccessException;
import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
+import org.springframework.util.CollectionUtils;
import com.gemstone.gemfire.GemFireException;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheClosedException;
import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.CacheTransactionManager;
+import com.gemstone.gemfire.cache.DynamicRegionFactory;
import com.gemstone.gemfire.cache.GemFireCache;
+import com.gemstone.gemfire.cache.TransactionListener;
+import com.gemstone.gemfire.cache.TransactionWriter;
import com.gemstone.gemfire.distributed.DistributedMember;
import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
+import com.gemstone.gemfire.internal.datasource.ConfigProperty;
+import com.gemstone.gemfire.internal.jndi.JNDIInvoker;
import com.gemstone.gemfire.pdx.PdxSerializable;
import com.gemstone.gemfire.pdx.PdxSerializer;
/**
- * Factory used for configuring a Gemfire Cache manager. Allows either retrieval of an existing, opened cache
- * or the creation of a new one.
-
- *
This class implements the {@link org.springframework.dao.support.PersistenceExceptionTranslator}
+ * Factory used for configuring a Gemfire Cache manager. Allows either retrieval
+ * of an existing, opened cache or the creation of a new one.
+ *
+ *
+ * This class implements the
+ * {@link org.springframework.dao.support.PersistenceExceptionTranslator}
* interface, as auto-detected by Spring's
- * {@link org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor},
- * for AOP-based translation of native exceptions to Spring DataAccessExceptions.
- * Hence, the presence of this class automatically enables
- * a PersistenceExceptionTranslationPostProcessor to translate GemFire exceptions.
+ * {@link org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor}
+ * , for AOP-based translation of native exceptions to Spring
+ * DataAccessExceptions. Hence, the presence of this class automatically enables
+ * a PersistenceExceptionTranslationPostProcessor to translate GemFire
+ * exceptions.
*
* @author Costin Leau
+ * @author David Turanski
*/
public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanClassLoaderAware, DisposableBean,
InitializingBean, FactoryBean, PersistenceExceptionTranslator {
-
/**
* Inner class to avoid a hard dependency on the GemFire 6.6 API.
*
@@ -67,12 +81,13 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
*/
private class PdxOptions implements Runnable {
- private CacheFactory factory;
+ private final CacheFactory factory;
PdxOptions(CacheFactory factory) {
this.factory = factory;
}
+ @Override
public void run() {
if (pdxSerializer != null) {
Assert.isAssignable(PdxSerializer.class, pdxSerializer.getClass(), "Invalid pdx serializer used");
@@ -93,24 +108,157 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
}
}
+ private class InternalCacheOptions implements Runnable {
+ private final GemFireCacheImpl cacheImpl;
+
+ InternalCacheOptions(GemFireCache cache) {
+ this.cacheImpl = (GemFireCacheImpl) cache;
+ }
+
+ @Override
+ public void run() {
+ if (lockLease != null) {
+ cacheImpl.setLockLease(lockLease);
+ }
+ if (lockTimeout != null) {
+ cacheImpl.setLockTimeout(lockTimeout);
+ }
+ if (searchTimeout != null) {
+ cacheImpl.setSearchTimeout(searchTimeout);
+ }
+ if (messageSyncInterval != null) {
+ cacheImpl.setMessageSyncInterval(messageSyncInterval);
+ }
+ }
+ }
+
+ public static class DynamicRegionSupport {
+ private String diskDir;
+
+ private String poolName;
+
+ private Boolean persistent = Boolean.TRUE;
+
+ private Boolean registerInterest = Boolean.TRUE;
+
+ public String getDiskDir() {
+ return diskDir;
+ }
+
+ public void setDiskDir(String diskDir) {
+ this.diskDir = diskDir;
+ }
+
+ public Boolean getPersistent() {
+ return persistent;
+ }
+
+ public void setPersistent(Boolean persistent) {
+ this.persistent = persistent;
+ }
+
+ public Boolean getRegisterInterest() {
+ return registerInterest;
+ }
+
+ public void setRegisterInterest(Boolean registerInterest) {
+ this.registerInterest = registerInterest;
+ }
+
+ public String getPoolName() {
+ return poolName;
+ }
+
+ public void setPoolName(String poolName) {
+ this.poolName = poolName;
+ }
+
+ public void initializeDynamicRegionFactory() {
+ DynamicRegionFactory.Config config = null;
+ if (diskDir == null) {
+ config = new DynamicRegionFactory.Config(null, poolName, persistent, registerInterest);
+ }
+ else {
+ config = new DynamicRegionFactory.Config(new File(diskDir), poolName, persistent, registerInterest);
+ }
+ DynamicRegionFactory.get().open(config);
+ }
+ }
+
+ public static class JndiDataSource {
+ private Map attributes;
+
+ private List props;
+
+ public Map getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Map attributes) {
+ this.attributes = attributes;
+ }
+
+ public List getProps() {
+ return props;
+ }
+
+ public void setProps(List props) {
+ this.props = props;
+ }
+ }
+
protected final Log log = LogFactory.getLog(getClass());
private GemFireCache cache;
+
private Resource cacheXml;
+
private Properties properties;
+
private ClassLoader beanClassLoader;
+
private GemfireBeanFactoryLocator factoryLocator;
private BeanFactory beanFactory;
+
private String beanName;
+
private boolean useBeanFactoryLocator = true;
+
// PDX options
protected Object pdxSerializer;
+
protected Boolean pdxPersistent;
+
protected Boolean pdxReadSerialized;
+
protected Boolean pdxIgnoreUnreadFields;
+
protected String pdxDiskStoreName;
+ protected Boolean copyOnRead;
+
+ protected Integer lockTimeout;
+
+ protected Integer lockLease;
+
+ protected Integer messageSyncInterval;
+
+ protected Integer searchTimeout;
+
+ protected List transactionListeners;
+
+ protected TransactionWriter transactionWriter;
+
+ protected Float evictionHeapPercentage;
+
+ protected Float criticalHeapPercentage;
+
+ protected DynamicRegionSupport dynamicRegionSupport;
+
+ protected List jndiDataSources;
+
+ @Override
public void afterPropertiesSet() throws Exception {
// initialize locator
if (useBeanFactoryLocator) {
@@ -132,7 +280,11 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
try {
cache = fetchCache();
msg = "Retrieved existing";
- } catch (CacheClosedException ex) {
+ }
+ catch (CacheClosedException ex) {
+
+ initializeDynamicRegionFactory();
+
Object factory = createFactory(cfgProps);
// GemFire 6.6 specific options
@@ -147,6 +299,11 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
cache = createCache(factory);
msg = "Created";
}
+ if (this.copyOnRead != null) {
+ cache.setCopyOnRead(this.copyOnRead);
+ }
+
+ applyInternalCacheOptions();
DistributedSystem system = cache.getDistributedSystem();
DistributedMember member = system.getDistributedMember();
@@ -159,19 +316,80 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
if (cacheXml != null) {
cache.loadCacheXml(cacheXml.getInputStream());
- if (log.isDebugEnabled())
+ if (log.isDebugEnabled()) {
log.debug("Initialized cache from " + cacheXml);
+ }
}
-
-
- } finally {
+ setHeapPercentages();
+ registerTransactionListeners();
+ registerTransactionWriter();
+ registerJndiDataSources();
+ }
+ finally {
th.setContextClassLoader(oldTCCL);
}
}
+ private void registerJndiDataSources() {
+ if (jndiDataSources != null) {
+ for (JndiDataSource jndiDataSource : jndiDataSources) {
+ JNDIInvoker.mapDatasource(jndiDataSource.getAttributes(), jndiDataSource.getProps());
+ }
+ }
+ }
+
/**
- * Sets the PDX properties for the given object. Note this is implementation specific as it depends on the type
- * of the factory passed in.
+ * If dynamic regions are enabled, create a DynamicRegionFactory before
+ * creating the cache
+ */
+ private void initializeDynamicRegionFactory() {
+ if (dynamicRegionSupport != null) {
+ dynamicRegionSupport.initializeDynamicRegionFactory();
+ }
+ }
+
+ private void setHeapPercentages() {
+ if (criticalHeapPercentage != null) {
+ Assert.isTrue(criticalHeapPercentage > 0.0 && criticalHeapPercentage <= 100.0,
+ "invalid value specified for criticalHeapPercentage :" + criticalHeapPercentage
+ + ". Must be > 0.0 and <= 100.0");
+ cache.getResourceManager().setCriticalHeapPercentage(criticalHeapPercentage);
+
+ }
+
+ if (evictionHeapPercentage != null) {
+ Assert.isTrue(evictionHeapPercentage > 0.0 && evictionHeapPercentage <= 100.0,
+ "invalid value specified for evictionHeapPercentage :" + evictionHeapPercentage
+ + ". Must be > 0.0 and <= 100.0");
+ cache.getResourceManager().setEvictionHeapPercentage(evictionHeapPercentage);
+ }
+
+ }
+
+ /**
+ * Register a transaction writer if declared
+ */
+ protected void registerTransactionWriter() {
+ if (transactionWriter != null) {
+ cache.getCacheTransactionManager().setWriter(transactionWriter);
+ }
+ }
+
+ /**
+ * Register all declared transaction listeners
+ */
+ protected void registerTransactionListeners() {
+ if (!CollectionUtils.isEmpty(transactionListeners)) {
+ CacheTransactionManager txManager = cache.getCacheTransactionManager();
+ for (TransactionListener transactionListener : transactionListeners) {
+ txManager.addListener(transactionListener);
+ }
+ }
+ }
+
+ /**
+ * Sets the PDX properties for the given object. Note this is implementation
+ * specific as it depends on the type of the factory passed in.
*
* @param factory
*/
@@ -181,6 +399,10 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
}
}
+ protected void applyInternalCacheOptions() {
+ new InternalCacheOptions(cache).run();
+ }
+
protected Object createFactory(Properties props) {
return new CacheFactory(props);
}
@@ -198,6 +420,7 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
return cfgProps;
}
+ @Override
public void destroy() throws Exception {
if (cache != null && !cache.isClosed()) {
cache.close();
@@ -211,6 +434,7 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
}
}
+ @Override
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
if (ex instanceof GemFireException) {
return GemfireCacheUtils.convertGemfireAccessException((GemFireException) ex);
@@ -226,26 +450,32 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
return null;
}
+ @Override
public GemFireCache getObject() throws Exception {
return cache;
}
+ @Override
public Class extends GemFireCache> getObjectType() {
return (cache != null ? cache.getClass() : Cache.class);
}
+ @Override
public boolean isSingleton() {
return true;
}
+ @Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.beanClassLoader = classLoader;
}
+ @Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
+ @Override
public void setBeanName(String name) {
this.beanName = name;
}
@@ -269,9 +499,11 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
}
/**
- * Indicates whether a bean factory locator is enabled (default) for this cache definition or not. The locator stores
- * the enclosing bean factory reference to allow auto-wiring of Spring beans into GemFire managed classes. Usually disabled
- * when the same cache is used in multiple application context/bean factories inside the same VM.
+ * Indicates whether a bean factory locator is enabled (default) for this
+ * cache definition or not. The locator stores the enclosing bean factory
+ * reference to allow auto-wiring of Spring beans into GemFire managed
+ * classes. Usually disabled when the same cache is used in multiple
+ * application context/bean factories inside the same VM.
*
* @param usage true if the bean factory locator is used underneath or not
*/
@@ -280,8 +512,9 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
}
/**
- * Sets the {@link PdxSerializable} for this cache. Applicable on GemFire 6.6 or higher.
- * The argument is of type object for compatibility with GemFire 6.5.
+ * Sets the {@link PdxSerializable} for this cache. Applicable on GemFire
+ * 6.6 or higher. The argument is of type object for compatibility with
+ * GemFire 6.5.
*
* @param serializer pdx serializer configured for this cache.
*/
@@ -290,8 +523,9 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
}
/**
- * Sets the object preference to PdxInstance type. Applicable on GemFire 6.6 or higher.
- *
+ * Sets the object preference to PdxInstance type. Applicable on GemFire 6.6
+ * or higher.
+ *
* @param pdxPersistent the pdxPersistent to set
*/
public void setPdxPersistent(Boolean pdxPersistent) {
@@ -299,7 +533,8 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
}
/**
- * Controls whether the type metadata for PDX objects is persisted to disk. Applicable on GemFire 6.6 or higher.
+ * Controls whether the type metadata for PDX objects is persisted to disk.
+ * Applicable on GemFire 6.6 or higher.
*
* @param pdxReadSerialized the pdxReadSerialized to set
*/
@@ -308,7 +543,8 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
}
/**
- * Controls whether pdx ignores fields that were unread during deserialization. Applicable on GemFire 6.6 or higher.
+ * Controls whether pdx ignores fields that were unread during
+ * deserialization. Applicable on GemFire 6.6 or higher.
*
* @param pdxIgnoreUnreadFields the pdxIgnoreUnreadFields to set
*/
@@ -317,8 +553,9 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
}
/**
- * Set the disk store that is used for PDX meta data. Applicable on GemFire 6.6 or higher.
- *
+ * Set the disk store that is used for PDX meta data. Applicable on GemFire
+ * 6.6 or higher.
+ *
* @param pdxDiskStoreName the pdxDiskStoreName to set
*/
public void setPdxDiskStoreName(String pdxDiskStoreName) {
@@ -331,4 +568,48 @@ public class CacheFactoryBean implements BeanNameAware, BeanFactoryAware, BeanCl
protected BeanFactory getBeanFactory() {
return beanFactory;
}
+
+ public void setCopyOnRead(boolean copyOnRead) {
+ this.copyOnRead = copyOnRead;
+ }
+
+ public void setLockTimeout(int lockTimeout) {
+ this.lockTimeout = lockTimeout;
+ }
+
+ public void setLockLease(int lockLease) {
+ this.lockLease = lockLease;
+ }
+
+ public void setMessageSyncInterval(int messageSyncInterval) {
+ this.messageSyncInterval = messageSyncInterval;
+ }
+
+ public void setSearchTimeout(int searchTimeout) {
+ this.searchTimeout = searchTimeout;
+ }
+
+ public void setEvictionHeapPercentage(Float evictionHeapPercentage) {
+ this.evictionHeapPercentage = evictionHeapPercentage;
+ }
+
+ public void setCriticalHeapPercentage(Float criticalHeapPercentage) {
+ this.criticalHeapPercentage = criticalHeapPercentage;
+ }
+
+ public void setTransactionListeners(List transactionListeners) {
+ this.transactionListeners = transactionListeners;
+ }
+
+ public void setTransactionWriter(TransactionWriter transactionWriter) {
+ this.transactionWriter = transactionWriter;
+ }
+
+ public void setDynamicRegionSupport(DynamicRegionSupport dynamicRegionSupport) {
+ this.dynamicRegionSupport = dynamicRegionSupport;
+ }
+
+ public void setJndiDataSources(List jndiDataSources) {
+ this.jndiDataSources = jndiDataSources;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/springframework/data/gemfire/DeclarableSupport.java b/src/main/java/org/springframework/data/gemfire/DeclarableSupport.java
index 7fd60b62..e93ec3e7 100644
--- a/src/main/java/org/springframework/data/gemfire/DeclarableSupport.java
+++ b/src/main/java/org/springframework/data/gemfire/DeclarableSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
@@ -25,18 +25,21 @@ import com.gemstone.gemfire.cache.CacheCallback;
import com.gemstone.gemfire.cache.Declarable;
/**
- * Convenience class for Spring-aware GemFire Declarable components.
- * Provides a reference to the current Spring application context, e.g. for bean lookup or resource loading.
+ * Convenience class for Spring-aware GemFire Declarable components. Provides a
+ * reference to the current Spring application context, e.g. for bean lookup or
+ * resource loading.
*
- * Note that in most cases, one can just declare the same components as Spring beans, through
- * {@link RegionFactoryBean} which gives access to the full container capabilities and does not enforce the
- * {@link Declarable} interface to be implemented.
+ * Note that in most cases, one can just declare the same components as Spring
+ * beans, through {@link RegionFactoryBean} which gives access to the full
+ * container capabilities and does not enforce the {@link Declarable} interface
+ * to be implemented.
*
* @author Costin Leau
*/
public abstract class DeclarableSupport implements CacheCallback, Declarable {
private String factoryKey = null;
+
private BeanFactoryReference bfReference = null;
public DeclarableSupport() {
@@ -48,8 +51,9 @@ public abstract class DeclarableSupport implements CacheCallback, Declarable {
*
* {@inheritDoc}
*
- * @see #setFactoryKey(String)
+ * @see #setFactoryKey(String)
*/
+ @Override
public final void init(Properties props) {
bfReference = new GemfireBeanFactoryLocator().useBeanFactory(factoryKey);
initInstance(props);
@@ -67,15 +71,16 @@ public abstract class DeclarableSupport implements CacheCallback, Declarable {
return bfReference.getFactory();
}
+ @Override
public void close() {
bfReference.release();
bfReference = null;
}
/**
- * Sets the key under which the enclosing beanFactory can be found.
- * Needed only if multiple beanFactories are used with GemFire inside
- * the same class loader / class space.
+ * Sets the key under which the enclosing beanFactory can be found. Needed
+ * only if multiple beanFactories are used with GemFire inside the same
+ * class loader / class space.
*
* @see GemfireBeanFactoryLocator
* @param key
diff --git a/src/main/java/org/springframework/data/gemfire/DiskStoreFactoryBean.java b/src/main/java/org/springframework/data/gemfire/DiskStoreFactoryBean.java
new file mode 100644
index 00000000..bf1236ad
--- /dev/null
+++ b/src/main/java/org/springframework/data/gemfire/DiskStoreFactoryBean.java
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2010-2012 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.gemfire;
+
+import java.io.File;
+import java.util.List;
+
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
+
+import com.gemstone.gemfire.cache.DiskStore;
+import com.gemstone.gemfire.cache.DiskStoreFactory;
+import com.gemstone.gemfire.cache.GemFireCache;
+
+/**
+ * FactoryBean for creating a DiskStore
+ * @author David Turanski
+ */
+public class DiskStoreFactoryBean implements FactoryBean, InitializingBean, BeanNameAware {
+
+ private DiskStoreFactory diskStoreFactory;
+
+ private Boolean autoCompact;
+
+ private Boolean allowForceCompaction;
+
+ private Integer maxOplogSize;
+
+ private Integer timeInterval;
+
+ private Integer queueSize;
+
+ private Integer compactionThreshold;
+
+ private Integer writeBufferSize;
+
+ private GemFireCache cache;
+
+ private String name;
+
+ private List diskDirs;
+
+ @Override
+ public DiskStore getObject() throws Exception {
+ return diskStoreFactory.create(name == null ? DiskStoreFactory.DEFAULT_DISK_STORE_NAME : name);
+ }
+
+ @Override
+ public Class> getObjectType() {
+ return DiskStore.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ Assert.notNull(cache, "Cache property must be set");
+ diskStoreFactory = cache.createDiskStoreFactory();
+
+ if (allowForceCompaction != null) {
+ diskStoreFactory.setAllowForceCompaction(allowForceCompaction);
+ }
+ if (compactionThreshold != null) {
+ diskStoreFactory.setCompactionThreshold(compactionThreshold);
+ }
+ if (autoCompact != null) {
+ diskStoreFactory.setAutoCompact(autoCompact);
+ }
+ if (queueSize != null) {
+ diskStoreFactory.setQueueSize(queueSize);
+ }
+ if (writeBufferSize != null) {
+ diskStoreFactory.setWriteBufferSize(writeBufferSize);
+ }
+ if (timeInterval != null) {
+ diskStoreFactory.setTimeInterval(timeInterval);
+ }
+ if (maxOplogSize != null) {
+ diskStoreFactory.setMaxOplogSize(maxOplogSize);
+ }
+
+ if (!CollectionUtils.isEmpty(diskDirs)) {
+ File[] diskDirFiles = new File[diskDirs.size()];
+ int[] diskDirSizes = new int[diskDirs.size()];
+ for (int i = 0; i < diskDirs.size(); i++) {
+ DiskDir diskDir = diskDirs.get(i);
+ diskDirFiles[i] = new File(diskDir.location);
+ diskDirSizes[i] = diskDir.maxSize == null ? DiskStoreFactory.DEFAULT_DISK_DIR_SIZE : diskDir.maxSize;
+ }
+ diskStoreFactory.setDiskDirsAndSizes(diskDirFiles, diskDirSizes);
+ }
+ }
+
+ public void setCache(GemFireCache cache) {
+ this.cache = cache;
+ }
+
+ public void setAutoCompact(Boolean autoCompact) {
+ this.autoCompact = autoCompact;
+ }
+
+ public void setAllowForceCompaction(Boolean allowForceCompaction) {
+ this.allowForceCompaction = allowForceCompaction;
+ }
+
+ public void setMaxOplogSize(Integer maxOplogSize) {
+ this.maxOplogSize = maxOplogSize;
+ }
+
+ public void setTimeInterval(Integer timeInterval) {
+ this.timeInterval = timeInterval;
+ }
+
+ public void setQueueSize(Integer queueSize) {
+ this.queueSize = queueSize;
+ }
+
+ public void setCompactionThreshold(Integer compactionThreshold) {
+ this.compactionThreshold = compactionThreshold;
+ }
+
+ public void setWriteBufferSize(Integer writeBufferSize) {
+ this.writeBufferSize = writeBufferSize;
+ }
+
+ public void setDiskDirs(List diskDirs) {
+ this.diskDirs = diskDirs;
+ }
+
+ @Override
+ public void setBeanName(String name) {
+ this.name = name;
+ }
+
+ public static class DiskDir {
+ final String location;
+
+ final Integer maxSize;
+
+ public DiskDir(String location, int maxSize) {
+ this.location = location;
+ this.maxSize = maxSize;
+ }
+
+ public DiskDir(String location) {
+ this.location = location;
+ this.maxSize = null;
+ }
+ }
+}
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireAccessor.java b/src/main/java/org/springframework/data/gemfire/GemfireAccessor.java
index fa847eb6..ebe738ab 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireAccessor.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireAccessor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireBeanFactoryLocator.java b/src/main/java/org/springframework/data/gemfire/GemfireBeanFactoryLocator.java
index 2b0eeca2..2f724f82 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireBeanFactoryLocator.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireBeanFactoryLocator.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireCacheUtils.java b/src/main/java/org/springframework/data/gemfire/GemfireCacheUtils.java
index cc444b80..e299f379 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireCacheUtils.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireCacheUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireCallback.java b/src/main/java/org/springframework/data/gemfire/GemfireCallback.java
index f20f767e..a8c1a3d7 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireCallback.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireCallback.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireCancellationException.java b/src/main/java/org/springframework/data/gemfire/GemfireCancellationException.java
index 44d1eebd..66975a08 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireCancellationException.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireCancellationException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireIndexException.java b/src/main/java/org/springframework/data/gemfire/GemfireIndexException.java
index 937e824b..50a07a84 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireIndexException.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireIndexException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireQueryException.java b/src/main/java/org/springframework/data/gemfire/GemfireQueryException.java
index 600d1dbc..b0a1c483 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireQueryException.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireQueryException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireSystemException.java b/src/main/java/org/springframework/data/gemfire/GemfireSystemException.java
index 5c7e5823..3611db75 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireSystemException.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireSystemException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireTemplate.java b/src/main/java/org/springframework/data/gemfire/GemfireTemplate.java
index 28c6a42b..7f9b0e71 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireTemplate.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireTemplate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireTransactionCommitException.java b/src/main/java/org/springframework/data/gemfire/GemfireTransactionCommitException.java
index d1545cde..ddc5a470 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireTransactionCommitException.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireTransactionCommitException.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/GemfireTransactionManager.java b/src/main/java/org/springframework/data/gemfire/GemfireTransactionManager.java
index d7c17f9f..d6207184 100644
--- a/src/main/java/org/springframework/data/gemfire/GemfireTransactionManager.java
+++ b/src/main/java/org/springframework/data/gemfire/GemfireTransactionManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
@@ -33,22 +33,26 @@ import com.gemstone.gemfire.cache.CacheTransactionManager;
import com.gemstone.gemfire.cache.Region;
/**
- * Local transaction manager for GemFire Enterprise Fabric (GEF). Provides a {@link PlatformTransactionManager}
- * implementation for a single GemFire {@link CacheTransactionManager}.
+ * Local transaction manager for GemFire Enterprise Fabric (GEF). Provides a
+ * {@link PlatformTransactionManager} implementation for a single GemFire
+ * {@link CacheTransactionManager}.
*
- * Binds one or multiple GemFire regions for the specified {@link Cache} to the thread, potentially allowing for one
- * region per cache model.
+ * Binds one or multiple GemFire regions for the specified {@link Cache} to the
+ * thread, potentially allowing for one region per cache model.
*
*
- * This local strategy is an alternative to executing cache operations within JTA transactions. Its advantage is that
- * is able to work in any environment, for example a stand-alone application or a test suite. It is not able to
- * provide XA transactions, for example to share transactions with data access.
+ * This local strategy is an alternative to executing cache operations within
+ * JTA transactions. Its advantage is that is able to work in any environment,
+ * for example a stand-alone application or a test suite. It is not able
+ * to provide XA transactions, for example to share transactions with data
+ * access.
*
*
- * To prevent dirty reads, by default, the cache is configured to return copies rather then direct references for
- * get operations. As a workaround, one could use explicitly deep copy objects before making changes
+ * To prevent dirty reads, by default, the cache is configured to return copies
+ * rather then direct references for get operations. As a
+ * workaround, one could use explicitly deep copy objects before making changes
* to them to avoid unnecessary copying on every fetch.
- *
+ *
* @see com.gemstone.gemfire.cache.CacheTransactionManager
* @see com.gemstone.gemfire.cache.Cache#setCopyOnRead(boolean)
* @see com.gemstone.gemfire.cache.Region#get(Object)
@@ -58,11 +62,13 @@ import com.gemstone.gemfire.cache.Region;
*
* @author Costin Leau
*/
-// TODO add lenient behavior if a transaction is already started on the current thread (what should happen then)
+// TODO add lenient behavior if a transaction is already started on the current
+// thread (what should happen then)
public class GemfireTransactionManager extends AbstractPlatformTransactionManager implements InitializingBean,
ResourceTransactionManager {
private Cache cache;
+
private boolean copyOnRead = true;
/**
@@ -81,6 +87,7 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
afterPropertiesSet();
}
+ @Override
public void afterPropertiesSet() {
Assert.notNull(cache, "Cache property is required");
cache.setCopyOnRead(copyOnRead);
@@ -94,6 +101,7 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
return txObject;
}
+ @Override
protected boolean isExistingTransaction(Object transaction) throws TransactionException {
CacheTransactionObject txObject = (CacheTransactionObject) transaction;
// Consider a pre-bound cache as transaction.
@@ -126,29 +134,34 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
@Override
protected void doCommit(DefaultTransactionStatus status) throws TransactionException {
- //CacheTransactionObject txObject = (CacheTransactionObject) status.getTransaction();
+ // CacheTransactionObject txObject = (CacheTransactionObject)
+ // status.getTransaction();
if (status.isDebug()) {
logger.debug("Committing Gemfire local transaction on Cache [" + cache + "]");
}
try {
cache.getCacheTransactionManager().commit();
- } catch (IllegalStateException ex) {
+ }
+ catch (IllegalStateException ex) {
throw new NoTransactionException(
"No transaction associated with the current thread; are there multiple transaction managers ?", ex);
- } catch (TransactionException ex) {
+ }
+ catch (TransactionException ex) {
throw new GemfireTransactionCommitException("Unexpected failure on commit of Cache local transaction", ex);
}
}
@Override
protected void doRollback(DefaultTransactionStatus status) throws TransactionException {
- //CacheTransactionObject txObject = (CacheTransactionObject) status.getTransaction();
+ // CacheTransactionObject txObject = (CacheTransactionObject)
+ // status.getTransaction();
if (status.isDebug()) {
logger.debug("Rolling back Cache local transaction for [" + cache + "]");
}
try {
cache.getCacheTransactionManager().rollback();
- } catch (IllegalStateException ex) {
+ }
+ catch (IllegalStateException ex) {
throw new NoTransactionException(
"No transaction associated with the current thread; are there multiple transaction managers ?", ex);
}
@@ -163,6 +176,7 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
txObject.getHolder().setRollbackOnly();
}
+ @Override
protected void doCleanupAfterCompletion(Object transaction) {
// Remove the cache holder from the thread.
TransactionSynchronizationManager.unbindResource(cache);
@@ -183,7 +197,7 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
}
/**
- * Sets the Cache that this instance manages local transactions for.
+ * Sets the Cache that this instance manages local transactions for.
*
* @param cache Gemfire cache
*/
@@ -191,12 +205,14 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
this.cache = cache;
}
+ @Override
public Object getResourceFactory() {
return getCache();
}
/**
- * Sets the Gemfire {@link Region} (as an alternative in setting in the cache directly).
+ * Sets the Gemfire {@link Region} (as an alternative in setting in the
+ * cache directly).
*
* @param region Gemfire region
*/
@@ -206,22 +222,24 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
}
/**
- * Indicates whether the cache returns direct references or copies of the objects (default) it manages.
- * While copies imply additional work for every fetch operation, direct references can cause dirty reads
- * across concurrent threads in the same VM, whether or not transactions are used.
- *
- * One could explicitly deep copy objects before making changes (for example by using {@link com.gemstone.gemfire.CopyHelper#copy(Object)}
- * in which case this setting can be set to false. However, unless there is a measurable
- * performance penalty, the recommendation is to keep this setting to true
- *
- * @param copyOnRead whether copies (default) rather then direct references will be returned on
- * fetch operations
+ * Indicates whether the cache returns direct references or copies of the
+ * objects (default) it manages. While copies imply additional work for
+ * every fetch operation, direct references can cause dirty reads across
+ * concurrent threads in the same VM, whether or not transactions are used.
+ *
+ * One could explicitly deep copy objects before making changes (for example
+ * by using {@link com.gemstone.gemfire.CopyHelper#copy(Object)} in which
+ * case this setting can be set to false. However, unless there
+ * is a measurable performance penalty, the recommendation is to keep this
+ * setting to true
+ *
+ * @param copyOnRead whether copies (default) rather then direct references
+ * will be returned on fetch operations
*/
public void setCopyOnRead(boolean copyOnRead) {
this.copyOnRead = copyOnRead;
}
-
/**
* Indicates whether copy on read is set or not on the transaction manager.
*
@@ -232,7 +250,6 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
return copyOnRead;
}
-
/**
* GemfireTM local transaction object.
*
@@ -254,7 +271,6 @@ public class GemfireTransactionManager extends AbstractPlatformTransactionManage
private boolean rollbackOnly = false;
-
public boolean isRollbackOnly() {
return rollbackOnly;
}
diff --git a/src/main/java/org/springframework/data/gemfire/IndexFactoryBean.java b/src/main/java/org/springframework/data/gemfire/IndexFactoryBean.java
index fb66051b..4b804a68 100644
--- a/src/main/java/org/springframework/data/gemfire/IndexFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/IndexFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/LocalRegionFactoryBean.java b/src/main/java/org/springframework/data/gemfire/LocalRegionFactoryBean.java
new file mode 100644
index 00000000..e5db8f69
--- /dev/null
+++ b/src/main/java/org/springframework/data/gemfire/LocalRegionFactoryBean.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2010-2012 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.gemfire;
+
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.RegionFactory;
+
+/**
+ * @author David Turanski
+ *
+ */
+public class LocalRegionFactoryBean extends RegionFactoryBean {
+
+ @Override
+ protected void resolveDataPolicy(RegionFactory regionFactory, boolean persistent, String dataPolicyName) {
+ if (dataPolicyName != null) {
+ if ("NORMAL".equals(dataPolicyName) || dataPolicyName == null) {
+ regionFactory.setDataPolicy(DataPolicy.NORMAL);
+ }
+ else if ("PRELOADED".equals(dataPolicyName)) {
+ regionFactory.setDataPolicy(DataPolicy.PRELOADED);
+ }
+ else if ("EMPTY".equals(dataPolicyName)) {
+ regionFactory.setDataPolicy(DataPolicy.EMPTY);
+ }
+ else {
+ throw new IllegalArgumentException("Data policy '" + dataPolicyName
+ + "' is unsupported or invalid for local regions.");
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/org/springframework/data/gemfire/PartitionAttributesFactoryBean.java b/src/main/java/org/springframework/data/gemfire/PartitionAttributesFactoryBean.java
index f2826ea7..d294e47a 100644
--- a/src/main/java/org/springframework/data/gemfire/PartitionAttributesFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/PartitionAttributesFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/PartitionedRegionFactoryBean.java b/src/main/java/org/springframework/data/gemfire/PartitionedRegionFactoryBean.java
new file mode 100644
index 00000000..00764171
--- /dev/null
+++ b/src/main/java/org/springframework/data/gemfire/PartitionedRegionFactoryBean.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2010-2012 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.gemfire;
+
+import java.util.concurrent.ConcurrentMap;
+
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionFactory;
+
+/**
+ * @author David Turanski
+ *
+ */
+public class PartitionedRegionFactoryBean extends RegionFactoryBean {
+
+ @Override
+ protected void resolveDataPolicy(RegionFactory regionFactory, boolean persistent, String dataPolicyName) {
+ if (persistent) {
+ // check first for GemFire 6.5
+ if (ConcurrentMap.class.isAssignableFrom(Region.class)) {
+ regionFactory.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
+ }
+ else {
+ throw new IllegalArgumentException(
+ "Can define persistent partitions only from GemFire 6.5 onwards - current version is ["
+ + CacheFactory.getVersion() + "]");
+ }
+ }
+ else {
+ regionFactory.setDataPolicy(DataPolicy.PARTITION);
+ }
+ }
+
+}
diff --git a/src/main/java/org/springframework/data/gemfire/RegionAttributesFactoryBean.java b/src/main/java/org/springframework/data/gemfire/RegionAttributesFactoryBean.java
index 23febbc9..cae9685a 100644
--- a/src/main/java/org/springframework/data/gemfire/RegionAttributesFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/RegionAttributesFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
@@ -16,67 +16,40 @@
package org.springframework.data.gemfire;
-import java.io.File;
-
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
-import org.springframework.util.ObjectUtils;
import com.gemstone.gemfire.cache.AttributesFactory;
import com.gemstone.gemfire.cache.RegionAttributes;
/**
- * Spring-friendly bean for creating {@link RegionAttributes}. Eliminates the need of using
- * a XML 'factory-method' tag.
+ * Spring-friendly bean for creating {@link RegionAttributes}. Eliminates the
+ * need of using a XML 'factory-method' tag.
*
* @author Costin Leau
*/
public class RegionAttributesFactoryBean extends AttributesFactory implements FactoryBean,
InitializingBean {
- private int[] diskSizes;
- private File[] diskDirs;
-
private RegionAttributes attributes;
+ @Override
public void afterPropertiesSet() throws Exception {
- if (diskSizes!= null){
- super.setDiskDirsAndSizes(diskDirs, diskSizes);
- }
- else{
- if (!ObjectUtils.isEmpty(diskDirs)) {
- super.setDiskDirs(diskDirs);
- }
- }
-
attributes = super.create();
}
+ @Override
public RegionAttributes getObject() throws Exception {
return attributes;
}
+ @Override
public Class> getObjectType() {
return (attributes != null ? attributes.getClass() : RegionAttributes.class);
}
+ @Override
public boolean isSingleton() {
return true;
}
-
-
- @Override
- public void setDiskDirs(File[] diskDirs) {
- this.diskDirs = diskDirs;
- }
-
- /**
- * Sets the sizes (in megabytes) for each disk directory.
- * Used only disk directories are specified.
- *
- * @param sizes
- */
- public void setDiskSizes(int[] sizes) {
- this.diskSizes = sizes;
- }
}
\ No newline at end of file
diff --git a/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java b/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java
index 7a7ea4eb..bafab68a 100644
--- a/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/RegionFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
@@ -17,6 +17,7 @@
package org.springframework.data.gemfire;
import java.lang.reflect.Field;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -33,7 +34,6 @@ import com.gemstone.gemfire.cache.CacheClosedException;
import com.gemstone.gemfire.cache.CacheListener;
import com.gemstone.gemfire.cache.CacheLoader;
import com.gemstone.gemfire.cache.CacheWriter;
-import com.gemstone.gemfire.cache.DataPolicy;
import com.gemstone.gemfire.cache.GemFireCache;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.RegionAttributes;
@@ -41,30 +41,47 @@ import com.gemstone.gemfire.cache.RegionFactory;
import com.gemstone.gemfire.cache.Scope;
/**
- * FactoryBean for creating generic GemFire {@link Region}s. Will try to first locate the region (by name)
- * and, in case none if found, proceed to creating one using the given settings.
+ * FactoryBean for creating generic GemFire {@link Region}s. Will try to first
+ * locate the region (by name) and, in case none if found, proceed to creating
+ * one using the given settings.
*
- * Note that this factory bean allows for very flexible creation of GemFire {@link Region}. For "client" regions
- * however, see {@link ClientRegionFactoryBean} which offers easier configuration and defaults.
+ * Note that this factory bean allows for very flexible creation of GemFire
+ * {@link Region}. For "client" regions however, see
+ * {@link ClientRegionFactoryBean} which offers easier configuration and
+ * defaults.
*
* @author Costin Leau
+ * @author David Turanski
*/
-public class RegionFactoryBean extends RegionLookupFactoryBean implements DisposableBean {
+public abstract class RegionFactoryBean extends RegionLookupFactoryBean implements DisposableBean {
protected final Log log = LogFactory.getLog(getClass());
private boolean destroy = false;
+
private boolean close = true;
+
private Resource snapshot;
private CacheListener cacheListeners[];
+
private CacheLoader cacheLoader;
+
private CacheWriter cacheWriter;
+
private RegionAttributes attributes;
+
private Scope scope;
- private DataPolicy dataPolicy;
+
+ private boolean persistent;
+
+ private String diskStoreName;
+
+ private String dataPolicyName;
+
private Region region;
+ private List> subRegions;
@Override
public void afterPropertiesSet() throws Exception {
@@ -73,7 +90,6 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
postProcess(region);
}
-
@Override
protected Region lookupFallback(GemFireCache cache, String regionName) throws Exception {
Assert.isTrue(cache instanceof Cache, "Unable to create regions from " + cache);
@@ -83,8 +99,8 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
if (attributes != null)
AttributesFactory.validateAttributes(attributes);
- final RegionFactory regionFactory = (attributes != null ? c.createRegionFactory(attributes)
- : c. createRegionFactory());
+ final RegionFactory regionFactory = (attributes != null ? c.createRegionFactory(attributes) : c
+ . createRegionFactory());
if (!ObjectUtils.isEmpty(cacheListeners)) {
for (CacheListener listener : cacheListeners) {
@@ -100,14 +116,20 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
regionFactory.setCacheWriter(cacheWriter);
}
- if (dataPolicy != null) {
- regionFactory.setDataPolicy(dataPolicy);
- }
+ resolveDataPolicy(regionFactory, persistent, dataPolicyName);
if (scope != null) {
regionFactory.setScope(scope);
}
+ if (diskStoreName != null) {
+ regionFactory.setDiskStoreName(diskStoreName);
+ }
+
+ if (attributes != null) {
+ Assert.state(!attributes.isLockGrantor() || scope.isGlobal(),
+ "Lock grantor only applies to a global scoped region");
+ }
// get underlying AttributesFactory
postProcess(findAttrFactory(regionFactory));
@@ -117,9 +139,16 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
reg.loadSnapshot(snapshot.getInputStream());
}
+ if (attributes != null && attributes.isLockGrantor()) {
+ reg.becomeLockGrantor();
+ }
+
return reg;
}
+ protected abstract void resolveDataPolicy(RegionFactory regionFactory, boolean persistent,
+ String dataPolicyName);
+
@SuppressWarnings("unchecked")
private AttributesFactory findAttrFactory(RegionFactory regionFactory) {
Field attrField = ReflectionUtils.findField(RegionFactory.class, "attrsFactory", AttributesFactory.class);
@@ -127,24 +156,24 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
return (AttributesFactory) ReflectionUtils.getField(attrField, regionFactory);
}
-
/**
- * Post-process the attribute factory object used for configuring the region of this factory bean during the initialization process.
- * The object is already initialized and configured by the factory bean before this method
+ * Post-process the attribute factory object used for configuring the region
+ * of this factory bean during the initialization process. The object is
+ * already initialized and configured by the factory bean before this method
* is invoked.
*
* @param attrFactory attribute factory
- * @deprecated as of GemFire 6.5, the use of {@link AttributesFactory} has been deprecated
+ * @deprecated as of GemFire 6.5, the use of {@link AttributesFactory} has
+ * been deprecated
*/
@Deprecated
protected void postProcess(AttributesFactory attrFactory) {
}
-
/**
- * Post-process the region object for this factory bean during the initialization process.
- * The object is already initialized and configured by the factory bean before this method
- * is invoked.
+ * Post-process the region object for this factory bean during the
+ * initialization process. The object is already initialized and configured
+ * by the factory bean before this method is invoked.
*
* @param region
*/
@@ -152,13 +181,15 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
// do nothing
}
+ @Override
public void destroy() throws Exception {
if (region != null) {
if (close) {
if (!region.getCache().isClosed()) {
try {
region.close();
- } catch (CacheClosedException cce) {
+ }
+ catch (CacheClosedException cce) {
// nothing to see folks, move on.
}
}
@@ -171,9 +202,9 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
}
/**
- * Indicates whether the region referred by this factory bean,
- * will be destroyed on shutdown (default false).
- * Note: destroy and close are mutually exclusive. Enabling one will automatically disable the other.
+ * Indicates whether the region referred by this factory bean, will be
+ * destroyed on shutdown (default false). Note: destroy and close are
+ * mutually exclusive. Enabling one will automatically disable the other.
*
* @param destroy whether or not to destroy the region
*
@@ -188,9 +219,9 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
}
/**
- * Indicates whether the region referred by this factory bean,
- * will be closed on shutdown (default true).
- * Note: destroy and close are mutually exclusive. Enabling one will automatically disable the other.
+ * Indicates whether the region referred by this factory bean, will be
+ * closed on shutdown (default true). Note: destroy and close are mutually
+ * exclusive. Enabling one will automatically disable the other.
*
* @param close whether to close or not the region
* @see #setDestroy(boolean)
@@ -203,9 +234,9 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
}
/**
- * Sets the snapshots used for loading a newly created region.
- * That is, the snapshot will be used only when a new region is created - if the region
- * already exists, no loading will be performed.
+ * Sets the snapshots used for loading a newly created region. That
+ * is, the snapshot will be used only when a new region is created -
+ * if the region already exists, no loading will be performed.
*
* @see #setName(String)
* @param snapshot the snapshot to set
@@ -215,9 +246,9 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
}
/**
- * Sets the cache listeners used for the region used by this factory.
- * Used only when a new region is created.Overrides the settings
- * specified through {@link #setAttributes(RegionAttributes)}.
+ * Sets the cache listeners used for the region used by this factory. Used
+ * only when a new region is created.Overrides the settings specified
+ * through {@link #setAttributes(RegionAttributes)}.
*
* @param cacheListeners the cacheListeners to set on a newly created region
*/
@@ -225,10 +256,15 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
this.cacheListeners = cacheListeners;
}
+ public void setSubRegions(List> subRegions) {
+ log.info("setting subRegions");
+ this.subRegions = subRegions;
+ }
+
/**
- * Sets the cache loader used for the region used by this factory.
- * Used only when a new region is created.Overrides the settings
- * specified through {@link #setAttributes(RegionAttributes)}.
+ * Sets the cache loader used for the region used by this factory. Used only
+ * when a new region is created.Overrides the settings specified through
+ * {@link #setAttributes(RegionAttributes)}.
*
* @param cacheLoader the cacheLoader to set on a newly created region
*/
@@ -237,9 +273,9 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
}
/**
- * Sets the cache writer used for the region used by this factory.
- * Used only when a new region is created. Overrides the settings
- * specified through {@link #setAttributes(RegionAttributes)}.
+ * Sets the cache writer used for the region used by this factory. Used only
+ * when a new region is created. Overrides the settings specified through
+ * {@link #setAttributes(RegionAttributes)}.
*
* @param cacheWriter the cacheWriter to set on a newly created region
*/
@@ -248,18 +284,8 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
}
/**
- * Sets the data policy. Used only when a new region is created.
- * Overrides the settings specified through {@link #setAttributes(RegionAttributes)}.
- *
- * @param dataPolicy the region data policy
- */
- public void setDataPolicy(DataPolicy dataPolicy) {
- this.dataPolicy = dataPolicy;
- }
-
- /**
- * Sets the region scope. Used only when a new region is created.
- * Overrides the settings specified through {@link #setAttributes(RegionAttributes)}.
+ * Sets the region scope. Used only when a new region is created. Overrides
+ * the settings specified through {@link #setAttributes(RegionAttributes)}.
*
* @see Scope
* @param scope the region scope
@@ -268,10 +294,31 @@ public class RegionFactoryBean extends RegionLookupFactoryBean imple
this.scope = scope;
}
+ public void setPersistent(boolean persistent) {
+ this.persistent = persistent;
+ }
+
+ /**
+ * Sets the dataPolicy as a String. Required to support property
+ * placeholders
+ * @param dataPolicyName the dataPolicy name (NORMAL, PRELOADED, etc)
+ */
+ public void setDataPolicyName(String dataPolicyName) {
+ this.dataPolicyName = dataPolicyName;
+ }
+
+ /**
+ * Sets the name of disk store to use for overflow and persistence
+ * @param diskStoreName
+ */
+ public void setDiskStoreName(String diskStoreName) {
+ this.diskStoreName = diskStoreName;
+ }
+
/**
* Sets the region attributes used for the region used by this factory.
- * Allows maximum control in specifying the region settings.
- * Used only when a new region is created.
+ * Allows maximum control in specifying the region settings. Used only when
+ * a new region is created.
*
* @param attributes the attributes to set on a newly created region
*/
diff --git a/src/main/java/org/springframework/data/gemfire/RegionLookupFactoryBean.java b/src/main/java/org/springframework/data/gemfire/RegionLookupFactoryBean.java
index 3333203c..86d0dc04 100644
--- a/src/main/java/org/springframework/data/gemfire/RegionLookupFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/RegionLookupFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/ReplicatedRegionFactoryBean.java b/src/main/java/org/springframework/data/gemfire/ReplicatedRegionFactoryBean.java
new file mode 100644
index 00000000..5d50c439
--- /dev/null
+++ b/src/main/java/org/springframework/data/gemfire/ReplicatedRegionFactoryBean.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2010-2012 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.gemfire;
+
+import org.springframework.util.Assert;
+
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.RegionFactory;
+
+/**
+ * @author David Turanski
+ *
+ */
+public class ReplicatedRegionFactoryBean extends RegionFactoryBean {
+ @Override
+ protected void resolveDataPolicy(RegionFactory regionFactory, boolean persistent, String dataPolicyName) {
+
+ DataPolicy dataPolicy = null;
+ if (dataPolicyName != null) {
+ if ("EMPTY".equals(dataPolicyName)) {
+ Assert.isTrue(!persistent, "Cannot have persistence on an empty region");
+ dataPolicy = DataPolicy.EMPTY;
+ }
+ else {
+ throw new IllegalArgumentException("Data policy '" + dataPolicyName
+ + "' is unsupported or invalid for replicated regions.");
+ }
+ }
+ else {
+ dataPolicy = persistent ? DataPolicy.PERSISTENT_REPLICATE : DataPolicy.REPLICATE;
+ }
+ regionFactory.setDataPolicy(dataPolicy);
+ }
+}
diff --git a/src/main/java/org/springframework/data/gemfire/SubRegionFactoryBean.java b/src/main/java/org/springframework/data/gemfire/SubRegionFactoryBean.java
new file mode 100644
index 00000000..dd033209
--- /dev/null
+++ b/src/main/java/org/springframework/data/gemfire/SubRegionFactoryBean.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2010-2012 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.gemfire;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.BeanInitializationException;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.Assert;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Region;
+
+@SuppressWarnings("deprecation")
+/**
+ * FactoryBean for creating a Gemfire Region as a subregion
+ * @author David Turanski
+ *
+ * @param - Region Key Type
+ * @param - Region Value Type
+ */
+public class SubRegionFactoryBean extends AttributesFactory implements FactoryBean>,
+ InitializingBean {
+
+ protected final Log log = LogFactory.getLog(getClass());
+
+ @SuppressWarnings("unused")
+ private String name;
+
+ private String regionName;
+
+ private Region subRegion;
+
+ private Region, ?> parent;
+
+ private boolean lookupOnly;
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ Assert.notNull(parent, "parent region must not be null");
+
+ this.subRegion = parent.getSubregion(regionName);
+ if (this.subRegion == null) {
+ if (lookupOnly) {
+ throw new BeanInitializationException("Cannot find region [" + regionName + "] in cache "
+ + parent.getRegionService());
+ }
+ else {
+ log.debug("creating subregion of [" + parent.getFullPath() + "] with name " + regionName);
+ this.subRegion = this.parent.createSubregion(regionName, create());
+ }
+ }
+ }
+
+ @Override
+ public Region getObject() throws Exception {
+ return this.subRegion;
+ }
+
+ @Override
+ public Class> getObjectType() {
+ return Region.class;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+ /**
+ * Set the bean name - the same as the subregion full path
+ * @param name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Set the simple name of the region
+ * @param regionName
+ */
+ public void setRegionName(String regionName) {
+ this.regionName = regionName;
+ }
+
+ /**
+ * Set the parent Region
+ * @param parent
+ */
+ public void setParent(Region, ?> parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * Set to true if the subregion should already exist, e.g., specified by
+ * <lookup-region>
+ * @param lookupOnly
+ */
+ public void setLookupOnly(boolean lookupOnly) {
+ this.lookupOnly = lookupOnly;
+ }
+
+}
diff --git a/src/main/java/org/springframework/data/gemfire/WiringDeclarableSupport.java b/src/main/java/org/springframework/data/gemfire/WiringDeclarableSupport.java
index fe64c4f4..f44233d6 100644
--- a/src/main/java/org/springframework/data/gemfire/WiringDeclarableSupport.java
+++ b/src/main/java/org/springframework/data/gemfire/WiringDeclarableSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java b/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java
index 6b0a180c..e9d5441d 100644
--- a/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2011-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/client/ClientRegionFactoryBean.java b/src/main/java/org/springframework/data/gemfire/client/ClientRegionFactoryBean.java
index 705d7b84..5271cac8 100644
--- a/src/main/java/org/springframework/data/gemfire/client/ClientRegionFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/client/ClientRegionFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
@@ -44,6 +44,7 @@ import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
* Client extension for GemFire regions.
*
* @author Costin Leau
+ * @author David Turanski
*/
public class ClientRegionFactoryBean extends RegionLookupFactoryBean implements BeanFactoryAware,
DisposableBean {
@@ -51,19 +52,28 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
private static final Log log = LogFactory.getLog(ClientRegionFactoryBean.class);
private boolean destroy = false;
+
private boolean close = true;
+
private Resource snapshot;
private CacheListener cacheListeners[];
+
private Interest[] interests;
+
private String poolName;
+
private BeanFactory beanFactory;
+
private ClientRegionShortcut shortcut = null;
+
private DataPolicy dataPolicy;
private RegionAttributes attributes;
+
private Region region;
+ private String diskStoreName;
@Override
public void afterPropertiesSet() throws Exception {
@@ -76,12 +86,11 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
protected Region lookupFallback(GemFireCache cache, String regionName) throws Exception {
Assert.isTrue(cache instanceof ClientCache, "Unable to create regions from " + cache);
ClientCache c = (ClientCache) cache;
-
+
if (cache instanceof GemFireCacheImpl) {
Assert.isTrue(((GemFireCacheImpl) cache).isClient(), "A client-cache instance is required");
}
-
// first look at shortcut
ClientRegionShortcut s = null;
@@ -103,7 +112,8 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
else {
s = ClientRegionShortcut.LOCAL;
}
- } else {
+ }
+ else {
s = shortcut;
}
@@ -154,6 +164,10 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
factory.setPoolName(poolName);
}
+ if (diskStoreName != null) {
+ factory.setDiskStoreName(diskStoreName);
+ }
+
Region reg = factory.create(regionName);
log.info("Created new cache region [" + regionName + "]");
if (snapshot != null) {
@@ -179,6 +193,7 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
}
}
+ @Override
public void destroy() throws Exception {
Region region = getObject();
// unregister interests
@@ -193,8 +208,10 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
}
}
}
- // should not really happen since interests are validated at start/registration
- } catch (UnsupportedOperationException ex) {
+ // should not really happen since interests are validated at
+ // start/registration
+ }
+ catch (UnsupportedOperationException ex) {
log.warn("Cannot unregister cache interests", ex);
}
@@ -203,7 +220,8 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
if (!region.getCache().isClosed()) {
try {
region.close();
- } catch (CacheClosedException cce) {
+ }
+ catch (CacheClosedException cce) {
// nothing to see folks, move on.
}
}
@@ -215,13 +233,14 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
region = null;
}
+ @Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
-
/**
- * Set the interests for this client region. Both key and regex interest are supported.
+ * Set the interests for this client region. Both key and regex interest are
+ * supported.
*
* @param interests the interests to set
*/
@@ -257,9 +276,9 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
}
/**
- * Initializes the client using a GemFire {@link ClientRegionShortcut}.
- * The recommended way for creating clients since it covers all the major scenarios with minimal
- * configuration.
+ * Initializes the client using a GemFire {@link ClientRegionShortcut}. The
+ * recommended way for creating clients since it covers all the major
+ * scenarios with minimal configuration.
*
* @param shortcut
*/
@@ -268,9 +287,9 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
}
/**
- * Indicates whether the region referred by this factory bean,
- * will be destroyed on shutdown (default false).
- * Note: destroy and close are mutually exclusive. Enabling one will automatically disable the other.
+ * Indicates whether the region referred by this factory bean, will be
+ * destroyed on shutdown (default false). Note: destroy and close are
+ * mutually exclusive. Enabling one will automatically disable the other.
*
* @param destroy whether or not to destroy the region
*
@@ -285,9 +304,9 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
}
/**
- * Indicates whether the region referred by this factory bean,
- * will be closed on shutdown (default true).
- * Note: destroy and close are mutually exclusive. Enabling one will automatically disable the other.
+ * Indicates whether the region referred by this factory bean, will be
+ * closed on shutdown (default true). Note: destroy and close are mutually
+ * exclusive. Enabling one will automatically disable the other.
*
* @param close whether to close or not the region
* @see #setDestroy(boolean)
@@ -300,9 +319,9 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
}
/**
- * Sets the snapshots used for loading a newly created region.
- * That is, the snapshot will be used only when a new region is created - if the region
- * already exists, no loading will be performed.
+ * Sets the snapshots used for loading a newly created region. That
+ * is, the snapshot will be used only when a new region is created -
+ * if the region already exists, no loading will be performed.
*
* @see #setName(String)
* @param snapshot the snapshot to set
@@ -312,9 +331,9 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
}
/**
- * Sets the cache listeners used for the region used by this factory.
- * Used only when a new region is created.Overrides the settings
- * specified through {@link #setAttributes(RegionAttributes)}.
+ * Sets the cache listeners used for the region used by this factory. Used
+ * only when a new region is created.Overrides the settings specified
+ * through {@link #setAttributes(RegionAttributes)}.
*
* @param cacheListeners the cacheListeners to set on a newly created region
*/
@@ -331,12 +350,21 @@ public class ClientRegionFactoryBean extends RegionLookupFactoryBean
this.dataPolicy = dataPolicy;
}
+ /**
+ * Sets the name of disk store to use for overflow and persistence
+ * @param diskStoreName
+ */
+ public void setDiskStoreName(String diskStoreName) {
+ this.diskStoreName = diskStoreName;
+ }
+
/**
* Sets the region attributes used for the region used by this factory.
- * Allows maximum control in specifying the region settings.
- * Used only when a new region is created.
- * Note that using this method allows for advanced customization of the region - while it provides a lot of flexibility,
- * note that it's quite easy to create misconfigured regions (especially in a client/server scenario).
+ * Allows maximum control in specifying the region settings. Used only when
+ * a new region is created. Note that using this method allows for advanced
+ * customization of the region - while it provides a lot of flexibility,
+ * note that it's quite easy to create misconfigured regions (especially in
+ * a client/server scenario).
*
* @param attributes the attributes to set on a newly created region
*/
diff --git a/src/main/java/org/springframework/data/gemfire/client/Interest.java b/src/main/java/org/springframework/data/gemfire/client/Interest.java
index 0bce0a0f..1fb1a425 100644
--- a/src/main/java/org/springframework/data/gemfire/client/Interest.java
+++ b/src/main/java/org/springframework/data/gemfire/client/Interest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/client/PoolConnection.java b/src/main/java/org/springframework/data/gemfire/client/PoolConnection.java
index 7a72e0fe..15c6e971 100644
--- a/src/main/java/org/springframework/data/gemfire/client/PoolConnection.java
+++ b/src/main/java/org/springframework/data/gemfire/client/PoolConnection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java b/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java
index 74c95361..4b296192 100644
--- a/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java
+++ b/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/client/RegexInterest.java b/src/main/java/org/springframework/data/gemfire/client/RegexInterest.java
index ea14184f..d80afbc6 100644
--- a/src/main/java/org/springframework/data/gemfire/client/RegexInterest.java
+++ b/src/main/java/org/springframework/data/gemfire/client/RegexInterest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2010-2011 the original author or authors.
+ * Copyright 2010-2012 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.
diff --git a/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java b/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java
new file mode 100644
index 00000000..601465fb
--- /dev/null
+++ b/src/main/java/org/springframework/data/gemfire/config/AbstractRegionParser.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2012 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.gemfire.config;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+/**
+ * Base class for all Region Parsers
+ *
+ * @author David Turanski
+ */
+abstract class AbstractRegionParser extends AliasReplacingBeanDefinitionParser {
+ protected final Log log = LogFactory.getLog(getClass());
+
+ @Override
+ protected void doParseInternal(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+ super.doParse(element, builder);
+ boolean subRegion = isSubRegion(element);
+
+ doParseRegion(element, parserContext, builder, subRegion);
+
+ if (subRegion) {
+ builder.addPropertyValue("parent", parserContext.getContainingBeanDefinition().getAttribute("parent"));
+ builder.addPropertyValue("regionName", element.getAttribute(NAME_ATTRIBUTE));
+ }
+ }
+
+ protected abstract void doParseRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder,
+ boolean subRegion);
+
+ protected void doParseSubRegion(Element element, Element subElement, ParserContext parserContext,
+ BeanDefinitionBuilder builder, boolean subRegion) {
+
+ String regionPath = null;
+ String parentBeanName = null;
+ if (subRegion) {
+ parentBeanName = parserContext.getContainingBeanDefinition().getAttribute("regionPath").toString();
+ }
+ else {
+ parentBeanName = getRegionNameFromElement(element);
+ }
+ regionPath = StringUtils.arrayToDelimitedString(new String[] { parentBeanName,
+ getRegionNameFromElement(subElement) }, "/");
+ if (!regionPath.startsWith("/")) {
+ regionPath = "/" + regionPath;
+ }
+ /*
+ * The Region parser needs some context to handle recursion correctly
+ */
+ builder.getBeanDefinition().setAttribute("parent",
+ new BeanDefinitionHolder(builder.getBeanDefinition(), parentBeanName));
+ builder.getBeanDefinition().setAttribute("regionPath", regionPath);
+
+ // Make recursive call
+ BeanDefinition subRegionDef = this.parseSubRegion(subElement, parserContext, builder);
+ // TODO: Is there a better work-around?
+ /*
+ * This setting prevents the BF from generating a name for this been
+ */
+ subRegionDef.setScope(BeanDefinition.SCOPE_PROTOTYPE);
+
+ if (log.isDebugEnabled()) {
+ log.debug("registering subregion as " + regionPath);
+ }
+ this.registerBeanDefinition(new BeanDefinitionHolder(subRegionDef, regionPath), parserContext.getRegistry());
+ }
+
+ protected void doParseCommonRegionConfiguration(Element element, ParserContext parserContext,
+ BeanDefinitionBuilder builder, BeanDefinitionBuilder attrBuilder, boolean subRegion) {
+
+ if (!subRegion) {
+ String cacheRef = element.getAttribute("cache-ref");
+ // add cache reference (fallback to default if nothing is specified)
+ builder.addPropertyReference("cache", (StringUtils.hasText(cacheRef) ? cacheRef : "gemfire-cache"));
+ }
+ // add attributes
+ ParsingUtils.setPropertyValue(element, builder, "name");
+ ParsingUtils.parseOptionalRegionAttributes(parserContext, element, attrBuilder);
+ ParsingUtils.parseStatistics(element, attrBuilder);
+ ParsingUtils.setPropertyValue(element, attrBuilder, "publisher");
+ if (!isSubRegion(element)) {
+ ParsingUtils.setPropertyValue(element, builder, "persistent");
+ }
+ // set the data policy
+ ParsingUtils.setPropertyValue(element, builder, "data-policy", "dataPolicyName");
+
+ if (StringUtils.hasText(element.getAttribute("disk-store-ref"))) {
+ ParsingUtils.setPropertyValue(element, builder, "disk-store-ref", "diskStoreName");
+ builder.addDependsOn(element.getAttribute("disk-store-ref"));
+ }
+
+ ParsingUtils.parseExpiration(parserContext, element, attrBuilder);
+ ParsingUtils.parseEviction(parserContext, element, attrBuilder);
+ ParsingUtils.parseMembershipAttributes(parserContext, element, attrBuilder);
+
+ List subElements = DomUtils.getChildElements(element);
+
+ // parse nested elements
+ for (Element subElement : subElements) {
+ String name = subElement.getLocalName();
+
+ if ("cache-listener".equals(name)) {
+ builder.addPropertyValue("cacheListeners", parseCacheListener(parserContext, subElement, builder));
+ }
+
+ else if ("cache-loader".equals(name)) {
+ builder.addPropertyValue("cacheLoader", parseCacheLoader(parserContext, subElement, builder));
+ }
+
+ else if ("cache-writer".equals(name)) {
+ builder.addPropertyValue("cacheWriter", parseCacheWriter(parserContext, subElement, builder));
+ }
+ // subregion
+ else if (name.endsWith("region")) {
+ doParseSubRegion(element, subElement, parserContext, builder, subRegion);
+ }
+ }
+ }
+
+ private BeanDefinition parseSubRegion(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+ BeanDefinition beanDefinition = parserContext.getDelegate().parseCustomElement(element,
+ builder.getBeanDefinition());
+ return beanDefinition;
+ }
+
+ private String getRegionNameFromElement(Element element) {
+ String name = element.getAttribute(NAME_ATTRIBUTE);
+ return StringUtils.hasText(name) ? name : element.getAttribute(ID_ATTRIBUTE);
+ }
+
+ private Object parseCacheListener(ParserContext parserContext, Element subElement, BeanDefinitionBuilder builder) {
+ return ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder);
+ }
+
+ private Object parseCacheLoader(ParserContext parserContext, Element subElement, BeanDefinitionBuilder builder) {
+ return ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder);
+ }
+
+ private Object parseCacheWriter(ParserContext parserContext, Element subElement, BeanDefinitionBuilder builder) {
+ return ParsingUtils.parseRefOrNestedBeanDeclaration(parserContext, subElement, builder);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/springframework/data/gemfire/config/AliasReplacingBeanDefinitionParser.java b/src/main/java/org/springframework/data/gemfire/config/AliasReplacingBeanDefinitionParser.java
index 1184a87c..c06b9f19 100644
--- a/src/main/java/org/springframework/data/gemfire/config/AliasReplacingBeanDefinitionParser.java
+++ b/src/main/java/org/springframework/data/gemfire/config/AliasReplacingBeanDefinitionParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 the original author or authors.
+ * Copyright 2012 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.
@@ -21,19 +21,36 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.data.gemfire.SubRegionFactoryBean;
import org.w3c.dom.Element;
/**
- * Extension class dealing with the attribute clash (name) that triggers the region name to
- * be considered a bean alias. Overrides the automatic alias detection and replaces it with its own
- * using meta attributes (since the parsing method is final).
+ * Extension class dealing with the attribute clash (name) that triggers the
+ * region name to be considered a bean alias. Overrides the automatic alias
+ * detection and replaces it with its own using meta attributes (since the
+ * parsing method is final).
*
* @author Costin Leau
+ * @author David Turanski
*/
abstract class AliasReplacingBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
+ @Override
+ protected Class> getBeanClass(Element element) {
+
+ if (isSubRegion(element)) {
+ return SubRegionFactoryBean.class;
+ }
+ else {
+ return getRegionFactoryClass();
+ }
+ }
+
+ protected abstract Class> getRegionFactoryClass();
+
@Override
protected final void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+
ParsingUtils.addBeanAliasAsMetadata(element, builder);
doParseInternal(element, parserContext, builder);
@@ -41,9 +58,13 @@ abstract class AliasReplacingBeanDefinitionParser extends AbstractSingleBeanDefi
@Override
protected void registerBeanDefinition(BeanDefinitionHolder definition, BeanDefinitionRegistry registry) {
- // add the aliases from the metadata
+ // add the aliases from the metadata
super.registerBeanDefinition(ParsingUtils.replaceBeanAliasAsMetadata(definition), registry);
}
+ protected boolean isSubRegion(Element element) {
+ return element.getParentNode().getLocalName().endsWith("region");
+ }
+
protected abstract void doParseInternal(Element element, ParserContext parserContext, BeanDefinitionBuilder builder);
}
\ No newline at end of file
diff --git a/src/main/java/org/springframework/data/gemfire/config/CacheParser.java b/src/main/java/org/springframework/data/gemfire/config/CacheParser.java
index 357306c7..d8cd9755 100644
--- a/src/main/java/org/springframework/data/gemfire/config/CacheParser.java
+++ b/src/main/java/org/springframework/data/gemfire/config/CacheParser.java
@@ -16,22 +16,33 @@
package org.springframework.data.gemfire.config;
+import java.util.List;
+
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.support.ManagedMap;
+import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.data.gemfire.CacheFactoryBean;
+import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Attr;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+
+import com.gemstone.gemfire.internal.datasource.ConfigProperty;
/**
* Parser for <cache;gt; definitions.
*
* @author Costin Leau
* @author Oliver Gierke
+ * @author David Turanski
*/
-class CacheParser extends AbstractSingleBeanDefinitionParser {
+class CacheParser extends AbstractSimpleBeanDefinitionParser {
@Override
protected Class> getBeanClass(Element element) {
@@ -39,17 +50,115 @@ class CacheParser extends AbstractSingleBeanDefinitionParser {
}
@Override
- protected void doParse(Element element, BeanDefinitionBuilder builder) {
+ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
super.doParse(element, builder);
ParsingUtils.setPropertyValue(element, builder, "cache-xml-location", "cacheXml");
ParsingUtils.setPropertyReference(element, builder, "properties-ref", "properties");
ParsingUtils.setPropertyReference(element, builder, "pdx-serializer", "pdxSerializer");
ParsingUtils.setPropertyValue(element, builder, "pdx-disk-store", "pdxDiskStoreName");
- ParsingUtils.setPropertyValue(element, builder, "pdx-persistent", "pdxPersistent");
- ParsingUtils.setPropertyValue(element, builder, "pdx-read-serialized", "pdxReadSerialized");
- ParsingUtils.setPropertyValue(element, builder, "pdx-ignore-unread-fields", "pdxIgnoreUnreadFields");
- ParsingUtils.setPropertyValue(element, builder, "use-bean-factory-locator", "useBeanFactoryLocator");
+ ParsingUtils.setPropertyValue(element, builder, "pdx-persistent");
+ ParsingUtils.setPropertyValue(element, builder, "pdx-read-serialized");
+ ParsingUtils.setPropertyValue(element, builder, "pdx-ignore-unread-fields");
+ ParsingUtils.setPropertyValue(element, builder, "use-bean-factory-locator");
+ ParsingUtils.setPropertyValue(element, builder, "copy-on-read");
+ ParsingUtils.setPropertyValue(element, builder, "lock-timeout");
+ ParsingUtils.setPropertyValue(element, builder, "lock-lease");
+ ParsingUtils.setPropertyValue(element, builder, "message-sync-interval");
+ ParsingUtils.setPropertyValue(element, builder, "search-timeout");
+ ParsingUtils.setPropertyValue(element, builder, "critical-heap-percentage");
+ ParsingUtils.setPropertyValue(element, builder, "eviction-heap-percentage");
+
+ List txListeners = DomUtils.getChildElementsByTagName(element, "transaction-listener");
+ if (!CollectionUtils.isEmpty(txListeners)) {
+ ManagedList