Skip to content

Commit 9abda43

Browse files
authored
Merge pull request #3 from leonchen83/master
modify following files
2 parents 12118c6 + e7dcd20 commit 9abda43

File tree

9 files changed

+328
-130
lines changed

9 files changed

+328
-130
lines changed

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,25 @@
44
!**/*.md
55
!.gitignore
66
!pom.xml
7+
8+
/target
9+
*.class
10+
11+
# Mobile Tools for Java (J2ME)
12+
.mtj.tmp/
13+
14+
# Package Files #
15+
*.jar
16+
*.war
17+
*.ear
18+
19+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
20+
hs_err_pid*
21+
22+
# Eclipse
23+
/.project
24+
/.classpath
25+
26+
# Idea
27+
/redis-replicator.iml
28+
/.idea

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ This project is currently WIP and the interface may change. Also note that only
1313
1. Install Jedis (once v3 is released this step will be obsolete)
1414
1. Clone it: `git clone --depth 1 git@github.com:xetorthio/jedis.git`
1515
2. `cd jedis`
16-
3. `mvn -Dmaven.test.skip=true install`
16+
3. `mvn clean install -Dmaven.test.skip=true`
1717
2. Install JReJSON (todo: add to maven)
1818
1. Clone it: `git clone git@github.com:RedisLabs/JReJSON.git`
1919
2. `cd JReJSON`
20-
3. `mvn -Dmaven.test.skip=true install`
20+
3. `mvn clean install -Dmaven.test.skip=true`
2121

2222
## Usage example
2323

24-
```java
24+
```java
2525
import redis.clients.jedis.Jedis;
26-
import io.rejson.JReJSON;
26+
import com.redislabs.modules.rejson.JReJSON;
2727

2828
// First get a connection
2929
Jedis jedis = new Jedis("localhost", 6379);

pom.xml

Lines changed: 103 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,149 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ BSD 2-Clause License
4+
~
5+
~ Copyright (c) 2017, Redis Labs
6+
~ All rights reserved.
7+
~
8+
~ Redistribution and use in source and binary forms, with or without
9+
~ modification, are permitted provided that the following conditions are met:
10+
~
11+
~ * Redistributions of source code must retain the above copyright notice, this
12+
~ list of conditions and the following disclaimer.
13+
~
14+
~ * Redistributions in binary form must reproduce the above copyright notice,
15+
~ this list of conditions and the following disclaimer in the documentation
16+
~ and/or other materials provided with the distribution.
17+
~
18+
~ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
~ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
~ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
~ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22+
~ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
~ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
~ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25+
~ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26+
~ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
~ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
-->
229
<project xmlns="http://maven.apache.org/POM/4.0.0"
330
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
431
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
532
<modelVersion>4.0.0</modelVersion>
633

734
<groupId>com.redislabs</groupId>
835
<artifactId>jrejson</artifactId>
9-
<version>1.0-SNAPSHOT</version>
36+
<version>1.0.0-SNAPSHOT</version>
37+
<name>jrejson</name>
38+
39+
<developers>
40+
<developer>
41+
<name>Itamar Haber</name>
42+
<organization>redislabs</organization>
43+
<organizationUrl>https://redislabs.com/</organizationUrl>
44+
</developer>
45+
</developers>
46+
47+
<scm>
48+
<connection>scm:git:git@github.com:RedisLabs/JReJSON.git</connection>
49+
<url>scm:git:git@github.com:RedisLabs/JReJSON.git</url>
50+
<developerConnection>scm:git:git@github.com:RedisLabs/JReJSON.git</developerConnection>
51+
<tag>1.0.0</tag>
52+
</scm>
53+
54+
<issueManagement>
55+
<system>github</system>
56+
<url>https://github.com/RedisLabs/JReJSON/issues</url>
57+
</issueManagement>
58+
59+
<properties>
60+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
61+
<maven.compiler.source>1.8</maven.compiler.source>
62+
<maven.compiler.target>1.8</maven.compiler.target>
63+
<gson.version>2.8.0</gson.version>
64+
<jedis.version>3.0.0-SNAPSHOT</jedis.version>
65+
<commons.pool2.version>2.4.2</commons.pool2.version>
66+
</properties>
67+
1068
<dependencies>
1169
<dependency>
1270
<groupId>redis.clients</groupId>
1371
<artifactId>jedis</artifactId>
14-
<version>3.0.0-SNAPSHOT</version>
72+
<version>${jedis.version}</version>
1573
</dependency>
1674
<dependency>
1775
<groupId>com.google.code.gson</groupId>
1876
<artifactId>gson</artifactId>
19-
<version>2.8.0</version>
77+
<version>${gson.version}</version>
2078
</dependency>
2179
<dependency>
2280
<groupId>org.apache.commons</groupId>
2381
<artifactId>commons-pool2</artifactId>
24-
<version>2.4.2</version>
82+
<version>${commons.pool2.version}</version>
2583
</dependency>
84+
<!-- test -->
2685
<dependency>
2786
<groupId>junit</groupId>
2887
<artifactId>junit</artifactId>
2988
<version>4.12</version>
89+
<scope>test</scope>
3090
</dependency>
3191
</dependencies>
32-
<properties>
33-
<maven.compiler.source>8</maven.compiler.source>
34-
<maven.compiler.target>8</maven.compiler.target>
35-
<maven.test.source>8</maven.test.source>
36-
<maven.test.target>8</maven.test.target>
37-
</properties>
38-
3992

4093
<build>
4194
<plugins>
4295
<plugin>
43-
<artifactId>maven-assembly-plugin</artifactId>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-jar-plugin</artifactId>
98+
<version>2.6</version>
99+
</plugin>
100+
<plugin>
101+
<groupId>org.apache.maven.plugins</groupId>
102+
<artifactId>maven-compiler-plugin</artifactId>
103+
<version>2.0.2</version>
104+
<configuration>
105+
<source>${maven.compiler.source}</source>
106+
<target>${maven.compiler.target}</target>
107+
<encoding>${project.build.sourceEncoding}</encoding>
108+
</configuration>
109+
</plugin>
110+
<plugin>
111+
<groupId>org.apache.maven.plugins</groupId>
112+
<artifactId>maven-resources-plugin</artifactId>
113+
<version>2.6</version>
44114
<configuration>
45-
<archive>
46-
<manifest>
47-
<addClasspath>true</addClasspath>
48-
<!--<mainClass></mainClass>-->
49-
</manifest>
50-
</archive>
51-
<descriptorRefs>
52-
<descriptorRef>jar-with-dependencies</descriptorRef>
53-
</descriptorRefs>
115+
<encoding>${project.build.sourceEncoding}</encoding>
116+
</configuration>
117+
</plugin>
118+
<plugin>
119+
<groupId>org.apache.maven.plugins</groupId>
120+
<artifactId>maven-javadoc-plugin</artifactId>
121+
<version>2.10.3</version>
122+
<configuration>
123+
<encoding>${project.build.sourceEncoding}</encoding>
54124
</configuration>
55125
<executions>
56126
<execution>
57-
<id>make-my-jar-with-dependencies</id>
58127
<phase>package</phase>
59128
<goals>
60-
<goal>single</goal>
129+
<goal>jar</goal>
61130
</goals>
62131
</execution>
63132
</executions>
64133
</plugin>
65134
<plugin>
66-
<artifactId>maven-compiler-plugin</artifactId>
67-
<version>3.0</version>
68-
<configuration>
69-
<source>1.8</source>
70-
<target>1.8</target>
71-
</configuration>
135+
<groupId>org.apache.maven.plugins</groupId>
136+
<artifactId>maven-source-plugin</artifactId>
137+
<version>3.0.0</version>
138+
<executions>
139+
<execution>
140+
<id>attach-sources</id>
141+
<goals>
142+
<goal>jar</goal>
143+
</goals>
144+
</execution>
145+
</executions>
72146
</plugin>
73147
</plugins>
74148
</build>
75-
76-
77-
78-
79149
</project>

src/main/java/io/rejson/JReJSON.java renamed to src/main/java/com/redislabs/modules/rejson/JReJSON.java

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
1-
package io.rejson;
1+
/*
2+
* BSD 2-Clause License
3+
*
4+
* Copyright (c) 2017, Redis Labs
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* * Redistributions of source code must retain the above copyright notice, this
11+
* list of conditions and the following disclaimer.
12+
*
13+
* * Redistributions in binary form must reproduce the above copyright notice,
14+
* this list of conditions and the following disclaimer in the documentation
15+
* and/or other materials provided with the distribution.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
package com.redislabs.modules.rejson;
230

331
import com.google.gson.Gson;
432
import redis.clients.jedis.Jedis;
@@ -95,7 +123,7 @@ else if (1 == path.length)
95123
*/
96124
public static Long del(Jedis conn, String key, Path... path) {
97125

98-
ArrayList<byte[]> args = new ArrayList(2);
126+
List<byte[]> args = new ArrayList(2);
99127

100128
args.add(SafeEncoder.encode(key));
101129
args.add(SafeEncoder.encode(getSingleOptionalPath(path).toString()));
@@ -117,7 +145,7 @@ public static Long del(Jedis conn, String key, Path... path) {
117145
*/
118146
public static Object get(Jedis conn, String key, Path... paths) {
119147

120-
ArrayList<byte[]> args = new ArrayList(2);
148+
List<byte[]> args = new ArrayList(2);
121149

122150
args.add(SafeEncoder.encode(key));
123151
for (Path p :paths) {
@@ -143,7 +171,7 @@ public static Object get(Jedis conn, String key, Path... paths) {
143171
*/
144172
public static void set(Jedis conn, String key, Object object, ExistenceModifier flag, Path... path) {
145173

146-
ArrayList<byte[]> args = new ArrayList(4);
174+
List<byte[]> args = new ArrayList(4);
147175

148176
args.add(SafeEncoder.encode(key));
149177
args.add(SafeEncoder.encode(getSingleOptionalPath(path).toString()));
@@ -178,11 +206,9 @@ public static void set(Jedis conn, String key, Object object, Path... path) {
178206
* @param path optional single path in the object, defaults to root
179207
* @return the Java class of the requested object
180208
*/
181-
public static Class<? extends Object> type(Jedis conn, String key, Path... path) {
182-
183-
ArrayList<byte[]> args = new ArrayList(2);
184-
209+
public static Class<?> type(Jedis conn, String key, Path... path) {
185210

211+
List<byte[]> args = new ArrayList(2);
186212

187213
args.add(SafeEncoder.encode(key));
188214
args.add(SafeEncoder.encode(getSingleOptionalPath(path).toString()));
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* BSD 2-Clause License
3+
*
4+
* Copyright (c) 2017, Redis Labs
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* * Redistributions of source code must retain the above copyright notice, this
11+
* list of conditions and the following disclaimer.
12+
*
13+
* * Redistributions in binary form must reproduce the above copyright notice,
14+
* this list of conditions and the following disclaimer in the documentation
15+
* and/or other materials provided with the distribution.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
package com.redislabs.modules.rejson;
30+
31+
/**
32+
* Path is a ReJSON path, representing a valid path into an object
33+
* TODO: make path building even more fun
34+
*/
35+
36+
public class Path {
37+
private final String strPath;
38+
39+
public Path(final String strPath) {
40+
this.strPath = strPath;
41+
}
42+
43+
/**
44+
* Makes a root path
45+
* @return the root path
46+
*/
47+
public static Path RootPath() {
48+
return new Path(".");
49+
}
50+
51+
@Override
52+
public String toString() {
53+
return strPath;
54+
}
55+
}

src/main/java/io/rejson/Path.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)