diff options
author | Andrew Morrow <acm@mongodb.com> | 2022-05-02 14:22:13 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-05 22:10:55 +0000 |
commit | f812c3bc873762960f32dbb64de1acb0e0133f01 (patch) | |
tree | 404513cceb5e7373a0a45062f4db1caf5e78821e /src/mongo/embedded | |
parent | 6593f72ace4d44ec2addeff3efe49467e3ffb9a9 (diff) | |
download | mongo-f812c3bc873762960f32dbb64de1acb0e0133f01.tar.gz |
SERVER-65992 Remove outdated java related sources from embedded directory
Diffstat (limited to 'src/mongo/embedded')
25 files changed, 0 insertions, 1937 deletions
diff --git a/src/mongo/embedded/mongo_embedded/java/build.gradle b/src/mongo/embedded/mongo_embedded/java/build.gradle deleted file mode 100644 index f6e5cf8e0f6..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/build.gradle +++ /dev/null @@ -1,81 +0,0 @@ -ext.jnaVersion = '4.5.2' -ext.libraryName = 'embedded-capi' -ext.licenseShort = 'MongoDB Embedded License' -ext.pomName = 'MongoDB Embedded for Java' -ext.pomDescription = 'The MongoDB Embedded SDK for Java' -ext.pomUrl = 'http://www.mongodb.org' -ext.pomLicenseName = 'MongoDB Embedded License' -ext.pomLicenseUrl = 'https://www.mongodb.com/licensing/embedded-license' -ext.pomScmConnection = 'https://github.com/mongodb/mongo.git' -ext.pomScmDevConnection = 'git@github.com:mongodb/mongo.git' -ext.pomScmUrl = 'https://github.com/mongodb/mongo' - -buildscript { - repositories { - google() - jcenter() - mavenCentral() - } - dependencies { - classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.3' - classpath 'com.android.tools.build:gradle:3.1.2' - classpath 'digital.wup:android-maven-publish:3.6.2' - classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.9.0' - classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.12.0" - } -} - -def getGitVersion() { - if (project.findProperty("versionOverride")) { - return versionOverride - } else { - def outputAsString - - new ByteArrayOutputStream().withStream { os -> - def result = exec { - executable 'git' - args 'describe', '--abbrev=7', '--tags', '--always' - standardOutput = os - } - outputAsString = os.toString().substring(1).trim() - } - - def minorVer = outputAsString.tokenize('.')[1].toInteger() - if ((minorVer % 2) != 0) { - return outputAsString + "-SNAPSHOT" - } - - return outputAsString - } -} - -File localPropsFile = file('./local.properties') -if (localPropsFile.exists()) { - Properties p = new Properties() - p.load(new FileInputStream(localPropsFile)) - p.each { name, value -> - ext[name] = value - } -} - -allprojects { - group = 'org.mongodb' - version = getGitVersion() - - repositories { - google() - jcenter() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} - -apply plugin: 'io.codearte.nexus-staging' - -nexusStaging { - packageGroup = "org.mongodb" - username = ossrhUsername - password = ossrhPassword -} diff --git a/src/mongo/embedded/mongo_embedded/java/embedded-jar/build.gradle b/src/mongo/embedded/mongo_embedded/java/embedded-jar/build.gradle deleted file mode 100644 index 566770c793f..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/embedded-jar/build.gradle +++ /dev/null @@ -1,99 +0,0 @@ -apply plugin: 'java-library' -apply plugin: 'osgi' -apply plugin: 'maven-publish' -apply plugin: 'optional-base' -apply plugin: 'com.jfrog.artifactory' - -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 = "scm:" + pomScmConnection - developerConnection = "scm:" + pomScmDevConnection - url = pomScmUrl - } - } - } - } - - repositories { - maven { - name = 'local' - url = "$buildDir/repo" - } - } -} - - -artifactory { - contextUrl = "http://artifactory.corp.mongodb.com/artifactory" - publish { - repository { - repoKey = 'mongodb-mobile-local' - username = System.getenv('artifactory_mobile_user') - password = System.getenv('artifactory_mobile_pass') - maven = true - } - defaults { - publications ('maven') - } - } - resolve { - repository { - repoKey = 'maven' - username = System.getenv('artifactory_mobile_user') - password = System.getenv('artifactory_mobile_pass') - maven = true - } - } -} diff --git a/src/mongo/embedded/mongo_embedded/java/gradle/wrapper/gradle-wrapper.jar b/src/mongo/embedded/mongo_embedded/java/gradle/wrapper/gradle-wrapper.jar Binary files differdeleted file mode 100644 index 1948b9074f1..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/gradle/wrapper/gradle-wrapper.jar +++ /dev/null diff --git a/src/mongo/embedded/mongo_embedded/java/gradle/wrapper/gradle-wrapper.properties b/src/mongo/embedded/mongo_embedded/java/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index d2c45a4b260..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -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 diff --git a/src/mongo/embedded/mongo_embedded/java/gradlew b/src/mongo/embedded/mongo_embedded/java/gradlew deleted file mode 100755 index cccdd3d517f..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# 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 - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# 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 -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -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" -a "$nonstop" = "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 - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/src/mongo/embedded/mongo_embedded/java/gradlew.bat b/src/mongo/embedded/mongo_embedded/java/gradlew.bat deleted file mode 100644 index f9553162f12..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@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 - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@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= - -@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 - -: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=%* - -: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/src/mongo/embedded/mongo_embedded/java/settings.gradle b/src/mongo/embedded/mongo_embedded/java/settings.gradle deleted file mode 100644 index fd39703259d..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -include ':embedded-android' -include ':embedded-jar' diff --git a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java deleted file mode 100644 index 78b5f921aa7..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java +++ /dev/null @@ -1,82 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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(), - null); - } - - 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/mongo_embedded/java/src/com/mongodb/embedded/capi/LogLevel.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/LogLevel.java deleted file mode 100644 index e0564d6b894..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/LogLevel.java +++ /dev/null @@ -1,69 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java deleted file mode 100644 index 44595852ae2..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java +++ /dev/null @@ -1,98 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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"; - - /** - * 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." - ), t - ); - } - return new MongoEmbeddedLibraryImpl(yamlConfig != null ? yamlConfig : "", logLevel != null ? logLevel : LogLevel.LOGGER); - } - - private MongoEmbeddedCAPI() { - } -} diff --git a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java deleted file mode 100644 index 95e8e8fd6a2..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java +++ /dev/null @@ -1,80 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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 - * @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 - * @param cause the cause - */ - public MongoEmbeddedCAPIException(final int code, final String msg, final Throwable cause) { - super(msg, cause); - 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 - * @param cause the cause - */ - public MongoEmbeddedCAPIException(final int errorCode, final int subErrorCode, final String reason, final Throwable cause) { - this(errorCode, format("%s (%s:%s)", reason, errorCode, subErrorCode), cause); - } - - /** - * @return the error code for the exception. - */ - public int getCode() { - return code; - } -} diff --git a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClient.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClient.java deleted file mode 100644 index 68799821970..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClient.java +++ /dev/null @@ -1,52 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClientImpl.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClientImpl.java deleted file mode 100644 index 39a498cb91d..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedClientImpl.java +++ /dev/null @@ -1,90 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstance.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstance.java deleted file mode 100644 index 42a0e4561d1..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstance.java +++ /dev/null @@ -1,49 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstanceImpl.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstanceImpl.java deleted file mode 100644 index 827659aa746..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedInstanceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibrary.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibrary.java deleted file mode 100644 index 0e8f17d58ed..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibrary.java +++ /dev/null @@ -1,50 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibraryImpl.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibraryImpl.java deleted file mode 100644 index 3f2a87c9fa2..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedLibraryImpl.java +++ /dev/null @@ -1,99 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/CAPI.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/CAPI.java deleted file mode 100644 index 6b582db245e..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/CAPI.java +++ /dev/null @@ -1,168 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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"); - } - -} -//CHECKSTYLE:ON diff --git a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/JULLogger.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/JULLogger.java deleted file mode 100644 index ac301ef9652..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/JULLogger.java +++ /dev/null @@ -1,142 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/Logger.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/Logger.java deleted file mode 100644 index c414023aaad..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/Logger.java +++ /dev/null @@ -1,156 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/Loggers.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/Loggers.java deleted file mode 100644 index e391088dd39..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/Loggers.java +++ /dev/null @@ -1,63 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/SLF4JLogger.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/SLF4JLogger.java deleted file mode 100644 index d1f2f7b730f..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/SLF4JLogger.java +++ /dev/null @@ -1,122 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -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/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/package-info.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/package-info.java deleted file mode 100644 index eb66868f25d..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/logging/package-info.java +++ /dev/null @@ -1,34 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -/** - * This package contains logging classes - */ -package com.mongodb.embedded.capi.internal.logging; diff --git a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/package-info.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/package-info.java deleted file mode 100644 index 184ca02e8a4..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/internal/package-info.java +++ /dev/null @@ -1,34 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -/** - * Internal packages that are not part of the public api - */ -package com.mongodb.embedded.capi.internal; diff --git a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/package-info.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/package-info.java deleted file mode 100644 index 6a5b211b198..00000000000 --- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/package-info.java +++ /dev/null @@ -1,38 +0,0 @@ - -/** - * Copyright (C) 2018-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * 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 - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * 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 Server Side 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. - */ - -/** - * This packages contains classes for the embedded client - */ - -/** - * This packages contains classes for the embedded c-api version 1 - */ -package com.mongodb.embedded.capi; |