Bug 494157 Adds recipe "Accessing Data with MongoDB"
diff --git a/recipe-accessing-data-mongodb/.gitignore b/recipe-accessing-data-mongodb/.gitignore
new file mode 100644
index 0000000..5fb40ad
--- /dev/null
+++ b/recipe-accessing-data-mongodb/.gitignore
@@ -0,0 +1 @@
+**/META-INF/MANIFEST.MF
diff --git a/recipe-accessing-data-mongodb/build-slides.gradle b/recipe-accessing-data-mongodb/build-slides.gradle
new file mode 100644
index 0000000..0a2db84
--- /dev/null
+++ b/recipe-accessing-data-mongodb/build-slides.gradle
@@ -0,0 +1,106 @@
+buildscript {
+ dependencies {
+ classpath 'org.ysb33r.gradle:vfs-gradle-plugin:1.0-beta8'
+ classpath 'commons-httpclient:commons-httpclient:3.1'
+ }
+}
+
+plugins {
+ id 'org.asciidoctor.convert' version '1.5.3'
+ id 'com.github.jruby-gradle.base' version '1.2.1'
+}
+
+apply plugin: 'com.github.jruby-gradle.base'
+apply plugin: 'org.ysb33r.vfs'
+apply plugin: 'java'
+apply plugin: 'org.asciidoctor.convert'
+
+version = '1.0.0-SNAPSHOT'
+
+ext {
+ revealjsVersion = '3.2.0'
+ asciidoctorBackendVersion = 'master'
+ downloadDir = new File(buildDir,'download')
+ templateDir = new File(downloadDir,'templates')
+ revealjsDir = new File(downloadDir,'reveal.js')
+}
+
+repositories {
+ jcenter()
+}
+
+dependencies {
+ gems 'rubygems:slim:3.0.6'
+ gems 'rubygems:thread_safe:0.3.5'
+}
+
+task download << {
+ mkdir downloadDir
+ vfs {
+ cp "zip:https://github.com/asciidoctor/asciidoctor-reveal.js/archive/${asciidoctorBackendVersion}.zip!asciidoctor-reveal.js-${asciidoctorBackendVersion}",
+ templateDir, recursive:true, overwrite:true
+ cp "zip:https://github.com/hakimel/reveal.js/archive/${revealjsVersion}.zip!reveal.js-${revealjsVersion}",
+ revealjsDir, recursive:true, overwrite:true
+ }
+}
+
+download {
+ description "Download extra revealjs resources"
+ outputs.dir templateDir
+ outputs.dir revealjsDir
+}
+
+asciidoctorj {
+ version = '1.5.4'
+}
+
+task('mergeClassesAndResources', type: Copy, dependsOn: 'compileJava') {
+ ext.bundlorInputPath = new File(buildDir, 'asciidoc-sourcedir')
+ inputs.file sourceSets.main.output.classesDir
+ inputs.file sourceSets.main.resources
+ outputs.dir ext.bundlorInputPath
+ from sourceSets.main.output.classesDir
+ from sourceSets.main.resources
+ into ext.bundlorInputPath
+}
+
+asciidoctor {
+
+ dependsOn jrubyPrepare
+
+ sources {
+ include 'recipe-accessing-data-mongodb.adoc'
+ }
+
+ resources {
+ from (sourceDir) {
+ include 'images/**'
+ }
+ from (downloadDir) {
+ include 'reveal.js/**'
+ }
+ }
+
+ backends 'revealjs'
+
+ attributes 'build-gradle': file('build-slides.gradle'),
+ 'sourcedir': new File(buildDir, 'asciidoc-sourcedir'),
+ 'endpoint-url': 'http://example.org',
+ 'source-highlighter': 'coderay',
+ 'imagesdir': './images',
+ 'toc': 'left',
+ 'icons': 'font',
+ 'setanchors': '',
+ 'idprefix': '',
+ 'idseparator': '-',
+ 'docinfo1': '',
+ 'revealjs_theme': 'solarized',
+ 'revealjs_transition': 'linear',
+ 'revealjs_history': 'true',
+ 'revealjs_slideNumber': 'true'
+
+ options template_dirs : [new File(templateDir,'templates/slim').absolutePath ]
+
+ dependsOn download
+ dependsOn mergeClassesAndResources
+}
diff --git a/recipe-accessing-data-mongodb/build.gradle b/recipe-accessing-data-mongodb/build.gradle
new file mode 100644
index 0000000..356fd81
--- /dev/null
+++ b/recipe-accessing-data-mongodb/build.gradle
@@ -0,0 +1,172 @@
+buildscript {
+ repositories {
+ mavenCentral()
+ maven {
+ url "https://plugins.gradle.org/m2/"
+ }
+ }
+ dependencies {
+ classpath "gradle.plugin.org.eclipse.virgo.bundlor:bundlor-plugin:0.2"
+ classpath "gradle.plugin.com.eclipsesource.dockerizor:dockerizor:0.6.2"
+ classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
+ }
+}
+
+apply plugin: 'org.asciidoctor.convert'
+
+ext.virgoProjects = [
+ project(':org.eclipse.virgo.samples.recipe.data.mongodb'),
+]
+
+ext.dockerProjects = [
+ project(':recipe-accessing-data-mongodb-runtime'),
+ project(':recipe-accessing-data-mongodb-app'),
+]
+
+configure(virgoProjects + dockerProjects) {
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ ivy {
+ url "http://build.eclipse.org/rt/virgo/ivy/bundles/release/"
+ layout "pattern", { artifact "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" }
+ }
+ }
+}
+
+configure(virgoProjects) {
+ apply plugin: 'java'
+ apply plugin: 'eclipse'
+ apply plugin: 'eclipse-wtp'
+
+ version = '0.1.0.BUILD-SNAPSHOT'
+
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+
+ compileJava {
+ options.encoding = 'utf-8'
+ options.fork = true
+ doFirst {
+ options.forkOptions.with {
+ executable = 'java'
+ jvmArgs = [
+ '-cp',
+ configurations.ecj.asPath,
+ 'org.eclipse.jdt.internal.compiler.batch.Main',
+ '-source',
+ '1.8',
+ '-target',
+ '1.8',
+ '-warn:-unused'
+ ]
+ }
+ }
+ }
+
+ compileTestJava {
+ options.encoding = 'utf-8'
+ options.fork = true
+ doFirst {
+ options.forkOptions.with {
+ executable = 'java'
+ jvmArgs = [
+ '-cp',
+ configurations.ecj.asPath,
+ 'org.eclipse.jdt.internal.compiler.batch.Main',
+ '-source',
+ '1.8',
+ '-target',
+ '1.8',
+ '-warn:-unused'
+ ]
+ }
+ }
+ }
+
+ eclipse {
+ jdt {
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
+ }
+
+ project {
+ natures 'org.eclipse.virgo.ide.facet.core.bundlenature', 'org.eclipse.wst.common.project.facet.core.nature'
+ }
+
+ wtp {
+ facet {
+ facets = []
+ facet name: 'jst.java', version: '1.8'
+ facet name: 'org.eclipse.virgo.server.bundle', version: '1.0'
+ }
+ }
+ }
+
+ configurations { ecj { } }
+}
+
+configure(virgoProjects) {
+ apply plugin: 'org.eclipse.virgo.bundlor'
+
+ task('addProjectVersionToGradlePropertiesTask', type: Copy) {
+ ext.outputDir = new File(buildDir, 'bundlor-properties')
+ inputs.file project.rootProject.file('gradle.properties')
+ outputs.dir ext.outputDir
+ from project.rootProject.file('gradle.properties')
+ into ext.outputDir
+ }
+
+ task('mergeClassesAndResources', type: Copy, dependsOn: 'compileJava') {
+ ext.bundlorInputPath = new File(buildDir, 'bundlor-inputPath')
+ inputs.file sourceSets.main.output.classesDir
+ inputs.file sourceSets.main.resources
+ outputs.dir ext.bundlorInputPath
+ from sourceSets.main.output.classesDir
+ from sourceSets.main.resources
+ into ext.bundlorInputPath
+ }
+
+ project.tasks.'bundlor'.dependsOn('addProjectVersionToGradlePropertiesTask', 'mergeClassesAndResources')
+
+ bundlor {
+ ext.bundlorInputPath = new File(buildDir, 'bundlor-inputPath')
+ project.tasks['bundlor'].inputs.file ext.bundlorInputPath
+ manifestTemplatePath = "template.mf"
+ propertiesPath = new File("${project.buildDir}/bundlor-properties/gradle.properties")
+ inputPath = ext.bundlorInputPath
+ failOnWarnings = false
+ }
+}
+
+configure(dockerProjects) {
+ // add the build task 'clean'
+ apply plugin: 'base'
+
+ // add the build task 'dockerize'
+ apply plugin: 'com.eclipsesource.dockerizor'
+
+ dockerizor {
+ maintainer = 'Florian Waibel <fwaibel@eclipsesource.com>'
+
+ javaImage = 'java:openjdk-8u72-jre'
+
+ virgoVersion = 'latest'
+ hudsonJobName = 'gradle-build'
+
+ createLocalCopy = System.properties['local.build'] == 'true'
+ removeAdminConsole = System.properties['local.build'] != 'true'
+
+ virgoFlavour = 'VTS'
+ virgoVersion = 'latest'
+ }
+
+ dockerize.dependsOn configurations.repositoryExt
+ dockerize.dependsOn configurations.repositoryUsr
+}
+
+task wrapper(type: Wrapper) {
+ gradleVersion = '2.10'
+}
diff --git a/recipe-accessing-data-mongodb/create-slides.sh b/recipe-accessing-data-mongodb/create-slides.sh
new file mode 100755
index 0000000..ea50179
--- /dev/null
+++ b/recipe-accessing-data-mongodb/create-slides.sh
@@ -0,0 +1 @@
+./gradlew -b build-slides.gradle asciidoc && open -a "Google Chrome" build/asciidoc/revealjs/recipe-accessing-data-mongodb.html
diff --git a/recipe-accessing-data-mongodb/gradle.properties b/recipe-accessing-data-mongodb/gradle.properties
new file mode 100644
index 0000000..402a039
--- /dev/null
+++ b/recipe-accessing-data-mongodb/gradle.properties
@@ -0,0 +1,15 @@
+springframeworkVersion = 4.2.1.RELEASE
+
+# Eclipse Mars.1 bundle from Maven Central provided by Tycho
+# org.eclipse.osgi_3.10.101.v20150820-1432.jar
+equinoxVersion = 3.10.101.v20150820-1432
+# Eclipse Mars.1 bundle from Maven Central provided by Birt
+# org.eclipse.osgi.services_3.5.0.v20150519-2006.jar
+osgiServicesVersion = 3.5.0.v20150519-2006
+
+mongoJavaDriverVersion = 2.13.3
+springDataCommonsVersion = 1.11.2.RELEASE
+springDataMongodbVersion = 1.8.2.RELEASE
+
+# test dependencies
+junitVersion = 4.12
diff --git a/recipe-accessing-data-mongodb/gradle/wrapper/gradle-wrapper.jar b/recipe-accessing-data-mongodb/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..2c6137b
--- /dev/null
+++ b/recipe-accessing-data-mongodb/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/recipe-accessing-data-mongodb/gradle/wrapper/gradle-wrapper.properties b/recipe-accessing-data-mongodb/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..6ced50b
--- /dev/null
+++ b/recipe-accessing-data-mongodb/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Thu Apr 14 10:48:19 CEST 2016
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
diff --git a/recipe-accessing-data-mongodb/gradlew b/recipe-accessing-data-mongodb/gradlew
new file mode 100755
index 0000000..9d82f78
--- /dev/null
+++ b/recipe-accessing-data-mongodb/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# 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
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+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
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ 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
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# 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" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/recipe-accessing-data-mongodb/gradlew.bat b/recipe-accessing-data-mongodb/gradlew.bat
new file mode 100644
index 0000000..5f19212
--- /dev/null
+++ b/recipe-accessing-data-mongodb/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/build.gradle b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/build.gradle
new file mode 100644
index 0000000..6b251c0
--- /dev/null
+++ b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/build.gradle
@@ -0,0 +1,5 @@
+dependencies {
+ ecj group: "org.eclipse.jdt.core.compiler", name: "ecj", version: "4.4.2"
+
+ compile "org.springframework.data:spring-data-mongodb:${springDataMongodbVersion}"
+}
diff --git a/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/Application.java b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/Application.java
new file mode 100644
index 0000000..7bf96cc
--- /dev/null
+++ b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/Application.java
@@ -0,0 +1,44 @@
+package org.eclipse.virgo.samples.recipe.data.mongodb;
+
+import javax.annotation.PostConstruct;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class Application {
+
+ @Autowired
+ private CustomerRepository repository;
+
+ @PostConstruct
+ public void init() throws Exception {
+
+ repository.deleteAll();
+
+ // save a couple of customers
+ repository.save(new Customer("Alice", "Smith"));
+ repository.save(new Customer("Bob", "Smith"));
+
+ // fetch all customers
+ System.out.println("Customers found with findAll():");
+ System.out.println("-------------------------------");
+ for (Customer customer : repository.findAll()) {
+ System.out.println(customer);
+ }
+ System.out.println();
+
+ // fetch an individual customer
+ System.out.println("Customer found with findByFirstName('Alice'):");
+ System.out.println("--------------------------------");
+ System.out.println(repository.findByFirstName("Alice"));
+
+ System.out.println("Customers found with findByLastName('Smith'):");
+ System.out.println("--------------------------------");
+ for (Customer customer : repository.findByLastName("Smith")) {
+ System.out.println(customer);
+ }
+
+ }
+
+}
diff --git a/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/Customer.java b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/Customer.java
new file mode 100644
index 0000000..fddbce0
--- /dev/null
+++ b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/Customer.java
@@ -0,0 +1,28 @@
+package org.eclipse.virgo.samples.recipe.data.mongodb;
+
+import org.springframework.data.annotation.Id;
+
+//tag::type[]
+public class Customer {
+
+ @Id
+ private String id;
+
+ private String firstName;
+ private String lastName;
+
+ public Customer() {}
+
+ public Customer(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ @Override
+ public String toString() {
+ return String.format(
+ "Customer[id=%s, firstName='%s', lastName='%s']",
+ id, firstName, lastName);
+ }
+}
+//end::type[]
diff --git a/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/CustomerRepository.java b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/CustomerRepository.java
new file mode 100644
index 0000000..9e0636f
--- /dev/null
+++ b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/CustomerRepository.java
@@ -0,0 +1,13 @@
+package org.eclipse.virgo.samples.recipe.data.mongodb;
+
+import java.util.List;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+//tag::type[]
+public interface CustomerRepository extends MongoRepository<Customer, String> {
+
+ public Customer findByFirstName(String firstName);
+ public List<Customer> findByLastName(String lastName);
+}
+//end::type[]
diff --git a/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/resources/META-INF/spring/applicationContext.xml b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/resources/META-INF/spring/applicationContext.xml
new file mode 100644
index 0000000..3184db3
--- /dev/null
+++ b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/src/main/resources/META-INF/spring/applicationContext.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:mongo="http://www.springframework.org/schema/data/mongo"
+ xmlns="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd" >
+
+<!-- tag::configuration[] -->
+ <mongo:db-factory dbname="recipes" host="localhost:27017" /><!--1-->
+ <mongo:repositories base-package="org.eclipse.virgo.samples.recipe.data.mongodb" /><!--2-->
+
+ <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"><!--3-->
+ <constructor-arg ref="mongoDbFactory" />
+ </bean>
+
+ <context:component-scan base-package="org.eclipse.virgo.samples.recipe.data.mongodb" /><!--4-->
+<!-- end::configuration[] -->
+</beans>
diff --git a/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/template.mf b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/template.mf
new file mode 100644
index 0000000..4ecce3c
--- /dev/null
+++ b/recipe-accessing-data-mongodb/org.eclipse.virgo.samples.recipe.data.mongodb/template.mf
@@ -0,0 +1,10 @@
+Bundle-Version: 0.1
+Bundle-Name: Virgo Recipe MongoDB
+Bundle-SymbolicName: org.eclipse.virgo.samples.recipe.data.mongodb
+Import-Package: com.mongodb,
+ org.springframework.data.domain,
+ org.springframework.data.repository.core.support,
+ org.springframework.data.mongodb.repository.support,
+ org.aopalliance.aop
+Import-Bundle:
+ org.springframework.aop
diff --git a/recipe-accessing-data-mongodb/recipe-accessing-data-mongodb-app/build.gradle b/recipe-accessing-data-mongodb/recipe-accessing-data-mongodb-app/build.gradle
new file mode 100644
index 0000000..7ccb946
--- /dev/null
+++ b/recipe-accessing-data-mongodb/recipe-accessing-data-mongodb-app/build.gradle
@@ -0,0 +1,20 @@
+dockerizor {
+ repository = 'virgo-recipe/recipe-accessing-data-mongodb'
+ description = 'Virgo Recipe MongoDB created with Gradle Plugin: com.eclipsesource.dockerizor'
+
+ pickupFiles = ['recipe-accessing-data-mongodb.plan']
+
+ virgoHome = '/home/virgo/virgo-recipe-accessing-data-mongodb'
+}
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ repositoryUsr group: "org.mongodb", name: "mongo-java-driver", version: mongoJavaDriverVersion
+ repositoryUsr group: "org.springframework.data", name: "spring-data-commons", version: springDataCommonsVersion
+ repositoryUsr group: "org.springframework.data", name: "spring-data-mongodb", version: springDataMongodbVersion
+
+ repositoryUsr project(':org.eclipse.virgo.samples.recipe.data.mongodb')
+}
diff --git a/recipe-accessing-data-mongodb/recipe-accessing-data-mongodb-app/recipe-accessing-data-mongodb.plan b/recipe-accessing-data-mongodb/recipe-accessing-data-mongodb-app/recipe-accessing-data-mongodb.plan
new file mode 100644
index 0000000..bd677fc
--- /dev/null
+++ b/recipe-accessing-data-mongodb/recipe-accessing-data-mongodb-app/recipe-accessing-data-mongodb.plan
@@ -0,0 +1,9 @@
+<plan name="recipe-mongodb" version="0.1" scoped="false" atomic="true"
+ xmlns="http://www.eclipse.org/virgo/schema/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.eclipse.org/virgo/schema/plan
+ http://www.eclipse.org/virgo/schema/plan/eclipse-virgo-plan.xsd">
+
+ <artifact type="bundle" name="org.eclipse.virgo.samples.recipe.data.mongodb" version="[0.1, 1)" />
+</plan>
diff --git a/recipe-accessing-data-mongodb/recipe-accessing-data-mongodb-runtime/build.gradle b/recipe-accessing-data-mongodb/recipe-accessing-data-mongodb-runtime/build.gradle
new file mode 100644
index 0000000..ea81202
--- /dev/null
+++ b/recipe-accessing-data-mongodb/recipe-accessing-data-mongodb-runtime/build.gradle
@@ -0,0 +1,18 @@
+dockerizor {
+ repository = 'virgo-recipe/recipe-accessing-data-mongodb-runtime'
+ description = 'Virgo Recipe MongoDB (runtime-only) created with Gradle Plugin: com.eclipsesource.dockerizor'
+
+ virgoHome = '/home/virgo/virgo-recipe-accessing-data-mongodb-runtime'
+}
+
+repositories {
+ mavenCentral()
+}
+
+//tag::dependencies[]
+dependencies {
+ repositoryUsr("org.mongodb:mongo-java-driver:${mongoJavaDriverVersion}")
+ repositoryUsr group: "org.springframework.data", name: "spring-data-commons", version: springDataCommonsVersion
+ repositoryUsr group: "org.springframework.data", name: "spring-data-mongodb", version: springDataMongodbVersion
+}
+//end::dependencies[]
diff --git a/recipe-accessing-data-mongodb/settings.gradle b/recipe-accessing-data-mongodb/settings.gradle
new file mode 100644
index 0000000..0debf22
--- /dev/null
+++ b/recipe-accessing-data-mongodb/settings.gradle
@@ -0,0 +1 @@
+include 'org.eclipse.virgo.samples.recipe.data.mongodb', 'recipe-accessing-data-mongodb-runtime', 'recipe-accessing-data-mongodb-app'
diff --git a/recipe-accessing-data-mongodb/src/docs/asciidoc/recipe-accessing-data-mongodb.adoc b/recipe-accessing-data-mongodb/src/docs/asciidoc/recipe-accessing-data-mongodb.adoc
new file mode 100644
index 0000000..0059535
--- /dev/null
+++ b/recipe-accessing-data-mongodb/src/docs/asciidoc/recipe-accessing-data-mongodb.adoc
@@ -0,0 +1,172 @@
+:virgo-homepage: https://eclipse.org/virgo
+:guide-short-name: accessing-data-mongodb
+:recipe-name: Accessing Data with MongoDB
+:recipe-short-name: recipe-{guide-short-name}
+:experimental: true
+
+include::../../../../recipe-template/src/docs/asciidoc/00_title.adoc[]
+include::../../../../recipe-template/src/docs/asciidoc/01_acknowledgements.adoc[]
+
+== {recipe-name}
+
+The original guide uses https://projects.spring.io/spring-boot/[Spring Boot] to bootstrap the demo application. This guide shows what needs to be done to run {recipe-name} with Virgo.
+
+include::../../../../recipe-template/src/docs/asciidoc/03_shopping-list.adoc[]
+
+include::../../../../recipe-template/src/docs/asciidoc/04_ingredients.adoc[]
+* OSGi Metadata
+* Spring configuration
+
+== Preparations
+
+include::../../../../recipe-template/src/docs/asciidoc/051_get-the-code.adoc[]
+include::../../../../recipe-template/src/docs/asciidoc/052_create-recipe-runtime.adoc[]
+include::../../../../recipe-template/src/docs/asciidoc/053_create-eclipse-project-metadata.adoc[]
+include::../../../../recipe-template/src/docs/asciidoc/054_prepare-virgo-tooling.adoc[]
+include::../../../../recipe-template/src/docs/asciidoc/055_import-the-code.adoc[]
+include::../../../../recipe-template/src/docs/asciidoc/056_create-new-virgo-server.adoc[]
+
+== Directions
+
+In the original guide the music plays in the run method of the `CommandLineRunner` of the Spring Boot application.
+We are going to transform the `@SpringBootApplication` into a plain `@Component` with an `init`-method.
+
+=== Spring Boot Application
+
+[source,java]
+----
+@SpringBootApplication // <1>
+public class Application implements CommandLineRunner { // <2>
+
+ @Autowired private CustomerRepository repository; // <3>
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+ public void run(String... args) throws Exception { // <4>
+ // repository actions...
+ }
+}
+----
+<1> Will be replaced with a plain `@Component`.
+<2> `CommandLineRunner` will be replaced, too.
+<3> `@Autowired` is the common denominator.
+<4> Will be replaced with a `@PostConstruct` method.
+
+=== Virgoized Application
+
+After the transformation the component looks something like:
+
+[source,java]
+----
+@Component
+public class Application {
+
+ @Autowired private CustomerRepository repository;
+
+ @PostConstruct
+ public void init() throws Exception {
+ // repository actions...
+ }
+}
+----
+
+=== Customer
+
+Both: The `Customer`
+
+[source,java]
+.Customer
+----
+include::../../../org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/Customer.java[tags=type]
+----
+
+=== Customer Repository
+
+and `CustomerRepository` are unchanged:
+
+[source,java]
+.CustomerRepository
+----
+include::../../../org.eclipse.virgo.samples.recipe.data.mongodb/src/main/java/org/eclipse/virgo/samples/recipe/data/mongodb/CustomerRepository.java[tags=type]
+----
+
+=== OSGi Metadata
+
+The OSGi metadata is generated from a template:
+
+[source,java]
+.template.mf
+----
+include::../../../org.eclipse.virgo.samples.recipe.data.mongodb/template.mf[]
+----
+
+=== Dependency management
+
+While the original guide pulls in it's Spring Data dependencies the Spring Boot way:
+
+[source,groovy]
+----
+dependencies {
+ compile("org.springframework.boot:spring-boot-starter-data-mongodb")
+...
+}
+----
+
+we create a custom Virgo runtime and add list the required dependencies more explicit:
+
+[source,groovy]
+----
+include::../../../recipe-accessing-data-mongodb-runtime/build.gradle[tags=dependencies]
+----
+
+=== Spring Boot Demystified
+
+Within the Virgo powered OSGi environment some of the Spring Boot magic becomes visible in `XML`.
+
+
+[source,xml,indent=0]
+----
+include::../../../org.eclipse.virgo.samples.recipe.data.mongodb/src/main/resources/META-INF/spring/applicationContext.xml[tags=configuration]
+----
+<1> Provides a bean `MongoDbFactory`
+<2> Configures and provides a bean `MongoTemplate`
+<3> Scans provide MongoDB backed `MongoRepository`
+<4> Scans the application code for `@Component` s ...
+
+== Let's taste
+
+When the oven is hot - the Virgo Runtime is up and running - you can insert (drag'n'drop) the fresh OSGi bundle.
+
+A quick glimpse into the oven...
+
+[source,sh]
+----
+$ tail -500f ${VIRGO_HOME}/serviceability/logs/log.log
+----
+
+=== the results
+
+Should show the tasty result of our actions:
+
+[source,sh]
+.log.log
+----
+...
+System.out Customers found with findAll():
+System.out -------------------------------
+System.out Customer[id=570fa0b3eec8cfd2c9a99d98, firstName='Alice', lastName='Smith']
+System.out Customer[id=570fa0b3eec8cfd2c9a99d99, firstName='Bob', lastName='Smith']
+System.out
+System.out Customer found with findByFirstName('Alice'):
+System.out --------------------------------
+System.out Customer[id=570fa0b3eec8cfd2c9a99d98, firstName='Alice', lastName='Smith']
+System.out Customers found with findByLastName('Smith'):
+System.out --------------------------------
+System.out Customer[id=570fa0b3eec8cfd2c9a99d98, firstName='Alice', lastName='Smith']
+System.out Customer[id=570fa0b3eec8cfd2c9a99d99, firstName='Bob', lastName='Smith']
+...
+----
+
+include::../../../../recipe-template/src/docs/asciidoc/08_dockerize_recipe.adoc[]
diff --git a/recipe-accessing-data-mongodb/start-live-server.sh b/recipe-accessing-data-mongodb/start-live-server.sh
new file mode 100755
index 0000000..ac02c90
--- /dev/null
+++ b/recipe-accessing-data-mongodb/start-live-server.sh
@@ -0,0 +1,6 @@
+#/bin/bash
+
+# install live-server globally
+# npm install -g live-server
+
+${HOME}/npm-global/lib/node_modules/live-server/live-server.js --port=9000 build/asciidoc/revealjs/