From ef5faf292669993cc7f004670a5ccbf5666a39ee Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Tue, 13 Mar 2018 10:43:04 +0100 Subject: [PATCH] gitbook doesn't like blank after tripple ticks - remove them --- docs/Drivers/Java/Reference/README.md | 110 +++++++++++++------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/docs/Drivers/Java/Reference/README.md b/docs/Drivers/Java/Reference/README.md index 70ae95297..18002081a 100644 --- a/docs/Drivers/Java/Reference/README.md +++ b/docs/Drivers/Java/Reference/README.md @@ -63,7 +63,7 @@ Setup with default configuration, this automatically loads a properties file arangodb.properties if exists in the classpath: -``` Java +```Java // this instance is thread-safe ArangoDB arangoDB = new ArangoDB.Builder().build(); @@ -85,20 +85,20 @@ The driver is configured with some default values: To customize the configuration the parameters can be changed in the code... -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().host("192.168.182.50", 8888).build(); ``` ... or with a custom properties file (my.properties) -``` Java +```Java InputStream in = MyClass.class.getResourceAsStream("my.properties"); ArangoDB arangoDB = new ArangoDB.Builder().loadProperties(in).build(); ``` Example for arangodb.properties: -``` Java +```Java arangodb.hosts=127.0.0.1:8529,127.0.0.1:8529 arangodb.user=root arangodb.password= @@ -109,7 +109,7 @@ Example for arangodb.properties: The drivers default used network protocol is the binary protocol VelocyStream which offers the best performance within the driver. To use HTTP, you have to set the configuration `useProtocol` to `Protocol.HTTP_JSON` for HTTP with Json content or `Protocol.HTTP_VPACK` for HTTP with [VelocyPack](https://github.com/arangodb/velocypack/blob/master/VelocyPack.md) content. -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().useProtocol(Protocol.VST).build(); @@ -131,7 +131,7 @@ In addition to set the configuration for HTTP you have to add the apache httpcli To use SSL, you have to set the configuration `useSsl` to `true` and set a `SSLContext`. (see [example code](../src/test/java/com/arangodb/example/ssl/SslExample.java)) -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().useSsl(true).sslContext(sc).build(); @@ -141,7 +141,7 @@ To use SSL, you have to set the configuration `useSsl` to `true` and set a `SSLC The driver supports connection pooling for VelocyStream with a default of 1 and HTTP with a default of 20 maximum connections. To change this value use the method `maxConnections(Integer)` in `ArangoDB.Builder`. -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().maxConnections(8).build(); @@ -151,7 +151,7 @@ The driver supports connection pooling for VelocyStream with a default of 1 and The driver supports configuring multiple hosts. The first host is used to open a connection to. When this host is not reachable the next host from the list is used. To use this feature just call the method `host(String, int)` multiple times. -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().host("host1", 8529).host("host2", 8529).build(); @@ -159,7 +159,7 @@ The driver supports configuring multiple hosts. The first host is used to open a Since version 4.3 the driver support acquiring a list of known hosts in a cluster setup or a single server setup with followers. For this the driver has to be able to successfully open a connection to at least one host to get the list of hosts. Then it can use this list when fallback is needed. To use this feature just pass `true` to the method `acquireHostList(boolean)`. -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().acquireHostList(true).build(); @@ -171,7 +171,7 @@ Since version 4.3 the driver supports load balancing for cluster setups in two d The first one is a round robin load balancing where the driver iterates through a list of known hosts and performs every request on a different host than the request before. This load balancing strategy only work when the maximun of connections is greater 1. -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().loadBalancingStrategy(LoadBalancingStrategy.ROUND_ROBIN).maxConnections(8).build(); @@ -179,7 +179,7 @@ The first one is a round robin load balancing where the driver iterates through Just like the Fallback hosts feature the round robin load balancing strategy can use the `acquireHostList` configuration to acquire a list of all known hosts in the cluster. Do so only requires the manually configuration of only one host. Because this list is updated frequently it makes load balancing over the whole cluster very comfortable. -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().loadBalancingStrategy(LoadBalancingStrategy.ROUND_ROBIN).maxConnections(8).acquireHostList(true).build(); @@ -188,7 +188,7 @@ Just like the Fallback hosts feature the round robin load balancing strategy can The second load balancing strategy allows to pick a random host from the configured or acquired list of hosts and sticks to that host as long as the connection is open. This strategy is useful for an application - using the driver - which provides a session management where each session has its own instance of `ArangoDB` build from a global configured list of hosts. In this case it could be wanted that every sessions sticks with all its requests to the same host but not all sessions should use the same host. This load balancing strategy also works together with `acquireHostList`. -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().loadBalancingStrategy(LoadBalancingStrategy.ONE_RANDOM).acquireHostList(true).build(); @@ -219,7 +219,7 @@ Added support for: ``` -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJdk8Module()).build(); ``` @@ -240,7 +240,7 @@ Added support for: ``` -``` Scala +```Scala val arangoDB: ArangoDB = new ArangoDB.Builder().registerModule(new VPackScalaModule).build ``` @@ -262,12 +262,12 @@ Added support for: ``` -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJodaModule()).build(); ``` ## custom serializer -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackModule() { @Override public > void setup(final C context) { @@ -297,14 +297,14 @@ ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJodaModule()) # Manipulating databases ## create database -``` Java +```Java // create database arangoDB.createDatabase("myDatabase"); ``` ## drop database -``` Java +```Java // drop database arangoDB.db("myDatabase").drop(); @@ -313,21 +313,21 @@ ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackJodaModule()) # Manipulating collections ## create collection -``` Java +```Java // create collection arangoDB.db("myDatabase").createCollection("myCollection", null); ``` ## drop collection -``` Java +```Java // delete collection arangoDB.db("myDatabase").collection("myCollection").drop(); ``` ## truncate collection -``` Java +```Java arangoDB.db("myDatabase").collection("myCollection").truncate(); ``` @@ -337,7 +337,7 @@ Every document operations works with POJOs (e.g. MyObject), VelocyPack (VPackSli For the next examples we use a small object: -``` Java +```Java public class MyObject { private String key; @@ -362,7 +362,7 @@ For the next examples we use a small object: ``` ## insert document -``` Java +```Java MyObject myObject = new MyObject("Homer", 38); arangoDB.db("myDatabase").collection("myCollection").insertDocument(myObject); @@ -370,31 +370,31 @@ For the next examples we use a small object: When creating a document, the attributes of the object will be stored as key-value pair E.g. in the previous example the object was stored as follows: -``` properties +```properties "name" : "Homer" "age" : "38" ``` ## delete document -``` Java +```Java arangoDB.db("myDatabase").collection("myCollection").deleteDocument(myObject.getKey()); ``` ## update document -``` Java +```Java arangoDB.db("myDatabase").collection("myCollection").updateDocument(myObject.getKey(), myUpdatedObject); ``` ## replace document -``` Java +```Java arangoDB.db("myDatabase").collection("myCollection").replaceDocument(myObject.getKey(), myObject2); ``` ## read document as JavaBean -``` Java +```Java MyObject document = arangoDB.db("myDatabase").collection("myCollection").getDocument(myObject.getKey(), MyObject.class); document.getName(); document.getAge(); @@ -402,7 +402,7 @@ E.g. in the previous example the object was stored as follows: ``` ## read document as VelocyPack -``` Java +```Java VPackSlice document = arangoDB.db("myDatabase").collection("myCollection").getDocument(myObject.getKey(), VPackSlice.class); document.get("name").getAsString(); document.get("age").getAsInt(); @@ -410,19 +410,19 @@ E.g. in the previous example the object was stored as follows: ``` ## read document as Json -``` Java +```Java String json = arangoDB.db("myDatabase").collection("myCollection").getDocument(myObject.getKey(), String.class); ``` ## read document by key -``` Java +```Java arangoDB.db("myDatabase").collection("myCollection").getDocument("myKey", MyObject.class); ``` ## read document by id -``` Java +```Java arangoDB.db("myDatabase").getDocument("myCollection/myKey", MyObject.class); ``` @@ -430,7 +430,7 @@ E.g. in the previous example the object was stored as follows: # Multi Document operations ## insert documents -``` Java +```Java Collection documents = new ArrayList<>; documents.add(myObject1); documents.add(myObject2); @@ -440,7 +440,7 @@ E.g. in the previous example the object was stored as follows: ``` ## delete documents -``` Java +```Java Collection keys = new ArrayList<>; keys.add(myObject1.getKey()); keys.add(myObject2.getKey()); @@ -450,7 +450,7 @@ E.g. in the previous example the object was stored as follows: ``` ## update documents -``` Java +```Java Collection documents = new ArrayList<>; documents.add(myObject1); documents.add(myObject2); @@ -460,7 +460,7 @@ E.g. in the previous example the object was stored as follows: ``` ## replace documents -``` Java +```Java Collection documents = new ArrayList<>; documents.add(myObject1); documents.add(myObject2); @@ -477,7 +477,7 @@ Every AQL operations works with POJOs (e.g. MyObject), VelocyPack (VPackSlice) a E.g. get all Simpsons aged 3 or older in ascending order: -``` Java +```Java arangoDB.createDatabase("myDatabase"); ArangoDatabase db = arangoDB.db("myDatabase"); @@ -503,7 +503,7 @@ E.g. get all Simpsons aged 3 or older in ascending order: or return the AQL result as VelocyPack: -``` Java +```Java ArangoCursor cursor = db.query(query, bindVars, null, VPackSlice.class); for(; cursor.hasNext;) { @@ -523,7 +523,7 @@ Some of the basic graph operations are described in the following: ## add graph A graph consists of vertices and edges (stored in collections). Which collections are used within a graph is defined via edge definitions. A graph can contain more than one edge definition, at least one is needed. -``` Java +```Java Collection edgeDefinitions = new ArrayList<>(); EdgeDefinition edgeDefinition = new EdgeDefinition(); // define the edgeCollection to store the edges @@ -549,7 +549,7 @@ A graph consists of vertices and edges (stored in collections). Which collection A graph can be deleted by its name -``` Java +```Java arangoDB.db("myDatabase").graph("myGraph").drop(); ``` @@ -557,7 +557,7 @@ A graph can be deleted by its name Vertices are stored in the vertex collections defined above. -``` Java +```Java MyObject myObject1 = new MyObject("Homer", 38); MyObject myObject2 = new MyObject("Marge", 36); arangoDB.db("myDatabase").graph("myGraph").vertexCollection("collection1").insertVertex(myObject1, null); @@ -569,7 +569,7 @@ Vertices are stored in the vertex collections defined above. Now an edge can be created to set a relation between vertices -``` Java +```Java arangoDB.db("myDatabase").graph("myGraph").edgeCollection("myEdgeCollection").insertEdge(myEdgeObject, null); ``` @@ -577,7 +577,7 @@ Now an edge can be created to set a relation between vertices # Foxx ## call a service -``` Java +```Java Request request = new Request("mydb", RequestType.GET, "/my/foxx/service") Response response = arangoDB.execute(request); @@ -588,18 +588,18 @@ Now an edge can be created to set a relation between vertices If you are using [authentication] (https://docs.arangodb.com/Manual/GettingStarted/Authentication.html) you can manage users with the driver. ## add user -``` Java +```Java //username, password arangoDB.createUser("myUser", "myPassword"); ``` ## delete user -``` Java +```Java arangoDB.deleteUser("myUser"); ``` ## list users -``` Java +```Java Collection users = arangoDB.getUsers(); for(UserResult user : users) { System.out.println(user.getUser()) @@ -607,12 +607,12 @@ If you are using [authentication] (https://docs.arangodb.com/Manual/GettingStart ``` ## grant user access -``` Java +```Java arangoDB.db("myDatabase").grantAccess("myUser"); ```` ## revoke user access -``` Java +```Java arangoDB.db("myDatabase").revokeAccess("myUser"); ```` @@ -621,7 +621,7 @@ If you are using [authentication] (https://docs.arangodb.com/Manual/GettingStart ## JavaBeans The driver can serialize/deserialize JavaBeans. They need at least a constructor without parameter. -``` Java +```Java public class MyObject { private String name; @@ -638,7 +638,7 @@ The driver can serialize/deserialize JavaBeans. They need at least a constructor ## internal fields To use Arango-internal fields (like _id, _key, _rev, _from, _to) in your JavaBeans, use the annotation `DocumentField`. -``` Java +```Java public class MyObject { @DocumentField(Type.KEY) @@ -658,7 +658,7 @@ To use Arango-internal fields (like _id, _key, _rev, _from, _to) in your JavaBea ## serialized fieldnames To use a different serialized name for a field, use the annotation `SerializedName`. -``` Java +```Java public class MyObject { @SerializedName("title") @@ -677,7 +677,7 @@ To use a different serialized name for a field, use the annotation `SerializedNa ## ignore fields To ignore fields at serialization/deserialization, use the annotation `Expose` -``` Java +```Java public class MyObject { @Expose @@ -694,7 +694,7 @@ To ignore fields at serialization/deserialization, use the annotation `Expose` ``` ## custom serializer -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder().registerModule(new VPackModule() { @Override public > void setup(final C context) { @@ -723,12 +723,12 @@ To ignore fields at serialization/deserialization, use the annotation `Expose` ## manually serialization To de-/serialize from and to VelocyPack before or after a database call, use the `ArangoUtil` from the method `util()` in `ArangoDB`, `ArangoDatabase`, `ArangoCollection`, `ArangoGraph`, `ArangoEdgeCollection`or `ArangoVertexCollection`. -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder(); VPackSlice vpack = arangoDB.util().serialize(myObj); ``` -``` Java +```Java ArangoDB arangoDB = new ArangoDB.Builder(); MyObject myObj = arangoDB.util().deserialize(vpack, MyObject.class); ```