@Target(value=METHOD) @Retention(value=RUNTIME) public @interface Procedure
Procedures accept input, use that input to perform work, and then return a
Stream
of Records
. The work performed usually
involves one or more resources, such as a GraphDatabaseService
.
A procedure is associated with one of the following modes READ allows only reading the graph (default mode) WRITE allows reading and writing the graph SCHEMA allows reading the graphs and performing schema operations DBMS allows managing the database (i.e. change password)
Name
annotation, declaring the input name.
Valid input types are as follows:
String
Long
or long
Double
or double
Number
Boolean
or boolean
Node
Relationship
Path
Map
with key String
and value of any type in this list, including Map
List
with element type of any type in this list, including List
Object
, meaning any valid input typesStream
of Records
, or nothing.
The record is defined per procedure, as a class with only public, non-final fields.
The types, order and names of the fields in this class define the format of the returned records.
Valid field types are as follows:
String
Long
or long
Double
or double
Number
Boolean
or boolean
Node
Relationship
Path
Map
with key String
and value of any type in this list, including Map
List
of elements of any valid field type, including List
Object
, meaning any of the valid field typesContext
annotation. Fields declared this way are automatically injected with the
requested resource. This is how procedures gain access to APIs to do work with.
All fields in the class containing the procedure declaration must either be static; or it must be public, non-final
and annotated with Context
.
Resources supported by default are as follows:
GraphDatabaseService
Log
TerminationGuard
If you want to maintain state between invocations to your procedure, simply use a static field. Note that procedures may be called concurrently, meaning you need to take care to ensure the state you store in static fields can be safely accessed by multiple callers simultaneously.
Modifier and Type | Optional Element and Description |
---|---|
String |
deprecatedBy
When deprecating a procedure it is useful to indicate a possible
replacement procedure that clients might show in warnings
|
Mode |
mode
A procedure is associated with one of the following modes
READ allows only reading the graph (default mode)
WRITE allows reading and writing the graph
SCHEMA allows reading the graphs and performing schema operations
DBMS allows managing the database (i.e.
|
String |
name
Synonym for
value() |
String |
value
The namespace and name for the procedure, as a period-separated
string.
|
public abstract String value
myprocedures.myprocedure
.
If this is left empty, the name defaults to the package name of
the class the procedure is declared in, combined with the method
name. Notably, the class name is omitted.public abstract Mode mode
public abstract String deprecatedBy
Copyright © 2002–2017 The Neo4j Graph Database Project. All rights reserved.