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
47 changes: 41 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.redislabs/jrejson/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.redislabs/jrejson)
[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause)

# JReJSON

A Java Client Library for [ReJSON](https://github.com/redislabsmodules/rejson)
Expand All @@ -8,13 +11,45 @@ This client provides access to ReJSON's Redis API, and provides back-and-forth s

This project is currently WIP and the interface may change. Also note that only the core ReJSON commands are supported at the moment.

## Installation

1. Install Jedis (once v3 is released this step will be obsolete)
1. Clone it: `git clone --depth 1 git@github.com:xetorthio/jedis.git`
2. `cd jedis`
3. `mvn clean install -Dmaven.test.skip=true`
2. Install JReJSON (todo: add to maven)

## Official Releases

```xml
<dependencies>
<dependency>
<groupId>com.redislabs</groupId>
<artifactId>jrejson</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
```

### Snapshots

```xml
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
```

and

```xml
<dependencies>
<dependency>
<groupId>com.redislabs</groupId>
<artifactId>jrejson</artifactId>
<version>1.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
```


## Build
1. Clone it: `git clone git@github.com:RedisLabs/JReJSON.git`
2. `cd JReJSON`
3. `mvn clean install -Dmaven.test.skip=true`
Expand Down
191 changes: 104 additions & 87 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,65 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ BSD 2-Clause License
~
~ Copyright (c) 2017, Redis Labs
~ All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ * Redistributions of source code must retain the above copyright notice, this
~ list of conditions and the following disclaimer.
~
~ * Redistributions in binary form must reproduce the above copyright notice,
~ this list of conditions and the following disclaimer in the documentation
~ and/or other materials provided with the distribution.
~
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
~ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
~ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
~ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
~ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
~ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
~ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
~ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
~ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
~ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.redislabs</groupId>
<artifactId>jrejson</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>jrejson</name>
<version>1.0.0</version>

<name>JReJSON</name>
<description>Official client for ReJSON</description>
<url>https://oss.redislabs.com/rejson</url>

<organization>
<name>RedisLabs</name>
<url>www.redislabs.com</url>
</organization>
<issueManagement>
<system>github</system>
<url>https://github.com/RedisLabs/JReJSON/issues</url>
</issueManagement>
<scm>
<connection>scm:git:git@github.com:RedisLabs/JReJSON.git</connection>
<url>scm:git:git@github.com:RedisLabs/JReJSON.git</url>
<developerConnection>scm:git:git@github.com:RedisLabs/JReJSON.git</developerConnection>
<tag>1.0.0</tag>
</scm>
<developers>
<developer>
<name>Itamar Haber</name>
<organization>redislabs</organization>
<organizationUrl>https://redislabs.com/</organizationUrl>
</developer>
</developers>

<scm>
<connection>scm:git:git@github.com:RedisLabs/JReJSON.git</connection>
<url>scm:git:git@github.com:RedisLabs/JReJSON.git</url>
<developerConnection>scm:git:git@github.com:RedisLabs/JReJSON.git</developerConnection>
<tag>1.0.0</tag>
</scm>

<issueManagement>
<system>github</system>
<url>https://github.com/RedisLabs/JReJSON/issues</url>
</issueManagement>

<licenses>
<license>
<name>BSD 2 Clause</name>
<url>https://opensource.org/licenses/BSD-2-Clause</url>
<distribution>repo</distribution>
</license>
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.test.source>8</maven.test.source>
<maven.test.target>8</maven.test.target>
<gson.version>2.8.0</gson.version>
<jedis.version>3.0.0-SNAPSHOT</jedis.version>
<commons.pool2.version>2.4.2</commons.pool2.version>
Expand All @@ -81,7 +67,6 @@
<artifactId>commons-pool2</artifactId>
<version>${commons.pool2.version}</version>
</dependency>
<!-- test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -90,60 +75,92 @@
</dependency>
</dependencies>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<version>3.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>

</plugins>
</build>
</project>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<!--Include sources and docs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!--Sign the components - this is required by maven central for releases -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
28 changes: 14 additions & 14 deletions src/main/java/com/redislabs/modules/rejson/JReJSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.google.gson.Gson;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.commands.ProtocolCommand;
import redis.clients.util.SafeEncoder;
import redis.clients.jedis.util.SafeEncoder;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -128,9 +128,9 @@ public static Long del(Jedis conn, String key, Path... path) {
args.add(SafeEncoder.encode(key));
args.add(SafeEncoder.encode(getSingleOptionalPath(path).toString()));

Long rep = conn.getClient()
.sendCommand(Command.DEL, args.toArray(new byte[args.size()][]))
.getIntegerReply();
conn.getClient()
.sendCommand(Command.DEL, args.toArray(new byte[args.size()][]));
Long rep = conn.getClient().getIntegerReply();
conn.close();

return rep;
Expand All @@ -152,9 +152,9 @@ public static Object get(Jedis conn, String key, Path... paths) {
args.add(SafeEncoder.encode(p.toString()));
}

String rep = conn.getClient()
.sendCommand(Command.GET, args.toArray(new byte[args.size()][]))
.getBulkReply();
conn.getClient()
.sendCommand(Command.GET, args.toArray(new byte[args.size()][]));
String rep = conn.getClient().getBulkReply();
conn.close();

assertReplyNotError(rep);
Expand All @@ -180,9 +180,9 @@ public static void set(Jedis conn, String key, Object object, ExistenceModifier
args.add(flag.getRaw());
}

String status = conn.getClient()
.sendCommand(Command.SET, args.toArray(new byte[args.size()][]))
.getStatusCodeReply();
conn.getClient()
.sendCommand(Command.SET, args.toArray(new byte[args.size()][]));
String status = conn.getClient().getStatusCodeReply();
conn.close();

assertReplyOK(status);
Expand All @@ -198,7 +198,7 @@ public static void set(Jedis conn, String key, Object object, ExistenceModifier
public static void set(Jedis conn, String key, Object object, Path... path) {
set(conn,key, object, ExistenceModifier.DEFAULT, path);
}

/**
* Gets the class of an object
* @param conn the Jedis connection
Expand All @@ -213,9 +213,9 @@ public static Class<?> type(Jedis conn, String key, Path... path) {
args.add(SafeEncoder.encode(key));
args.add(SafeEncoder.encode(getSingleOptionalPath(path).toString()));

String rep = conn.getClient()
.sendCommand(Command.TYPE, args.toArray(new byte[args.size()][]))
.getBulkReply();
conn.getClient()
.sendCommand(Command.TYPE, args.toArray(new byte[args.size()][]));
String rep = conn.getClient().getBulkReply();
conn.close();

assertReplyNotError(rep);
Expand Down