Skip to content

Commit 9d76f94

Browse files
committed
added ArangoJack to replace VelocyJack
1 parent e936efa commit 9d76f94

16 files changed

+4420
-38
lines changed

ChangeLog.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
- added `com.arangodb.mapping.ArangoJack` to replace `com.arangodb.jackson.dataformat.velocypack.VelocyJack` (from
10+
`com.arangodb:jackson-dataformat-velocypack`)
11+
12+
- fixed removing removed coordinators from the hostlist (#347)
13+
914
## [6.8.2] - 2021-01-25
1015

1116
- fixed closing connection on failed authentication (#ES-772)

pom.xml

+20-23
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.arangodb</groupId>
77
<artifactId>arangodb-java-driver</artifactId>
8-
<version>6.8.2</version>
8+
<version>6.9.0-SNAPSHOT</version>
99
<inceptionYear>2016</inceptionYear>
1010
<packaging>jar</packaging>
1111

@@ -97,6 +97,11 @@
9797
<artifactId>maven-compiler-plugin</artifactId>
9898
<version>3.8.1</version>
9999
<configuration>
100+
<compilerArgs>
101+
<arg>-Xlint:unchecked</arg>
102+
<arg>-Xlint:deprecation</arg>
103+
</compilerArgs>
104+
<showWarnings>true</showWarnings>
100105
<source>1.8</source>
101106
<target>1.8</target>
102107
</configuration>
@@ -175,11 +180,6 @@
175180
</build>
176181

177182
<dependencies>
178-
<dependency>
179-
<groupId>org.apache.httpcomponents</groupId>
180-
<artifactId>httpclient</artifactId>
181-
<optional>true</optional>
182-
</dependency>
183183
<dependency>
184184
<groupId>com.arangodb</groupId>
185185
<artifactId>velocypack</artifactId>
@@ -188,6 +188,16 @@
188188
<groupId>org.slf4j</groupId>
189189
<artifactId>slf4j-api</artifactId>
190190
</dependency>
191+
<dependency>
192+
<groupId>org.apache.httpcomponents</groupId>
193+
<artifactId>httpclient</artifactId>
194+
<optional>true</optional>
195+
</dependency>
196+
<dependency>
197+
<groupId>com.arangodb</groupId>
198+
<artifactId>jackson-dataformat-velocypack</artifactId>
199+
<optional>true</optional>
200+
</dependency>
191201
<dependency>
192202
<groupId>ch.qos.logback</groupId>
193203
<artifactId>logback-classic</artifactId>
@@ -198,22 +208,11 @@
198208
<artifactId>junit</artifactId>
199209
<scope>test</scope>
200210
</dependency>
201-
<dependency>
202-
<groupId>com.fasterxml.jackson.core</groupId>
203-
<artifactId>jackson-core</artifactId>
204-
<scope>test</scope>
205-
</dependency>
206211
<dependency>
207212
<groupId>org.hamcrest</groupId>
208213
<artifactId>hamcrest-all</artifactId>
209214
<scope>test</scope>
210215
</dependency>
211-
<dependency>
212-
<groupId>com.arangodb</groupId>
213-
<artifactId>jackson-dataformat-velocypack</artifactId>
214-
<version>0.3.0</version>
215-
<scope>test</scope>
216-
</dependency>
217216
<dependency>
218217
<groupId>org.reflections</groupId>
219218
<artifactId>reflections</artifactId>
@@ -225,11 +224,9 @@
225224
<dependencyManagement>
226225
<dependencies>
227226
<dependency>
228-
<groupId>com.fasterxml.jackson</groupId>
229-
<artifactId>jackson-bom</artifactId>
230-
<version>2.11.3</version>
231-
<scope>import</scope>
232-
<type>pom</type>
227+
<groupId>com.arangodb</groupId>
228+
<artifactId>jackson-dataformat-velocypack</artifactId>
229+
<version>1.0.0-SNAPSHOT</version>
233230
</dependency>
234231
<dependency>
235232
<groupId>org.apache.httpcomponents</groupId>
@@ -254,7 +251,7 @@
254251
<dependency>
255252
<groupId>com.arangodb</groupId>
256253
<artifactId>velocypack</artifactId>
257-
<version>2.5.0</version>
254+
<version>2.5.1</version>
258255
</dependency>
259256
<dependency>
260257
<groupId>org.slf4j</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2016 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.internal.mapping;
22+
23+
24+
import com.arangodb.entity.DocumentField;
25+
import com.arangodb.velocypack.annotations.Expose;
26+
import com.arangodb.velocypack.annotations.SerializedName;
27+
import com.fasterxml.jackson.annotation.JsonProperty;
28+
import com.fasterxml.jackson.databind.PropertyName;
29+
import com.fasterxml.jackson.databind.introspect.Annotated;
30+
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
31+
import com.fasterxml.jackson.databind.introspect.AnnotatedParameter;
32+
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
33+
34+
/**
35+
* @author Michele Rastelli
36+
*/
37+
public class ArangoAnnotationIntrospector extends JacksonAnnotationIntrospector {
38+
39+
@Override
40+
public JsonProperty.Access findPropertyAccess(Annotated m) {
41+
if (!(m instanceof AnnotatedMember)) {
42+
return super.findPropertyAccess(m);
43+
}
44+
45+
final Expose expose = m.getAnnotation(Expose.class);
46+
if (expose != null) {
47+
final boolean serialize = expose.serialize();
48+
final boolean deserialize = expose.deserialize();
49+
50+
if (serialize && deserialize) {
51+
return JsonProperty.Access.READ_WRITE;
52+
} else if (serialize) {
53+
return JsonProperty.Access.READ_ONLY;
54+
} else if (deserialize) {
55+
return JsonProperty.Access.WRITE_ONLY;
56+
}
57+
}
58+
59+
return super.findPropertyAccess(m);
60+
}
61+
62+
@Override
63+
public boolean hasIgnoreMarker(AnnotatedMember m) {
64+
final Expose expose = m.getAnnotation(Expose.class);
65+
if (expose != null && !expose.serialize() && !expose.deserialize()) {
66+
return true;
67+
}
68+
return super.hasIgnoreMarker(m);
69+
}
70+
71+
@Override
72+
public PropertyName findNameForSerialization(Annotated a) {
73+
PropertyName name = findPropertyName(a);
74+
if (name != null) {
75+
return name;
76+
} else {
77+
return super.findNameForSerialization(a);
78+
}
79+
}
80+
81+
@Override
82+
public PropertyName findNameForDeserialization(Annotated a) {
83+
PropertyName name = findPropertyName(a);
84+
if (name != null) {
85+
return name;
86+
} else {
87+
return super.findNameForDeserialization(a);
88+
}
89+
}
90+
91+
@Override
92+
public String findImplicitPropertyName(AnnotatedMember member) {
93+
String name = findParameterName(member);
94+
if (name != null) {
95+
return name;
96+
} else {
97+
return super.findImplicitPropertyName(member);
98+
}
99+
}
100+
101+
private String findParameterName(Annotated a) {
102+
if (!(a instanceof AnnotatedParameter)) {
103+
return null;
104+
}
105+
106+
final SerializedName serializedName = a.getAnnotation(SerializedName.class);
107+
if (serializedName != null) {
108+
return serializedName.value();
109+
}
110+
111+
return null;
112+
}
113+
114+
private PropertyName findPropertyName(Annotated a) {
115+
if (!(a instanceof AnnotatedMember)) {
116+
return null;
117+
}
118+
119+
final DocumentField documentField = a.getAnnotation(DocumentField.class);
120+
if (documentField != null) {
121+
return PropertyName.construct(documentField.value().getSerializeName());
122+
}
123+
124+
final SerializedName serializedName = a.getAnnotation(SerializedName.class);
125+
if (serializedName != null) {
126+
return PropertyName.construct(serializedName.value());
127+
}
128+
129+
return null;
130+
}
131+
132+
}
133+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* DISCLAIMER
3+
*
4+
* Copyright 2017 ArangoDB GmbH, Cologne, Germany
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
*/
20+
21+
package com.arangodb.internal.mapping;
22+
23+
import com.arangodb.entity.BaseDocument;
24+
import com.arangodb.entity.BaseEdgeDocument;
25+
import com.arangodb.jackson.dataformat.velocypack.internal.VPackParser;
26+
import com.arangodb.velocypack.VPackSlice;
27+
import com.arangodb.velocypack.internal.util.DateUtil;
28+
import com.fasterxml.jackson.core.JsonParser;
29+
import com.fasterxml.jackson.core.JsonProcessingException;
30+
import com.fasterxml.jackson.databind.DeserializationContext;
31+
import com.fasterxml.jackson.databind.JsonDeserializer;
32+
33+
import java.io.IOException;
34+
import java.text.ParseException;
35+
import java.util.Map;
36+
37+
/**
38+
* @author Mark Vollmary
39+
*/
40+
public class VPackDeserializers {
41+
42+
public static final JsonDeserializer<VPackSlice> VPACK = new JsonDeserializer<VPackSlice>() {
43+
@Override
44+
public VPackSlice deserialize(final JsonParser p, final DeserializationContext ctxt)
45+
throws IOException, JsonProcessingException {
46+
if (p instanceof VPackParser) {
47+
final VPackSlice vpack = ((VPackParser) p).getVPack();
48+
// consume each element
49+
if (vpack.isArray() || vpack.isObject()) {
50+
for (int i = 0; i < vpack.size() + 1; i++) {
51+
p.nextToken();
52+
}
53+
}
54+
return vpack;
55+
}
56+
return new VPackSlice(p.getBinaryValue());
57+
}
58+
};
59+
60+
public static final JsonDeserializer<java.util.Date> UTIL_DATE = new JsonDeserializer<java.util.Date>() {
61+
@Override
62+
public java.util.Date deserialize(final JsonParser p, final DeserializationContext ctxt)
63+
throws IOException, JsonProcessingException {
64+
try {
65+
return DateUtil.parse(p.getValueAsString());
66+
} catch (final ParseException e) {
67+
throw new IOException(e);
68+
}
69+
}
70+
};
71+
72+
public static final JsonDeserializer<java.sql.Date> SQL_DATE = new JsonDeserializer<java.sql.Date>() {
73+
@Override
74+
public java.sql.Date deserialize(final JsonParser p, final DeserializationContext ctxt)
75+
throws IOException, JsonProcessingException {
76+
try {
77+
return new java.sql.Date(DateUtil.parse(p.getValueAsString()).getTime());
78+
} catch (final ParseException e) {
79+
throw new IOException(e);
80+
}
81+
}
82+
};
83+
84+
public static final JsonDeserializer<java.sql.Timestamp> SQL_TIMESTAMP = new JsonDeserializer<java.sql.Timestamp>() {
85+
@Override
86+
public java.sql.Timestamp deserialize(final JsonParser p, final DeserializationContext ctxt)
87+
throws IOException, JsonProcessingException {
88+
try {
89+
return new java.sql.Timestamp(DateUtil.parse(p.getValueAsString()).getTime());
90+
} catch (final ParseException e) {
91+
throw new IOException(e);
92+
}
93+
}
94+
};
95+
96+
public static final JsonDeserializer<BaseDocument> BASE_DOCUMENT = new JsonDeserializer<BaseDocument>() {
97+
@SuppressWarnings("unchecked")
98+
@Override
99+
public BaseDocument deserialize(final JsonParser p, final DeserializationContext ctxt)
100+
throws IOException, JsonProcessingException {
101+
return new BaseDocument(p.readValueAs(Map.class));
102+
}
103+
};
104+
105+
public static final JsonDeserializer<BaseEdgeDocument> BASE_EDGE_DOCUMENT = new JsonDeserializer<BaseEdgeDocument>() {
106+
@SuppressWarnings("unchecked")
107+
@Override
108+
public BaseEdgeDocument deserialize(final JsonParser p, final DeserializationContext ctxt)
109+
throws IOException, JsonProcessingException {
110+
return new BaseEdgeDocument(p.readValueAs(Map.class));
111+
}
112+
};
113+
114+
}

0 commit comments

Comments
 (0)