Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.neo4j.graphdb
Interface GraphDatabaseService

All Known Implementing Classes:
  EmbeddedGraphDatabase, EmbeddedReadOnlyGraphDatabase, RemoteGraphDatabase

    public interface GraphDatabaseService

The main access point to a running Neo4j instance. The most common implementation is the `EmbeddedGraphDatabase` class, which is used to embed Neo4j in an application. Typically, you would create an `EmbeddedGraphDatabase` instance as follows:

     GraphDatabaseService graphDb = new EmbeddedGraphDatabase( "var/graphDb" );
     // ... use Neo4j
     graphDb.shutdown();

GraphDatabaseService provides operations to `enable the shell`, `create nodes`, `get nodes given an id`, get the `reference node` and ultimately `shutdown Neo4j`.

Please note that all operations that write to the graph must be invoked in a `transactional context`. Failure to do so will result in a `NotInTransactionException` being thrown.

Method Summary
`Transaction` | `beginTx()` Starts a new transaction and associates it with the current thread.
`Node` | `createNode()` Creates a new node.
`boolean` | `enableRemoteShell()` Deprecated. in favor of a configuration parameter 'enable_remote_shell' Simply put:
     enable_remote_shell = true
In your configuration and it will be started with default port and RMI name. If you'd like to control the port and RMI name of the shell instead put:
     enable_remote_shell = port=1337,name=shell
`boolean` | `enableRemoteShell(Map<String,Serializable> initialProperties)` Deprecated. in favor of a configuration parameter 'enable_remote_shell' Put:
     enable_remote_shell = port=1337,name=shell
In your configuration and it will be started with the supplied port and RMI name. If you instead would like to use default parameters, put:
     enable_remote_shell = true
`Iterable<Node>` | `getAllNodes()` Returns all nodes in the node space.
`Node` | `getNodeById(long id)` Looks up a node by id.
`Node` | `getReferenceNode()` Returns the reference node, which is a "starting point" in the node space.
`Relationship` | `getRelationshipById(long id)` Looks up a relationship by id.
`Iterable<RelationshipType>` | `getRelationshipTypes()` Returns all relationship types currently in the underlying store.
`KernelEventHandler` | `registerKernelEventHandler(KernelEventHandler handler)` Registers `handler` as a handler for kernel events which are generated from different places in the lifecycle of the kernel.
`
`<T> TransactionEventHandler<T>`
` | `registerTransactionEventHandler(TransactionEventHandler<T> handler)` Registers `handler` as a handler for transaction events which are generated from different places in the lifecycle of each transaction.
`void` | `shutdown()` Shuts down Neo4j.
`KernelEventHandler` | `unregisterKernelEventHandler(KernelEventHandler handler)` Unregisters `handler` from the list of kernel event handlers.
`
`<T> TransactionEventHandler<T>`
` | `unregisterTransactionEventHandler(TransactionEventHandler<T> handler)` Unregisters `handler` from the list of transaction event handlers.

Method Detail

### createNode

    Node createNode()

  Creates a new node.

  Returns:
    the created node.

### getNodeById

    Node getNodeById(long id)

  Looks up a node by id.

  Parameters:
    `id` - the id of the node
  Returns:
    the node with id `id` if found
  Throws:
    `NotFoundException` - if not found

### getRelationshipById

    Relationship getRelationshipById(long id)

  Looks up a relationship by id.

  Parameters:
    `id` - the id of the relationship
  Returns:
    the relationship with id `id` if found
  Throws:
    `NotFoundException` - if not found

### getReferenceNode

    Node getReferenceNode()

  Returns the reference node, which is a "starting point" in the node space. Usually, a client attaches relationships to this node that leads into various parts of the node space. For more information about common node space organizational patterns, see the design guide at wiki.neo4j.org/content/Design_Guide.

  Returns:
    the reference node
  Throws:
    `NotFoundException` - if unable to get the reference node

### getAllNodes

    Iterable<Node> getAllNodes()

  Returns all nodes in the node space.

  Returns:
    all nodes in the node space

### getRelationshipTypes

    Iterable<RelationshipType> getRelationshipTypes()

  Returns all relationship types currently in the underlying store. Relationship types are added to the underlying store the first time they are used in a successfully commited `node.createRelationshipTo(...)`. Note that this method is guaranteed to return all known relationship types, but it does not guarantee that it won't return more than that (e.g. it can return "historic" relationship types that no longer have any relationships in the node space).

  Returns:
    all relationship types in the underlying store

### shutdown

    void shutdown()

  Shuts down Neo4j. After this method has been invoked, it's invalid to invoke any methods in the Neo4j API and all references to this instance of GraphDatabaseService should be discarded.

