summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--etc/evergreen.yml154
-rw-r--r--src/mongo/embedded/android/build.gradle27
-rw-r--r--src/mongo/embedded/android/gradle.properties13
-rw-r--r--src/mongo/embedded/android/mongodb-embedded-capi/build.gradle25
-rw-r--r--src/mongo/embedded/android/settings.gradle1
-rw-r--r--src/mongo/embedded/java/aar/AndroidManifest.xml (renamed from src/mongo/embedded/android/mongodb-embedded-capi/src/main/AndroidManifest.xml)0
-rw-r--r--src/mongo/embedded/java/aar/build.gradle101
-rw-r--r--src/mongo/embedded/java/build.gradle84
-rw-r--r--src/mongo/embedded/java/gradle/wrapper/gradle-wrapper.jar (renamed from src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.jar)bin54708 -> 54413 bytes
-rw-r--r--src/mongo/embedded/java/gradle/wrapper/gradle-wrapper.properties (renamed from src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.properties)3
-rw-r--r--src/mongo/embedded/java/gradlew (renamed from src/mongo/embedded/android/gradlew)0
-rw-r--r--src/mongo/embedded/java/gradlew.bat (renamed from src/mongo/embedded/android/gradlew.bat)0
-rw-r--r--src/mongo/embedded/java/jar/build.gradle102
-rw-r--r--src/mongo/embedded/java/settings.gradle30
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java67
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/LogLevel.java55
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java84
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java72
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClient.java38
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClientImpl.java76
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstance.java35
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstanceImpl.java54
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibrary.java36
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibraryImpl.java85
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/CAPI.java154
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/JULLogger.java128
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/Logger.java142
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/Loggers.java49
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/SLF4JLogger.java108
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/package-info.java20
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/package-info.java20
-rw-r--r--src/mongo/embedded/java/src/com/mongodb/embedded/capi/package-info.java24
33 files changed, 1716 insertions, 76 deletions
diff --git a/.gitignore b/.gitignore
index eb9f70011b2..f33874fbbdc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -156,6 +156,9 @@ DriverInclude.wxs
# Gradle
.gradle
-src/mongo/embedded/java/mongodb-embedded-capi/build/
+src/mongo/embedded/java/build/
+src/mongo/embedded/java/aar/build/
+src/mongo/embedded/java/jar/build/
+local.properties
compile_commands.json
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index 31750847564..9b98f1e48f1 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -3607,21 +3607,21 @@ tasks:
if [ "${setup_android_toolchain|}" = "true" ]; then
export ANDROID_HOME=$(pwd)/android_sdk
- cd src/src/mongo/embedded/android
+ cd src/src/mongo/embedded/java
chmod +x gradlew
for arch in arm64-v8a armeabi-v7a x86_64 ; do
tar zxvf ../../../../../embedded-sdk-android-$arch.tgz
- mkdir -p mongodb-embedded-capi/src/main/jniLibs/$arch
- cp ./mongo-embedded-sdk-${version}/lib/*.so mongodb-embedded-capi/src/main/jniLibs/$arch
+ mkdir -p jniLibs/$arch
+ cp ./mongo-embedded-sdk-${version}/lib/*.so jniLibs/$arch
rm -rf ./mongo-embedded-sdk-${version}
done
- ./gradlew build
+ ./gradlew clean :aar:build :aar:publishMavenAarPublicationToLocalRepository
- mkdir -p ../../../../build/mongo-embedded-sdk-${version}/aar
- cp mongodb-embedded-capi/build/outputs/aar/*.aar ../../../../build/mongo-embedded-sdk-${version}/aar
+ mkdir -p ../../../../build/mongo-embedded-sdk-${version}/android
+ cp -r aar/build/repo/* ../../../../build/mongo-embedded-sdk-${version}/android
fi
- command: shell.exec
params:
@@ -3635,7 +3635,6 @@ tasks:
fi
- command: s3.put
params:
- #optional: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: "src/build/mongo-embedded-sdk-${version}.tgz"
@@ -3645,6 +3644,132 @@ tasks:
content_type: application/tar
display_name: "Embedded SDK Tar Archive"
+ # If this is a patch build, blow away the file so our subsequent and optional s3.put
+ # doesn't run. That way, we won't overwrite the latest part in our patches.
+ - command: shell.exec
+ params:
+ script: |
+ set -o errexit
+ set -o verbose
+
+ if [ "${is_patch}" = "true" ]; then
+ rm -f src/build/mongo-embedded-sdk-${version}.tgz
+ fi
+ # A second put, this time to -latest, to give devs a reasonable
+ # way to get the most recent build.
+ - command: s3.put
+ params:
+ visibility: none
+ optional: true
+ aws_key: ${aws_key}
+ aws_secret: ${aws_secret}
+ local_file: "src/build/mongo-embedded-sdk-${version}.tgz"
+ remote_file: ${project}/embedded-sdk/${build_variant}-latest.tgz
+ bucket: mciuploads
+ permissions: public-read
+ content_type: application/tar
+
+- name: embedded_sdk_multiarch_java_package
+ depends_on:
+ - name: embedded_sdk_s3_put
+ variant: embedded-sdk-ubuntu-1604-x86_64
+ - name: embedded_sdk_s3_put
+ variant: embedded-sdk-macosx-10.10
+ commands:
+ - command: manifest.load
+ - func: "git get project"
+ - func: "get buildnumber"
+ - func: "set up credentials"
+ - func: "setup android toolchain" # noop if ${setup_android_toolchain} is not "true"
+ - func: "generate compile expansions"
+ - func: "apply compile expansions"
+ - command: s3.get
+ params:
+ aws_key: ${aws_key}
+ aws_secret: ${aws_secret}
+ remote_file: ${project}/embedded-sdk/embedded-sdk-ubuntu-1604-x86_64/${revision}/${version}.tgz
+ bucket: mciuploads
+ local_file: "embedded-sdk-java-linux-x86-64.tgz"
+ - command: s3.get
+ params:
+ aws_key: ${aws_key}
+ aws_secret: ${aws_secret}
+ remote_file: ${project}/embedded-sdk/embedded-sdk-macosx-10.10/${revision}/${version}.tgz
+ bucket: mciuploads
+ local_file: "embedded-sdk-java-darwin.tgz"
+ - command: shell.exec
+ params:
+ script: |
+ set -o errexit
+ set -o verbose
+
+ if [ "${setup_android_toolchain|}" = "true" ]; then
+ export ANDROID_HOME=$(pwd)/android_sdk
+
+ cd src/src/mongo/embedded/java
+
+ chmod +x gradlew
+
+ tar zxvf ../../../../../embedded-sdk-java-linux-x86-64.tgz
+ mkdir -p jniLibs/linux-x86-64
+ cp ./mongo-embedded-sdk-${version}/lib/*.so jniLibs/linux-x86-64
+ rm -rf ./mongo-embedded-sdk-${version}
+
+ tar zxvf ../../../../../embedded-sdk-java-darwin.tgz
+ mkdir -p jniLibs/darwin
+ cp ./mongo-embedded-sdk-${version}/lib/*.dylib jniLibs/darwin
+ rm -rf ./mongo-embedded-sdk-${version}
+
+ ./gradlew clean :jar:build :jar:publishMavenPublicationToLocalRepository
+
+ mkdir -p ../../../../build/mongo-embedded-sdk-${version}/java
+ cp -r jar/build/repo/* ../../../../build/mongo-embedded-sdk-${version}/java
+ fi
+ - command: shell.exec
+ params:
+ script: |
+ set -o errexit
+ set -o verbose
+
+ if [ "${setup_android_toolchain|}" = "true" ]; then
+ cd src/build
+ tar zcvf mongo-embedded-sdk-${version}.tgz mongo-embedded-sdk-${version}
+ fi
+ - command: s3.put
+ params:
+ aws_key: ${aws_key}
+ aws_secret: ${aws_secret}
+ local_file: "src/build/mongo-embedded-sdk-${version}.tgz"
+ remote_file: "${project}/embedded-sdk/embedded-sdk-java-multiarch/${revision}/${version}.tgz"
+ bucket: mciuploads
+ permissions: public-read
+ content_type: application/tar
+ display_name: "Embedded SDK Tar Archive"
+ # If this is a patch build, blow away the file so our subsequent and optional s3.put
+ # doesn't run. That way, we won't overwrite the latest part in our patches.
+ - command: shell.exec
+ params:
+ script: |
+ set -o errexit
+ set -o verbose
+
+ if [ "${is_patch}" = "true" ]; then
+ rm -f src/build/mongo-embedded-sdk-${version}.tgz
+ fi
+ # A second put, this time to -latest, to give devs a reasonable
+ # way to get the most recent build.
+ - command: s3.put
+ params:
+ visibility: none
+ optional: true
+ aws_key: ${aws_key}
+ aws_secret: ${aws_secret}
+ local_file: "src/build/mongo-embedded-sdk-${version}.tgz"
+ remote_file: ${project}/embedded-sdk/${build_variant}-latest.tgz
+ bucket: mciuploads
+ permissions: public-read
+ content_type: application/tar
+
- name: compile_benchmarks
depends_on: []
commands:
@@ -9963,6 +10088,21 @@ buildvariants:
tasks:
- name: embedded_sdk_multiarch_android_package
+- name: embedded-sdk-java-multiarch
+ display_name: "Embedded SDK - Java Multiarch Package"
+ run_on:
+ - ubuntu1604-build
+ batchtime: 1440 # 1 day
+ expansions:
+ compile_env: JAVA_HOME=/opt/java/jdk8/
+ setup_android_toolchain: true
+ android_toolchain_system_image_arch: "x86_64"
+ android_system_image_version: 21
+ android_toolchain_target_arch: "x86_64"
+ android_toolchain_api_version: "21"
+ tasks:
+ - name: embedded_sdk_multiarch_java_package
+
###########################################
# Redhat buildvariants #
###########################################
diff --git a/src/mongo/embedded/android/build.gradle b/src/mongo/embedded/android/build.gradle
deleted file mode 100644
index ae504cf74f6..00000000000
--- a/src/mongo/embedded/android/build.gradle
+++ /dev/null
@@ -1,27 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
-
- repositories {
- google()
- jcenter()
-
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:3.1.2'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-allprojects {
- repositories {
- google()
- jcenter()
- }
-}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/src/mongo/embedded/android/gradle.properties b/src/mongo/embedded/android/gradle.properties
deleted file mode 100644
index 1bb109ad42b..00000000000
--- a/src/mongo/embedded/android/gradle.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-# Project-wide Gradle settings.
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx4096m
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
diff --git a/src/mongo/embedded/android/mongodb-embedded-capi/build.gradle b/src/mongo/embedded/android/mongodb-embedded-capi/build.gradle
deleted file mode 100644
index 925a6cb4c73..00000000000
--- a/src/mongo/embedded/android/mongodb-embedded-capi/build.gradle
+++ /dev/null
@@ -1,25 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 28
-
- defaultConfig {
- minSdkVersion 21
- targetSdkVersion 28
- versionCode 1
- versionName "1.0"
- }
-
- buildTypes {
- release {
- minifyEnabled false
- }
- }
-
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
-
- implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
-}
diff --git a/src/mongo/embedded/android/settings.gradle b/src/mongo/embedded/android/settings.gradle
deleted file mode 100644
index a9df6d05560..00000000000
--- a/src/mongo/embedded/android/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':mongodb-embedded-capi'
diff --git a/src/mongo/embedded/android/mongodb-embedded-capi/src/main/AndroidManifest.xml b/src/mongo/embedded/java/aar/AndroidManifest.xml
index 8d3ffd30527..8d3ffd30527 100644
--- a/src/mongo/embedded/android/mongodb-embedded-capi/src/main/AndroidManifest.xml
+++ b/src/mongo/embedded/java/aar/AndroidManifest.xml
diff --git a/src/mongo/embedded/java/aar/build.gradle b/src/mongo/embedded/java/aar/build.gradle
new file mode 100644
index 00000000000..cf070bc7faa
--- /dev/null
+++ b/src/mongo/embedded/java/aar/build.gradle
@@ -0,0 +1,101 @@
+/**
+ * Copyright (C) 2018 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+apply plugin: 'com.android.library'
+apply plugin: 'digital.wup.android-maven-publish'
+apply plugin: 'optional-base'
+
+android {
+ compileSdkVersion 28
+
+ defaultConfig {
+ minSdkVersion 24
+ targetSdkVersion 28
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ }
+ }
+
+ sourceSets {
+ main {
+ manifest.srcFile 'AndroidManifest.xml'
+ java.srcDir '../src'
+ jniLibs.srcDirs '../jniLibs'
+ }
+ }
+}
+
+task sourcesJar(type: Jar) {
+ from android.sourceSets.main.java.srcDirs
+ classifier = 'sources'
+}
+
+dependencies {
+ api "net.java.dev.jna:jna:$jnaVersion@aar"
+ api 'org.slf4j:slf4j-api:1.7.6', optional
+}
+
+publishing {
+ publications {
+ mavenAar(MavenPublication) {
+ artifactId = libraryName + "-android"
+
+ from components.android
+ artifact sourcesJar
+
+ pom {
+ name = pomName
+ description = pomDescription
+ url = pomUrl
+ licenses {
+ license {
+ name = pomLicenseName
+ url = pomLicenseUrl
+ }
+ }
+ scm {
+ connection = pomScmConnection
+ developerConnection = pomScmDevConnection
+ url = pomScmUrl
+ }
+ }
+ }
+ }
+
+ repositories {
+ maven {
+ name = 'local'
+ url = "$buildDir/repo"
+ }
+ }
+}
+
+
diff --git a/src/mongo/embedded/java/build.gradle b/src/mongo/embedded/java/build.gradle
new file mode 100644
index 00000000000..9ece66d51a3
--- /dev/null
+++ b/src/mongo/embedded/java/build.gradle
@@ -0,0 +1,84 @@
+/**
+ * Copyright (C) 2018 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+ext.jnaVersion = '4.5.2'
+ext.libraryName = 'mongodb-embedded-capi'
+ext.pomName = 'MongoDB Embedded Driver C API'
+ext.pomDescription = 'The MongoDB Embedded Driver Native'
+ext.pomUrl = 'http://www.mongodb.org'
+ext.pomLicenseName = 'The Apache License, Version 2.0'
+ext.pomLicenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
+ext.pomScmConnection = 'scm:https://github.com/mongodb/mongo.git'
+ext.pomScmDevConnection = 'scm:git@github.com:mongodb/mongo.git'
+ext.pomScmUrl = 'https://github.com/mongodb/mongo'
+
+buildscript {
+ repositories {
+ jcenter()
+ mavenCentral()
+ google()
+ }
+ dependencies {
+ classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.+'
+ classpath 'com.android.tools.build:gradle:3.1.2'
+ classpath 'digital.wup:android-maven-publish:3.6.2'
+ }
+}
+
+def getGitVersion() {
+ if (project.findProperty("versionOverride")) {
+ return versionOverride
+ } else {
+ def outputAsString
+
+ new ByteArrayOutputStream().withStream { os ->
+ def result = exec {
+ executable 'git'
+ args 'describe', '--tags', '--always', '--dirty'
+ standardOutput = os
+ }
+ outputAsString = os.toString().substring(1).trim()
+ }
+
+ return outputAsString
+ }
+}
+
+allprojects {
+ group = 'com.mongodb'
+ version = getGitVersion()
+
+ repositories {
+ google()
+ jcenter()
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
diff --git a/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.jar b/src/mongo/embedded/java/gradle/wrapper/gradle-wrapper.jar
index 7a3265ee94c..1948b9074f1 100644
--- a/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.jar
+++ b/src/mongo/embedded/java/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.properties b/src/mongo/embedded/java/gradle/wrapper/gradle-wrapper.properties
index 63a52fcd345..d2c45a4b260 100644
--- a/src/mongo/embedded/android/gradle/wrapper/gradle-wrapper.properties
+++ b/src/mongo/embedded/java/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Thu Jun 07 14:12:06 EDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
diff --git a/src/mongo/embedded/android/gradlew b/src/mongo/embedded/java/gradlew
index cccdd3d517f..cccdd3d517f 100644
--- a/src/mongo/embedded/android/gradlew
+++ b/src/mongo/embedded/java/gradlew
diff --git a/src/mongo/embedded/android/gradlew.bat b/src/mongo/embedded/java/gradlew.bat
index f9553162f12..f9553162f12 100644
--- a/src/mongo/embedded/android/gradlew.bat
+++ b/src/mongo/embedded/java/gradlew.bat
diff --git a/src/mongo/embedded/java/jar/build.gradle b/src/mongo/embedded/java/jar/build.gradle
new file mode 100644
index 00000000000..f3d77ff6be6
--- /dev/null
+++ b/src/mongo/embedded/java/jar/build.gradle
@@ -0,0 +1,102 @@
+/**
+ * Copyright (C) 2018 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+apply plugin: 'java-library'
+apply plugin: 'osgi'
+apply plugin: 'maven-publish'
+apply plugin: 'optional-base'
+
+sourceCompatibility = JavaVersion.VERSION_1_7
+targetCompatibility = JavaVersion.VERSION_1_7
+
+jar {
+ sourceSets {
+ main {
+ java.srcDir '../src'
+ resources.srcDirs '../jniLibs'
+ }
+ }
+
+ manifest {
+ instruction 'Automatic-Module-Name', 'org.mongodb.driver.embedded.client.capi'
+ instruction 'Build-Version', getGitVersion()
+ instruction 'Import-Package',
+ 'com.mongodb.*'
+ }
+}
+
+task sourcesJar(type: Jar) {
+ from sourceSets.main.allJava
+ classifier = 'sources'
+}
+
+task javadocJar(type: Jar) {
+ from javadoc
+ classifier = 'javadoc'
+}
+
+dependencies {
+ api "net.java.dev.jna:jna:$jnaVersion"
+ api 'org.slf4j:slf4j-api:1.7.6', optional
+}
+
+publishing {
+ publications {
+ maven(MavenPublication) {
+ artifactId = libraryName
+
+ from components.java
+ artifact sourcesJar
+ artifact javadocJar
+
+ pom {
+ name = pomName
+ description = pomDescription
+ url = pomUrl
+ licenses {
+ license {
+ name = pomLicenseName
+ url = pomLicenseUrl
+ }
+ }
+ scm {
+ connection = pomScmConnection
+ developerConnection = pomScmDevConnection
+ url = pomScmUrl
+ }
+ }
+ }
+ }
+
+ repositories {
+ maven {
+ name = 'local'
+ url = "$buildDir/repo"
+ }
+ }
+}
diff --git a/src/mongo/embedded/java/settings.gradle b/src/mongo/embedded/java/settings.gradle
new file mode 100644
index 00000000000..f5cf2ddef09
--- /dev/null
+++ b/src/mongo/embedded/java/settings.gradle
@@ -0,0 +1,30 @@
+/**
+ * Copyright (C) 2018 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects
+ * for all of the code used other than as permitted herein. If you modify
+ * file(s) with this exception, you may extend this exception to your
+ * version of the file(s), but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version. If you
+ * delete this exception statement from all source files in the program,
+ * then also delete it in the license file.
+ */
+
+include ':aar'
+include ':jar'
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java
new file mode 100644
index 00000000000..ef86cd8ff84
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+import com.mongodb.embedded.capi.internal.CAPI;
+
+import static java.lang.String.format;
+
+final class CAPIHelper {
+
+ static CAPI.mongo_embedded_v1_status createStatusPointer() {
+ try {
+ return CAPI.mongo_embedded_v1_status_create();
+ } catch (Throwable t) {
+ throw createError("status_create", t);
+ }
+ }
+
+ static MongoEmbeddedCAPIException createError(final String methodName, final Throwable t) {
+ if (t instanceof MongoEmbeddedCAPIException) {
+ return (MongoEmbeddedCAPIException) t;
+ }
+ return new MongoEmbeddedCAPIException(format("Error from embedded server when calling '%s': %s", methodName, t.getMessage()), t);
+ }
+
+ static void createErrorFromStatus(final CAPI.mongo_embedded_v1_status statusPointer) {
+ createErrorFromStatus(statusPointer, CAPI.mongo_embedded_v1_status_get_error(statusPointer));
+ }
+
+ static void createErrorFromStatus(final CAPI.mongo_embedded_v1_status statusPointer,
+ final int errorCode) {
+ throw new MongoEmbeddedCAPIException(errorCode,
+ CAPI.mongo_embedded_v1_status_get_code(statusPointer),
+ CAPI.mongo_embedded_v1_status_get_explanation(statusPointer).toString());
+ }
+
+ static void destroyStatusPointer(final CAPI.mongo_embedded_v1_status statusPointer) {
+ try {
+ CAPI.mongo_embedded_v1_status_destroy(statusPointer);
+ } catch (Throwable t) {
+ throw createError("status_destroy", t);
+ }
+ }
+
+ static void validateErrorCode(final CAPI.mongo_embedded_v1_status statusPointer, final int errorCode) {
+ if (errorCode != 0) {
+ createErrorFromStatus(statusPointer, errorCode);
+ }
+ }
+
+ private CAPIHelper() {
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/LogLevel.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/LogLevel.java
new file mode 100644
index 00000000000..e6d64573db0
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/LogLevel.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+/**
+ * LogLevel represents the supported logging levels for the embedded mongod
+ */
+public enum LogLevel {
+ /**
+ * Turn off logging
+ */
+ NONE(0),
+
+ /**
+ * Log to stdout
+ */
+ STDOUT(1),
+
+ /**
+ * Log to stderr
+ */
+ STDERR(2),
+
+ /**
+ * Log via the {@code org.mongodb.embedded.capi} logger
+ */
+ LOGGER(4);
+
+ private final int level;
+
+ /**
+ * @return the logging level
+ */
+ public int getLevel(){
+ return level;
+ }
+
+ LogLevel(final int level){
+ this.level = level;
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java
new file mode 100644
index 00000000000..7b3d148b8a9
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+import com.mongodb.embedded.capi.internal.CAPI;
+import com.sun.jna.NativeLibrary;
+
+import static java.lang.String.format;
+
+/**
+ * The embedded mongodb CAPI.
+ */
+public final class MongoEmbeddedCAPI {
+ private static final String NATIVE_LIBRARY_NAME = "mongo_embedded_capi";
+
+ /**
+ * Initializes the embedded mongodb library, required before any other call.
+ *
+ * <p>Cannot be called multiple times without first calling {@link MongoEmbeddedLibrary#close()}.</p>
+ *
+ * @param yamlConfig the yaml configuration for the embedded mongodb capi library
+ * @return the initialized MongoEmbedded.
+ */
+ public static MongoEmbeddedLibrary create(final String yamlConfig) {
+ return create(yamlConfig, LogLevel.LOGGER);
+ }
+
+ /**
+ * Initializes the embedded mongodb library, required before any other call.
+ *
+ * <p>Cannot be called multiple times without first calling {@link MongoEmbeddedLibrary#close()}.</p>
+ *
+ * @param yamlConfig the yaml configuration for the embedded mongodb capi library
+ * @param logLevel the logging level
+ * @return the initialized MongoEmbedded.
+ */
+ public static MongoEmbeddedLibrary create(final String yamlConfig, final LogLevel logLevel) {
+ return create(yamlConfig, logLevel, null);
+ }
+
+ /**
+ * Initializes the embedded mongodb library, required before any other call.
+ *
+ * <p>Cannot be called multiple times without first calling {@link MongoEmbeddedLibrary#close()}.</p>
+ *
+ * @param yamlConfig the yaml configuration for the embedded mongodb capi library
+ * @param libraryPath the path to the embedded mongodb capi library.
+ * @param logLevel the logging level
+ * @return the initialized MongoEmbedded.
+ */
+ public static MongoEmbeddedLibrary create(final String yamlConfig, final LogLevel logLevel, final String libraryPath) {
+ if (libraryPath != null) {
+ NativeLibrary.addSearchPath(NATIVE_LIBRARY_NAME, libraryPath);
+ }
+ try {
+ new CAPI();
+ } catch (Throwable t) {
+ throw new MongoEmbeddedCAPIException(
+ format("Unable to load the Mongo Embedded Library.%n"
+ + "Please either: Set the libraryPath when calling MongoEmbeddedCAPI.create or %n"
+ + "Ensure the library is set on the jna.library.path or the java.library.path system property."
+ )
+ );
+ }
+ return new MongoEmbeddedLibraryImpl(yamlConfig != null ? yamlConfig : "", logLevel != null ? logLevel : LogLevel.LOGGER);
+ }
+
+ private MongoEmbeddedCAPI() {
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java
new file mode 100644
index 00000000000..ea856e22f94
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+
+import static java.lang.String.format;
+
+/**
+ * Top level Exception for all Mongo Embedded CAPI exceptions
+ */
+public class MongoEmbeddedCAPIException extends RuntimeException {
+ private static final long serialVersionUID = -5524416583514807953L;
+ private final int code;
+
+ /**
+ * @param msg the message
+ */
+ public MongoEmbeddedCAPIException(final String msg) {
+ super(msg);
+ this.code = -1;
+ }
+
+ /**
+ * @param msg the message
+ * @param cause the cause
+ */
+ public MongoEmbeddedCAPIException(final String msg, final Throwable cause) {
+ super(msg, cause);
+ this.code = -1;
+ }
+
+ /**
+ * @param code the error code
+ * @param msg the message
+ */
+ public MongoEmbeddedCAPIException(final int code, final String msg) {
+ super(msg);
+ this.code = code;
+ }
+
+ /**
+ * Constructs a new instance
+ *
+ * @param errorCode the error code
+ * @param subErrorCode the sub category error code
+ * @param reason the reason for the exception
+ */
+ public MongoEmbeddedCAPIException(final int errorCode, final int subErrorCode, final String reason) {
+ this(errorCode, format("%s (%s:%s)", reason, errorCode, subErrorCode));
+ }
+
+ /**
+ * @return the error code for the exception.
+ */
+ public int getCode() {
+ return code;
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClient.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClient.java
new file mode 100644
index 00000000000..cc9db8b42c8
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClient.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+import java.nio.ByteBuffer;
+
+/**
+ * The embedded client
+ */
+public interface MongoEmbeddedClient {
+
+ /**
+ * Writes the input to the embedded mongodb client
+ *
+ * @param input the input to write to the client
+ * @return the response from the embedded mongodb
+ */
+ ByteBuffer write(ByteBuffer input);
+
+ /**
+ * Shutsdown the client
+ */
+ void close();
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClientImpl.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClientImpl.java
new file mode 100644
index 00000000000..59ac167502d
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClientImpl.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+import com.mongodb.embedded.capi.internal.CAPI;
+import com.sun.jna.Memory;
+import com.sun.jna.NativeLong;
+import com.sun.jna.Pointer;
+import com.sun.jna.ptr.NativeLongByReference;
+import com.sun.jna.ptr.PointerByReference;
+
+import java.nio.ByteBuffer;
+
+class MongoEmbeddedClientImpl implements MongoEmbeddedClient {
+ private final CAPI.mongo_embedded_v1_status status;
+ private final CAPI.mongo_embedded_v1_client client;
+
+ MongoEmbeddedClientImpl(final CAPI.mongo_embedded_v1_instance instance) {
+ status = CAPIHelper.createStatusPointer();
+
+ try {
+ client = CAPI.mongo_embedded_v1_client_create(instance, status);
+ } catch (Throwable t) {
+ throw CAPIHelper.createError("instance_create", t);
+ }
+
+ if (client == null) {
+ CAPIHelper.createErrorFromStatus(status);
+ }
+ }
+
+
+ @Override
+ public void close() {
+ try {
+ CAPIHelper.validateErrorCode(status,
+ CAPI.mongo_embedded_v1_client_destroy(client, status));
+ } catch (Throwable t) {
+ throw CAPIHelper.createError("instance_destroy", t);
+ }
+ }
+
+ @Override
+ public ByteBuffer write(final ByteBuffer buffer) {
+ PointerByReference outputBufferReference = new PointerByReference();
+ NativeLongByReference outputSize = new NativeLongByReference();
+
+ byte[] message = new byte[buffer.remaining()];
+ buffer.get(message, 0, buffer.remaining());
+ Pointer messagePointer = new Memory(message.length);
+ messagePointer.write(0, message, 0, message.length);
+
+ try {
+ CAPIHelper.validateErrorCode(status,
+ CAPI.mongo_embedded_v1_client_invoke(client, messagePointer, new NativeLong(message.length), outputBufferReference,
+ outputSize, status));
+ } catch (Throwable t) {
+ throw CAPIHelper.createError("client_invoke", t);
+ }
+ return outputBufferReference.getValue().getByteBuffer(0, outputSize.getValue().longValue());
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstance.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstance.java
new file mode 100644
index 00000000000..6d5b963e89a
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstance.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+/**
+ * A Mongo Embedded Instance
+ */
+public interface MongoEmbeddedInstance {
+
+ /**
+ * Creates a client
+ *
+ * @return the client
+ */
+ MongoEmbeddedClient createClient();
+
+ /**
+ * Shuts down an embedded mongodb instance, all clients must be closed before calling this.
+ */
+ void close();
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstanceImpl.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstanceImpl.java
new file mode 100644
index 00000000000..159d0308054
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstanceImpl.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+import com.mongodb.embedded.capi.internal.CAPI;
+
+class MongoEmbeddedInstanceImpl implements MongoEmbeddedInstance {
+ private final CAPI.mongo_embedded_v1_status status;
+ private final CAPI.mongo_embedded_v1_instance instance;
+
+ MongoEmbeddedInstanceImpl(final CAPI.mongo_embedded_v1_lib libraryPointer, final String yamlConfig) {
+ status = CAPIHelper.createStatusPointer();
+
+ try {
+ instance = CAPI.mongo_embedded_v1_instance_create(libraryPointer,
+ new CAPI.cstring(yamlConfig != null ? yamlConfig : ""), status);
+ } catch (Throwable t) {
+ throw CAPIHelper.createError("instance_create", t);
+ }
+
+ if (instance == null) {
+ CAPIHelper.createErrorFromStatus(status);
+ }
+ }
+
+ @Override
+ public MongoEmbeddedClient createClient() {
+ return new MongoEmbeddedClientImpl(instance);
+ }
+
+ @Override
+ public void close() {
+ try {
+ CAPIHelper.validateErrorCode(status,
+ CAPI.mongo_embedded_v1_instance_destroy(instance, status));
+ } catch (Throwable t) {
+ throw CAPIHelper.createError("instance_destroy", t);
+ }
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibrary.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibrary.java
new file mode 100644
index 00000000000..262e67b072c
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibrary.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+/**
+ * The embedded Mongo library
+ */
+public interface MongoEmbeddedLibrary {
+
+ /**
+ * Create a new instance
+ *
+ * @param yamlConfig the yaml configuration for the instance
+ * @return the mongo embedded instance
+ */
+ MongoEmbeddedInstance createInstance(String yamlConfig);
+
+ /**
+ * Closes the embedded mongodb, all databases must be closed before calling this.
+ */
+ void close();
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibraryImpl.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibraryImpl.java
new file mode 100644
index 00000000000..7dff3b99af5
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibraryImpl.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi;
+
+import com.mongodb.embedded.capi.internal.CAPI;
+import com.mongodb.embedded.capi.internal.logging.Logger;
+import com.mongodb.embedded.capi.internal.logging.Loggers;
+import com.sun.jna.Pointer;
+
+import static java.lang.String.format;
+
+import java.util.Locale;
+
+class MongoEmbeddedLibraryImpl implements MongoEmbeddedLibrary {
+ private static final Logger LOGGER = Loggers.getLogger();
+ private static final LogCallback LOG_CALLBACK = new LogCallback();
+
+ private final CAPI.mongo_embedded_v1_status status;
+ private final CAPI.mongo_embedded_v1_lib lib;
+
+ MongoEmbeddedLibraryImpl(final String yamlConfig, final LogLevel logLevel) {
+ status = CAPIHelper.createStatusPointer();
+ CAPI.mongo_embedded_v1_init_params.ByReference initParams = new CAPI.mongo_embedded_v1_init_params.ByReference();
+ initParams.yaml_config = new CAPI.cstring(yamlConfig != null ? yamlConfig : "");
+ initParams.log_flags = logLevel != null ? logLevel.getLevel() : LogLevel.LOGGER.getLevel();
+ if (logLevel == LogLevel.LOGGER) {
+ initParams.log_callback = LOG_CALLBACK;
+ }
+
+ lib = CAPI.mongo_embedded_v1_lib_init(initParams, status);
+ if (lib == null) {
+ CAPIHelper.createErrorFromStatus(status);
+ }
+ }
+
+ @Override
+ public MongoEmbeddedInstance createInstance(final String yamlConfig) {
+ return new MongoEmbeddedInstanceImpl(lib, yamlConfig);
+ }
+
+ @Override
+ public void close() {
+ try {
+ CAPIHelper.validateErrorCode(status, CAPI.mongo_embedded_v1_lib_fini(lib, status));
+ } catch (Throwable t) {
+ throw CAPIHelper.createError("fini", t);
+ }
+ CAPIHelper.destroyStatusPointer(status);
+ }
+
+ static class LogCallback implements CAPI.mongo_embedded_v1_log_callback {
+
+ // CHECKSTYLE:OFF
+ @Override
+ public void log(final Pointer user_data, final CAPI.cstring message, final CAPI.cstring component, final CAPI.cstring context,
+ final int severity) {
+ String logMessage = format("%-9s [%s] %s", component.toString().toUpperCase(Locale.US), context, message).trim();
+
+ if (severity < -2) {
+ LOGGER.error(logMessage); // Severe/Fatal & Error messages
+ } else if (severity == -2) {
+ LOGGER.warn(logMessage); // Warning messages
+ } else if (severity < 1) {
+ LOGGER.info(logMessage); // Info / Log messages
+ } else {
+ LOGGER.debug(logMessage); // Debug messages
+ }
+ }
+ // CHECKSTYLE:ON
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/CAPI.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/CAPI.java
new file mode 100644
index 00000000000..99c8d44729a
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/CAPI.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi.internal;
+
+import com.sun.jna.Callback;
+import com.sun.jna.Memory;
+import com.sun.jna.Native;
+import com.sun.jna.NativeLong;
+import com.sun.jna.Pointer;
+import com.sun.jna.PointerType;
+import com.sun.jna.Structure;
+import com.sun.jna.ptr.NativeLongByReference;
+import com.sun.jna.ptr.PointerByReference;
+
+import java.util.Arrays;
+import java.util.List;
+
+//CHECKSTYLE:OFF
+public class CAPI {
+
+ public static class cstring extends PointerType {
+ public cstring() {
+ super();
+ }
+
+ public cstring(Pointer address) {
+ super(address);
+ }
+
+ public cstring(String string) {
+ Pointer m = new Memory(string.length() + 1);
+ m.setString(0, string);
+ setPointer(m);
+ }
+
+ public String toString() {
+ return getPointer().getString(0);
+ }
+ }
+
+ public static class mongo_embedded_v1_status extends PointerType {
+
+ public mongo_embedded_v1_status() {
+ super();
+ }
+
+ public mongo_embedded_v1_status(Pointer address) {
+ super(address);
+ }
+ }
+
+ public static class mongo_embedded_v1_lib extends PointerType {
+ public mongo_embedded_v1_lib() {
+ super();
+ }
+
+ public mongo_embedded_v1_lib(Pointer address) {
+ super(address);
+ }
+ }
+
+ public static class mongo_embedded_v1_instance extends PointerType {
+ public mongo_embedded_v1_instance() {
+ super();
+ }
+
+ public mongo_embedded_v1_instance(Pointer address) {
+ super(address);
+ }
+ }
+
+ public static class mongo_embedded_v1_client extends PointerType {
+ public mongo_embedded_v1_client() {
+ super();
+ }
+
+ public mongo_embedded_v1_client(Pointer address) {
+ super(address);
+ }
+ }
+
+ public static class mongo_embedded_v1_init_params extends Structure {
+ public cstring yaml_config;
+ public long log_flags;
+ public mongo_embedded_v1_log_callback log_callback;
+ public Pointer log_user_data;
+
+ public mongo_embedded_v1_init_params() {
+ super();
+ }
+
+ protected List<String> getFieldOrder() {
+ return Arrays.asList("yaml_config", "log_flags", "log_callback",
+ "log_user_data");
+ }
+
+ public static class ByReference extends mongo_embedded_v1_init_params
+ implements Structure.ByReference {
+ }
+ }
+
+ public interface mongo_embedded_v1_log_callback extends Callback {
+ void log(Pointer user_data, cstring message, cstring component, cstring context, int severity);
+ }
+
+ public static native mongo_embedded_v1_status mongo_embedded_v1_status_create();
+
+ public static native void mongo_embedded_v1_status_destroy(mongo_embedded_v1_status status);
+
+ public static native int mongo_embedded_v1_status_get_error(mongo_embedded_v1_status status);
+
+ public static native cstring mongo_embedded_v1_status_get_explanation(mongo_embedded_v1_status status);
+
+ public static native int mongo_embedded_v1_status_get_code(mongo_embedded_v1_status status);
+
+ public static native mongo_embedded_v1_lib mongo_embedded_v1_lib_init(mongo_embedded_v1_init_params.ByReference init_params,
+ mongo_embedded_v1_status status);
+
+ public static native int mongo_embedded_v1_lib_fini(mongo_embedded_v1_lib lib, mongo_embedded_v1_status status);
+
+ public static native mongo_embedded_v1_instance mongo_embedded_v1_instance_create(mongo_embedded_v1_lib lib, cstring yaml_config,
+ mongo_embedded_v1_status status);
+
+ public static native int mongo_embedded_v1_instance_destroy(mongo_embedded_v1_instance instance, mongo_embedded_v1_status status);
+
+ public static native mongo_embedded_v1_client mongo_embedded_v1_client_create(mongo_embedded_v1_instance instance,
+ mongo_embedded_v1_status status);
+
+ public static native int mongo_embedded_v1_client_destroy(mongo_embedded_v1_client client, mongo_embedded_v1_status status);
+
+ public static native int mongo_embedded_v1_client_invoke(mongo_embedded_v1_client client, Pointer input, NativeLong size,
+ PointerByReference output, NativeLongByReference output_size,
+ mongo_embedded_v1_status status);
+
+ static {
+ Native.register(CAPI.class, "mongo_embedded_capi");
+ }
+
+}
+//CHECKSTYLE:ON
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/JULLogger.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/JULLogger.java
new file mode 100644
index 00000000000..12f68cf043f
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/JULLogger.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi.internal.logging;
+
+import java.util.logging.Level;
+
+import static java.util.logging.Level.FINE;
+import static java.util.logging.Level.FINER;
+import static java.util.logging.Level.INFO;
+import static java.util.logging.Level.SEVERE;
+import static java.util.logging.Level.WARNING;
+
+class JULLogger implements Logger {
+
+ private final java.util.logging.Logger delegate;
+
+ JULLogger(final String name) {
+ this.delegate = java.util.logging.Logger.getLogger(name);
+ }
+
+ @Override
+ public String getName() {
+ return delegate.getName();
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return isEnabled(FINER);
+ }
+
+ @Override
+ public void trace(final String msg) {
+ log(FINER, msg);
+ }
+
+ @Override
+ public void trace(final String msg, final Throwable t) {
+ log(FINER, msg, t);
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return isEnabled(FINE);
+ }
+
+ @Override
+ public void debug(final String msg) {
+ log(FINE, msg);
+ }
+
+ @Override
+ public void debug(final String msg, final Throwable t) {
+ log(FINE, msg, t);
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return delegate.isLoggable(INFO);
+ }
+
+ @Override
+ public void info(final String msg) {
+ log(INFO, msg);
+ }
+
+ @Override
+ public void info(final String msg, final Throwable t) {
+ log(INFO, msg, t);
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return delegate.isLoggable(WARNING);
+ }
+
+ @Override
+ public void warn(final String msg) {
+ log(WARNING, msg);
+ }
+
+ @Override
+ public void warn(final String msg, final Throwable t) {
+ log(WARNING, msg, t);
+ }
+
+
+ @Override
+ public boolean isErrorEnabled() {
+ return delegate.isLoggable(SEVERE);
+ }
+
+ @Override
+ public void error(final String msg) {
+ log(SEVERE, msg);
+ }
+
+ @Override
+ public void error(final String msg, final Throwable t) {
+ log(SEVERE, msg, t);
+ }
+
+
+ private boolean isEnabled(final Level level) {
+ return delegate.isLoggable(level);
+ }
+
+ private void log(final Level level, final String msg) {
+ delegate.log(level, msg);
+ }
+
+ public void log(final Level level, final String msg, final Throwable t) {
+ delegate.log(level, msg, t);
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/Logger.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/Logger.java
new file mode 100644
index 00000000000..5b1b04cf3ae
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/Logger.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi.internal.logging;
+
+/**
+ * Not part of the public API
+ */
+public interface Logger {
+ /**
+ * Return the name of this <code>Logger</code> instance.
+ *
+ * @return name of this logger instance
+ */
+ String getName();
+
+ /**
+ * Is the logger instance enabled for the TRACE level?
+ *
+ * @return True if this Logger is enabled for the TRACE level, false otherwise.
+ */
+ boolean isTraceEnabled();
+
+ /**
+ * Log a message at the TRACE level.
+ *
+ * @param msg the message string to be logged
+ */
+ void trace(String msg);
+
+ /**
+ * Log an exception (throwable) at the TRACE level with an accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void trace(String msg, Throwable t);
+
+ /**
+ * Is the logger instance enabled for the DEBUG level?
+ *
+ * @return True if this Logger is enabled for the DEBUG level, false otherwise.
+ */
+ boolean isDebugEnabled();
+
+
+ /**
+ * Log a message at the DEBUG level.
+ *
+ * @param msg the message string to be logged
+ */
+ void debug(String msg);
+
+
+ /**
+ * Log an exception (throwable) at the DEBUG level with an accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void debug(String msg, Throwable t);
+
+ /**
+ * Is the logger instance enabled for the INFO level?
+ *
+ * @return True if this Logger is enabled for the INFO level, false otherwise.
+ */
+ boolean isInfoEnabled();
+
+
+ /**
+ * Log a message at the INFO level.
+ *
+ * @param msg the message string to be logged
+ */
+ void info(String msg);
+
+ /**
+ * Log an exception (throwable) at the INFO level with an accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void info(String msg, Throwable t);
+
+ /**
+ * Is the logger instance enabled for the WARN level?
+ *
+ * @return True if this Logger is enabled for the WARN level, false otherwise.
+ */
+ boolean isWarnEnabled();
+
+ /**
+ * Log a message at the WARN level.
+ *
+ * @param msg the message string to be logged
+ */
+ void warn(String msg);
+
+ /**
+ * Log an exception (throwable) at the WARN level with an accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void warn(String msg, Throwable t);
+
+ /**
+ * Is the logger instance enabled for the ERROR level?
+ *
+ * @return True if this Logger is enabled for the ERROR level, false otherwise.
+ */
+ boolean isErrorEnabled();
+
+ /**
+ * Log a message at the ERROR level.
+ *
+ * @param msg the message string to be logged
+ */
+ void error(String msg);
+
+ /**
+ * Log an exception (throwable) at the ERROR level with an accompanying message.
+ *
+ * @param msg the message accompanying the exception
+ * @param t the exception (throwable) to log
+ */
+ void error(String msg, Throwable t);
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/Loggers.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/Loggers.java
new file mode 100644
index 00000000000..a9ce93fa88e
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/Loggers.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi.internal.logging;
+
+/**
+ * This class is not part of the public API.
+ */
+public final class Loggers {
+ private static final String NAME = "org.mongodb.driver.embedded.capi";
+
+ private static final boolean USE_SLF4J = shouldUseSLF4J();
+
+ /**
+ * @return the logger
+ */
+ public static Logger getLogger() {
+ if (USE_SLF4J) {
+ return new SLF4JLogger(NAME);
+ } else {
+ return new JULLogger(NAME);
+ }
+ }
+
+ private Loggers() {
+ }
+
+ private static boolean shouldUseSLF4J() {
+ try {
+ Class.forName("org.slf4j.Logger");
+ return true;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/SLF4JLogger.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/SLF4JLogger.java
new file mode 100644
index 00000000000..79d510e984b
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/SLF4JLogger.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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 com.mongodb.embedded.capi.internal.logging;
+
+import org.slf4j.LoggerFactory;
+
+class SLF4JLogger implements Logger {
+
+ private final org.slf4j.Logger delegate;
+
+ SLF4JLogger(final String name) {
+ this.delegate = LoggerFactory.getLogger(name);
+ }
+
+ @Override
+ public String getName() {
+ return delegate.getName();
+ }
+
+ @Override
+ public boolean isTraceEnabled() {
+ return delegate.isTraceEnabled();
+ }
+
+ @Override
+ public void trace(final String msg) {
+ delegate.trace(msg);
+ }
+
+ @Override
+ public void trace(final String msg, final Throwable t) {
+ delegate.trace(msg, t);
+ }
+
+ @Override
+ public boolean isDebugEnabled() {
+ return delegate.isDebugEnabled();
+ }
+
+ @Override
+ public void debug(final String msg) {
+ delegate.debug(msg);
+ }
+
+ @Override
+ public void debug(final String msg, final Throwable t) {
+ delegate.debug(msg, t);
+ }
+
+ @Override
+ public boolean isInfoEnabled() {
+ return delegate.isInfoEnabled();
+ }
+
+ @Override
+ public void info(final String msg) {
+ delegate.info(msg);
+ }
+
+ @Override
+ public void info(final String msg, final Throwable t) {
+ delegate.info(msg, t);
+ }
+
+ @Override
+ public boolean isWarnEnabled() {
+ return delegate.isWarnEnabled();
+ }
+
+ @Override
+ public void warn(final String msg) {
+ delegate.warn(msg);
+ }
+
+ @Override
+ public void warn(final String msg, final Throwable t) {
+ delegate.warn(msg, t);
+ }
+
+ @Override
+ public boolean isErrorEnabled() {
+ return delegate.isErrorEnabled();
+ }
+
+ @Override
+ public void error(final String msg) {
+ delegate.error(msg);
+ }
+
+ @Override
+ public void error(final String msg, final Throwable t) {
+ delegate.error(msg, t);
+ }
+}
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/package-info.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/package-info.java
new file mode 100644
index 00000000000..2849661baa9
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/logging/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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.
+ */
+
+/**
+ * This package contains logging classes
+ */
+package com.mongodb.embedded.capi.internal.logging;
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/package-info.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/package-info.java
new file mode 100644
index 00000000000..90923757217
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/internal/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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.
+ */
+
+/**
+ * Internal packages that are not part of the public api
+ */
+package com.mongodb.embedded.capi.internal;
diff --git a/src/mongo/embedded/java/src/com/mongodb/embedded/capi/package-info.java b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/package-info.java
new file mode 100644
index 00000000000..d1a44d80aa1
--- /dev/null
+++ b/src/mongo/embedded/java/src/com/mongodb/embedded/capi/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2008-present MongoDB, Inc.
+ *
+ * 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.
+ */
+
+/**
+ * This packages contains classes for the embedded client
+ */
+
+/**
+ * This packages contains classes for the embedded c-api version 1
+ */
+package com.mongodb.embedded.capi;