Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
17 changes: 14 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
/dist/
build
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

ids.txt
nbproject/private
build/
dist/
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

34 changes: 34 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>s2s</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1615207284547</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
4 changes: 4 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
2 changes: 2 additions & 0 deletions .settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
9 changes: 9 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
1 change: 1 addition & 0 deletions src/LICENSE → LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,4 @@
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.

23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# brainclouds2s-java
Version 3.11

Java library for brainCloud S2S

Expand All @@ -16,25 +15,27 @@ clone the repo.

```
git clone https://github.com/getbraincloud/brainclouds2s-java.git
cd brainclouds2s-java
git submodule update --init --recursive --remote
./autobuild/build.sh
```
The resulting jar file is in **dist/Brainclouds2s-x.x.jar**

Build using maven
```
mvn package
```
The resulting jar file is in **target/brainclouds2s-x.x.x.jar**

## Sample Usage

### Using included org.json encoding/decoding
``` java
import com.bitheads.braincloud.s2s.Brainclouds2s;
import com.bitheads.brainclouds2s.BrainCloudS2S;
import org.json.JSONArray;
import org.json.JSONObject;

String appId = "<Your app ID>";
String serverName = "<Your Server defined name>";
String serverSecret = "<Your server secret>";

Brainclouds2s instance = new Brainclouds2s();
BrainCloudS2S instance = new BrainCloudS2S();
instance.init(appId, serverName, serverSecret);

JSONObject json = new JSONObject();
Expand All @@ -53,7 +54,7 @@ The resulting jar file is in **dist/Brainclouds2s-x.x.jar**
params.put("maxReturn", 5); // Max 5 entity
json.put("data",params);

instance.request(json, (Brainclouds2s context, JSONObject jsonData) -> {
instance.request(json, (BrainCloudS2S context, JSONObject jsonData) -> {
if (jsonData.getInt("status").isEqual(200)) {
JSONArray list = jsonData.getJSONObject("data").getJSONArray("entityList");
// Now list contains the address entities.
Expand All @@ -62,7 +63,7 @@ The resulting jar file is in **dist/Brainclouds2s-x.x.jar**
});
```

### Using Your own JSON encoding/deocoding
### Using Your own JSON encoding/decoding

``` java
import com.bitheads.braincloud.s2s.Brainclouds2s;
Expand All @@ -73,12 +74,12 @@ The resulting jar file is in **dist/Brainclouds2s-x.x.jar**
String serverName = "<Your Server defined name>";
String serverSecret = "<Your server secret>";

Brainclouds2s instance = new Brainclouds2s();
BrainCloudS2S instance = new BrainCloudS2S();
instance.init(appId, serverName, serverSecret);

String requestString ="{\"service\":\"globalEntity", \"operation\":\"READ__LIST\",\"data\":{\"where\":{\"entityType\":\"address\"},\"orderBy\":{\"data.address\":1},\"maxReturn\":50}";

instance.request(requestString, (Brainclouds2s context, String jsonString) -> {
instance.request(requestString, (BrainCloudS2S context, String jsonString) -> {
// decode and evaluate jsonString
// Your code here.
});
Expand Down
23 changes: 3 additions & 20 deletions autobuild/build.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,8 @@
# Go to project root
cd `dirname $0`/..

if [ ! -f version.txt ]; then
echo "Missing version.txt file, must contain onle line with the current version of the source."
exit 1
fi
# Create jar file
mvn package

VERSION=`cat version.txt`

#Get Version from arguments if present
if [ -n "$1" ]; then
VERSION=$1
fi

echo "Building Brainclouds2s... "
mkdir -p build
javac -d ./build `find ./src -name "*.java"`
cp src/LICENSE build/

echo "Packacking Brainclouds2s-$VERSION.jar..."
mkdir -p dist
cd ./build
jar -cf ../dist/Brainclouds2s-$VERSION.jar `find . -name "*.class"` LICENSE
# Feedback
echo "Done."
20 changes: 2 additions & 18 deletions autobuild/test.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@
# Go to project root
cd `dirname $0`/..

VERSION=`cat version.txt`
# Run Tests
mvn test

# Make sure it is already built
if [ ! -f dist/Brainclouds2s-$VERSION.jar ]; then
autobuild/build.sh
fi

# Set a temporary build folder
mkdir -p testBuild
javac -cp lib/junit-4.12.jar:dist/Brainclouds2s-$VERSION.jar -d ./testBuild `find ./test -name "*.java"`
java -cp lib/junit-4.12.jar:lib/hamcrest-core-1.3.jar:dist/Brainclouds2s-$VERSION.jar:testBuild/ org.junit.runner.JUnitCore com.bitheads.braincloud.s2s.Brainclouds2sSetupTest
# Persist test results
TEST_RESULT=$?

# Cleanup
rm -rf testBuild

# Return test resutls
exit $TEST_RESULT
73 changes: 0 additions & 73 deletions build.xml

This file was deleted.

Binary file removed lib/hamcrest-core-1.3.jar
Binary file not shown.
Binary file removed lib/junit-4.12.jar
Binary file not shown.
Loading