-
-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
# neo4j driver | ||
|
||
[Neo4j](https://neo4j.com/) driver for Jooby. | ||
|
||
## exports | ||
|
||
* [BoltDBAccess](https://neo4j.com/developer/java/#jcypher) | ||
|
||
## dependency | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.jooby</groupId> | ||
<artifactId>jooby-neo4j</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
``` | ||
|
||
## usage | ||
|
||
application.conf: | ||
|
||
```properties | ||
neo4j.db { | ||
uri = "bolt://localhost:7687" | ||
username = "neo4j" | ||
password = "neo4j1" | ||
} | ||
``` | ||
|
||
```java | ||
{ | ||
use(new Neo4j()); | ||
get("/", req -> { | ||
BoltDBAccess db = require(BoltDBAccess.class); | ||
// work with db | ||
}); | ||
} | ||
``` | ||
|
||
Default connection info property is ```db``` but of course you can use any other name: | ||
|
||
application.conf: | ||
|
||
```properties | ||
neo4j.mydb { | ||
uri = "bolt://localhost:7687" | ||
username = "neo4j" | ||
password = "neo4j1" | ||
} | ||
``` | ||
|
||
```java | ||
{ | ||
use(new Neo4j("mydb")); | ||
get("/", req -> { | ||
BoltDBAccess db = require(BoltDBAccess.class); | ||
// work with db | ||
}); | ||
} | ||
``` | ||
|
||
## properties | ||
|
||
Properties can be set via ```.conf``` file: | ||
|
||
```properties | ||
neo4j.db.arrayBlockSize = "120" | ||
``` | ||
|
||
or programmatically: | ||
|
||
```java | ||
{ | ||
use(new Neo4j() | ||
.properties((properties, config) -> { | ||
properties.put(DBProperties.ARRAY_BLOCK_SIZE, "120") | ||
}) | ||
); | ||
} | ||
``` | ||
|
||
### connection URI | ||
|
||
Default connection URI is defined by the ```neo4j.db.uri``` property. Neo4j URI looks like: | ||
|
||
```properties | ||
neo4j.db.uri = bolt://host1[:port1] | ||
``` | ||
|
||
For more detailed information please check: [Neo4jBoltDrivers](https://neo4j.com/docs/developer-manual/current/drivers/). | ||
|
||
# neo4j session store | ||
|
||
## dependency | ||
|
||
```xml | ||
<dependency> | ||
<groupId>org.jooby</groupId> | ||
<artifactId>jooby-neo4j</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
``` | ||
|
||
## usage | ||
|
||
```java | ||
{ | ||
session(Neo4jSessionStore.class); | ||
get("/", req -> { | ||
req.session().set("name", "jooby"); | ||
}); | ||
} | ||
``` | ||
|
||
The ```name``` attribute and value will be stored in a [Neo4j](https://neo4j.com/). | ||
|
||
## properties | ||
|
||
### timeout | ||
|
||
By default, a neo4j session will expire after ```30 minutes```. Changing the default timeout is as simple as: | ||
|
||
```properties | ||
# 8 hours | ||
|
||
session.timeout = 8h | ||
|
||
# 15 seconds | ||
|
||
session.timeout = 15 | ||
|
||
# 120 minutes | ||
|
||
session.timeout = 120m | ||
|
||
# no timeout | ||
|
||
session.timeout = -1 | ||
``` | ||
|
||
It uses [GraphAware's expire library](https://github.com/graphaware/neo4j-expire) to automatically remove expired sessions. | ||
|
||
### session label | ||
|
||
It's possible to provide the session label using the `neo4j.session.label` property. | ||
|
||
## neo4j.conf | ||
|
||
```properties | ||
################################################################################################### | ||
|
||
# neo4j | ||
|
||
################################################################################################### | ||
|
||
neo4j.db { | ||
uri = "bolt://localhost:7687" | ||
arrayBlockSize = "120" | ||
pageCacheMemory = "1M" | ||
stringBlockSize = "120" | ||
username = "****" | ||
password = "****" | ||
} | ||
|
||
################################################################################################### | ||
|
||
# session datastore | ||
|
||
# databaseDir: "/tmp" | ||
|
||
# neo4j.session.label: "sessions" | ||
|
||
# session.timeout: 30m | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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/maven-v4_0_0.xsd"> | ||
|
||
<parent> | ||
<groupId>org.jooby</groupId> | ||
<artifactId>jooby-project</artifactId> | ||
<version>1.1.1</version> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>jooby-neo4j</artifactId> | ||
|
||
<name>neo4j module</name> | ||
|
||
<build> | ||
<plugins> | ||
<!-- sure-fire --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<includes> | ||
<include>**/*Test.java</include> | ||
<include>**/*Feature.java</include> | ||
<include>**/Issue*.java</include> | ||
</includes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<!-- Jooby --> | ||
<dependency> | ||
<groupId>org.jooby</groupId> | ||
<artifactId>jooby</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<!-- Neo4j --> | ||
<dependency> | ||
<groupId>net.iot-solutions.graphdb</groupId> | ||
<artifactId>jcypher</artifactId> | ||
<version>3.7.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.graphaware.neo4j</groupId> | ||
<artifactId>expire</artifactId> | ||
<version>3.1.4.49.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.graphaware.neo4j</groupId> | ||
<artifactId>runtime</artifactId> | ||
<version>3.1.4.49</version> | ||
</dependency> | ||
|
||
<!-- Test Dependencies --> | ||
<dependency> | ||
<groupId>org.jooby</groupId> | ||
<artifactId>jooby</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
<classifier>tests</classifier> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.easymock</groupId> | ||
<artifactId>easymock</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-api-easymock</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-module-junit4</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jooby</groupId> | ||
<artifactId>jooby-netty</artifactId> | ||
<version>${project.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>commons-lang</groupId> | ||
<artifactId>commons-lang</artifactId> | ||
<version>2.6</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Oops, something went wrong.