Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
- Java client library source.
- Client library tutorial examples.
- Client library unit tests.
- Client library, examples, tests build scripts.
  • Loading branch information
david-russell committed Nov 27, 2014
1 parent b842f1c commit 7d1c178
Show file tree
Hide file tree
Showing 267 changed files with 30,311 additions and 3 deletions.
8 changes: 8 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Copyright (C) 2010-2014 by Revolution Analytics Inc.

This program is licensed to you under the terms of Version 2.0 of the
Apache License. This program is distributed WITHOUT
ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0) for more
details.
107 changes: 104 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,105 @@
java-client-library
===================

Java Client Library for DeployR
===============================

The [DeployR API](https://github.com/deployr/server) exposes a wide range of
R analytics services to client application developers. These services are
exposed using standards based JSON/XML and are delivered by the DeployR
server as Web services over HTTP(S).

The DeployR Java client library is provided to simplify the integration of
DeployR services within Java client applications.

Links
-----

* [Download](http://deployr.revolutionanalytics.com/docanddown/#clientlib)
* [Quick Start Tutorial](http://deployr.revolutionanalytics.com/documents/dev/clientlib)
* [Client Library API JavaDoc](http://deployr.revolutionanalytics.com/documents/dev/client-javadoc)
* [DeployR API Reference Guide](http://deployr.revolutionanalytics.com/documents/dev/api-doc/guide)
* [Library Dependencies](#dependencies)
* [Example Code](#examples)
* [License](#license)

Dependencies
============


Declaractive JAR Dependencies: Maven Central Repository Artifacts
-----------------------------------------------------------------

Artifacts for each official release (since 7.3.0) of the DeployR Java client
library are published to the Maven Central repository.

[ArtifactId](http://search.maven.org/#search|ga|1|a%3A%22jDeployR%22): `jDeployR`

Using build frameworks such as Maven and Gradle your Java client
application can simply declare a dependency on the appropriate version
of the `jDeployR` artifact to ensure all required JAR dependencies are resolved
and available at runtime.


Bundled JAR Dependencies
------------------------

If you are not defining your DeployR client library JAR dependencies using
declarative tools then you must ensure the required JAR files are placed
directly on your application CLASSPATH.

Besides the DeployR Java client library JAR itself, `jDeployR-<version>.jar`,
there are a number of 3rd party JAR file dependencies. These additional JAR
file dependencies are provided for your convenience in the `lib` directory
within this repository.


Building the Java Client Library
--------------------------------

A Gradle build script is provided to build the DeployR Java client
library:

```
build.gradle
```

By default, the build will generate a version of the `jDeployR-<version>.jar`
file in the `build/libs` directory.

You do not need to install Gradle before running these commands. To
build the DeployR Java client library a Unix based OS, run the following shell
script:

```
gradlew build
```

To build the DeployR Java client library on a Windows based OS, run the following
batch file:

```
gradlew.bat build
```


Examples
========

The DeployR Java client library ships with a number of sample applications
provided to demonstrate some of the key featues introduced by the
[Quick Start Tutorial](http://deployr.revolutionanalytics.com/documents/dev/clientlib)
for the Java client library. See
[here](examples/tutorial) for details.

The DeployR Java client library also ships with a set of unit tests. See
[here](test) for details.

License
=======

Copyright (C) 2010-2014 by Revolution Analytics Inc.

This program is licensed to you under the terms of Version 2.0 of the
Apache License. This program is distributed WITHOUT
ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0) for more
details.
49 changes: 49 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apply plugin: 'java'

repositories {
mavenCentral()
}

dependencies {
compile "commons-codec:commons-codec:1.9"
compile "commons-lang:commons-lang:2.6"
compile "commons-logging:commons-logging:1.2"
compile "org.apache.httpcomponents:httpcore:4.3.2"
compile "org.apache.httpcomponents:httpmime:4.3.5"
compile "org.apache.httpcomponents:httpclient:4.3.5"
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.3'
compile 'com.fasterxml.jackson.core:jackson-core:2.2.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.3'
compile 'log4j:log4j:1.2.17'
}

jar {
baseName = 'jDeployR'
version = '7.3.0'
}

javadoc {
title = "DeployR 7.3.0 Java Client Library"
options.overview = "src/main/java/overview.html"
exclude "com/revo/deployr/client/core/**/*.java"
exclude "com/revo/deployr/client/call/**/*.java"
exclude "com/revo/deployr/client/data/impl/**/*.java"
exclude "com/revo/deployr/client/managers/impl/**/*.java"
exclude "com/revo/deployr/client/auth/impl/**/*.java"
exclude "com/revo/deployr/client/response/impl/**/*.java"
exclude "com/revo/deployr/client/util/**/*.java"
}

task wrapper(type: Wrapper) {
gradleVersion = '2.0'
}

task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
7 changes: 7 additions & 0 deletions examples/awt/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To run the SimpleConsole example application use:

gradlew run

or

gradlew.bat run
35 changes: 35 additions & 0 deletions examples/awt/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apply plugin: 'java'
apply plugin: 'application'

mainClassName = 'com.revo.deployr.example.SimpleConsole'

applicationDefaultJvmArgs = ["-Dendpoint=http://localhost:7300/deployr",
"-Dusername=testuser",
"-Dpassword=changeme"]

repositories {
mavenCentral()
}

dependencies {
compile fileTree(dir: '../../build/libs', include: ['*.jar'])
compile "commons-codec:commons-codec:1.9"
compile "commons-lang:commons-lang:2.6"
compile "commons-logging:commons-logging:1.2"
compile "org.apache.httpcomponents:httpcore:4.3.2"
compile "org.apache.httpcomponents:httpmime:4.3.5"
compile "org.apache.httpcomponents:httpclient:4.3.5"
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.3'
compile 'com.fasterxml.jackson.core:jackson-core:2.2.3'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.3'
compile 'log4j:log4j:1.2.17'
}

jar {
baseName = 'deployr-example'
version = '7.3.0'
}

task wrapper(type: Wrapper) {
gradleVersion = '2.0'
}
Binary file added examples/awt/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions examples/awt/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Thu Sep 11 21:49:57 ICT 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
164 changes: 164 additions & 0 deletions examples/awt/gradlew
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#!/usr/bin/env bash

##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""

APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
echo "$*"
}

die ( ) {
echo
echo "$*"
echo
exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option

if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
Loading

0 comments on commit 7d1c178

Please sign in to comment.