org.neo4j.api.core
Interface NeoService

All Known Implementing Classes:
EmbeddedNeo

public interface NeoService

The main access point to a running Neo instance. The only current implementation is the EmbeddedNeo class, which is used to embed Neo in an application. Typically, you would create an EmbeddedNeo instance as follows:

NeoService neo = new EmbeddedNeo( "var/neo" );
 // ... use neo
 neo.shutdown();
NeoService provides operations to enable the shell, create nodes, get nodes given an id, get the reference node and ultimately shutdown Neo.

Please note that all operations that read or write to the node space must be invoked in a transactional context.


Method Summary
 Node createNode()
          Creates a new node.
 boolean enableRemoteShell()
          Enables remote shell access (with default configuration) to this Neo instance, if the Neo4j shell component is available on the classpath.
 boolean enableRemoteShell(Map<String,Serializable> initialProperties)
          Enables remote shell access to this Neo instance, if the Neo4j shell component is available on the classpath.
 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.
 void shutdown()
          Shuts down Neo.
 

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:
RuntimeException - 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 http://neo4j.org/doc.

Returns:
the reference node
Throws:
RuntimeException - if unable to get the reference node

shutdown

void shutdown()
Shuts down Neo. After this method has been invoked, it's invalid to invoke any methods in the Neo API and all references to this instance of NeoService should be discarded.


enableRemoteShell

boolean enableRemoteShell()
Enables remote shell access (with default configuration) to this Neo 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

boolean enableRemoteShell(Map<String,Serializable> initialProperties)
Enables remote shell access to this Neo 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.util.shell.ShellClient from the Neo4J shell project. Typically, the neoshell 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:

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


Copyright © 2007 Neo4j. All Rights Reserved.