### enableRemoteShell

    @Deprecated
    boolean enableRemoteShell()

  Deprecated. in favor of a configuration parameter 'enable_remote_shell' Simply put:

       enable_remote_shell = true

  In your configuration and it will be started with default port and RMI name. If you'd like to control the port and RMI name of the shell instead put:

       enable_remote_shell = port=1337,name=shell

  Enables remote shell access (with default configuration) to this Neo4j instance, if the Neo4j shell component is available on the classpath. This method is identical to invoking `enableRemoteShell( null )`.

  Returns:
    `true` if the shell has been enabled, `false` otherwise (`false` usually indicates that the `shell` jar dependency is not on the classpath)

### enableRemoteShell

    @Deprecated
    boolean enableRemoteShell(Map<String,Serializable> initialProperties)

  Deprecated. in favor of a configuration parameter 'enable_remote_shell' Put:

       enable_remote_shell = port=1337,name=shell

  In your configuration and it will be started with the supplied port and RMI name. If you instead would like to use default parameters, put:

       enable_remote_shell = true

  Enables remote shell access to this Neo4j instance, if the Neo4j Shell component is available on the classpath. This will publish a shell access interface on an RMI registry on localhost (with configurable port and RMI binding name). It can be accessed by a client that implements `org.neo4j.shell.ShellClient` from the Neo4j Shell project. Typically, the `neo4j-shell` binary package is used (see neo4j.org/download).

  The shell is parameterized by a map of properties passed in to this method. Currently, two properties are used:

  - `port`, an `Integer` describing the port of the RMI registry where the Neo4j shell will be bound, defaults to `1337`
  - `name`, the `String` under which the Neo4j shell will be bound in the RMI registry, defaults to `shell`

  Parameters:
    `initialProperties` - a set of properties that will be used to configure the remote shell, or `null` if the default properties should be used
  Returns:
    `true` if the shell has been enabled, `false` otherwise (`false` usually indicates that the `shell` jar dependency is not on the classpath)
  Throws:
    `ClassCastException` - if the shell library is available, but one (or more) of the configuration properties have an unexpected type
    `IllegalStateException` - if the shell library is available, but the remote shell can't be enabled anyway

### beginTx

    Transaction beginTx()

  Starts a new transaction and associates it with the current thread.

  Returns:
    a new transaction instance

### registerTransactionEventHandler

    <T> TransactionEventHandler<T> registerTransactionEventHandler(TransactionEventHandler<T> handler)

  Registers `handler` as a handler for transaction events which are generated from different places in the lifecycle of each transaction. To guarantee that the handler gets all events properly it shouldn't be registered when the application is running (i.e. in the middle of one or more transactions). If the specified handler instance has already been registered this method will do nothing.

  Type Parameters:
    `T` - the type of state object used in the handler, see more documentation about it at `TransactionEventHandler`.
  Parameters:
    `handler` - the handler to receive events about different states in transaction lifecycles.
  Returns:
    the handler passed in as the argument.

### unregisterTransactionEventHandler

    <T> TransactionEventHandler<T> unregisterTransactionEventHandler(TransactionEventHandler<T> handler)

  Unregisters `handler` from the list of transaction event handlers. If `handler` hasn't been registered with `registerTransactionEventHandler(TransactionEventHandler)` prior to calling this method an `IllegalStateException` will be thrown. After a successful call to this method the `handler` will no longer receive any transaction events.

  Type Parameters:
    `T` - the type of state object used in the handler, see more documentation about it at `TransactionEventHandler`.
  Parameters:
    `handler` - the handler to receive events about different states in transaction lifecycles.
  Returns:
    the handler passed in as the argument.
  Throws:
    `IllegalStateException` - if `handler` wasn't registered prior to calling this method.

### registerKernelEventHandler

    KernelEventHandler registerKernelEventHandler(KernelEventHandler handler)

  Registers `handler` as a handler for kernel events which are generated from different places in the lifecycle of the kernel. To guarantee proper behaviour the handler should be registered right after the graph database has been started. If the specified handler instance has already been registered this method will do nothing.

  Parameters:
    `handler` - the handler to receive events about different states in the kernel lifecycle.
  Returns:
    the handler passed in as the argument.

### unregisterKernelEventHandler

    KernelEventHandler unregisterKernelEventHandler(KernelEventHandler handler)

  Unregisters `handler` from the list of kernel event handlers. If `handler` hasn't been registered with `registerKernelEventHandler(KernelEventHandler)` prior to calling this method an `IllegalStateException` will be thrown. After a successful call to this method the `handler` will no longer receive any kernel events.

  Parameters:
    `handler` - the handler to receive events about different states in the kernel lifecycle.
  Returns:
    the handler passed in as the argument.
  Throws:
    `IllegalStateException` - if `handler` wasn't registered prior to calling this method.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 Neo4j. All Rights Reserved.