Database Reference
In-Depth Information
Server plugins
Server plugins provide an architectural pattern exposed by Neo4j for extending its func-
tionality and exposing the new REST endpoints for its consumers.
These new REST endpoints are automatically exposed and advertised in the representations
and clients can discover the extension implemented by the plugins by performing a GET on
the default database URI:
http://localhost:7474/db/data/
or
ht-
tps://localhost:7473/db/data/
.
Let's extend our
Spring-Neo4j
project and perform the following steps to implement a
server plugin for traversing the graph from a given node on the movie dataset that we cre-
ated in
Chapter 3
,
Pattern Matching in Neo4j
, under the
Read-only Cypher queries
section:
1. Remove the project's JAR file from
<$NEO4J_HOME>/lib/
, which we copied
during our previous example stated in the
Fine-grained authorization
section.
2. Disable all custom security rules (if any). Open
<$NEO4J_HOME>/conf/
neo4j-server.properties
and comment the entry, which starts with
org.neo4j.server.rest.security_rules
.
3. Create a new package,
org.neo4j.custom.server.plugins
, and define a
new Java class
GraphTraversal.java
under this new package.
4. Add the following code in
GraphTraversal.java
and follow the comments
provided in the code to understand the implementation logic:
package org.neo4j.custom.server.plugins;
import java.util.ArrayList;
import java.util.List;
import org.neo4j.cypher.*;
import org.neo4j.graphdb.*;
import org.neo4j.graphdb.factory.Description;
import org.neo4j.graphdb.traversal.*;
import org.neo4j.kernel.impl.util.StringLogger;
import org.neo4j.server.plugins.*
import scala.collection.Iterator;
@Description("An extension to the Neo4j Server for
Traversing graph till 3 levels in all directions from