org.neo4j.api.core
Class EmbeddedNeo

java.lang.Object
  extended by org.neo4j.api.core.EmbeddedNeo
All Implemented Interfaces:
NeoService

public final class EmbeddedNeo
extends Object
implements NeoService

An implementation of NeoService that is used to embed Neo in an application. You typically instantiate it by invoking the single argument constructor that takes a path to a directory where Neo will store its data files, as such:

 NeoService neo = new EmbeddedNeo( "var/neo" );
 // ... use neo
 neo.shutdown();
 
For more information, see NeoService.


Constructor Summary
EmbeddedNeo(String storeDir)
          Creates an embedded NeoService with a store located in storeDir, which will be created if it doesn't already exist.
EmbeddedNeo(String storeDir, Map<String,String> params)
          A non-standard way of creating an embedded NeoService with a set of configuration parameters.
 
Method Summary
 Transaction beginTx()
          Starts a new transaction.
 Node createNode()
          Creates a new node.
 boolean enableRemoteShell()
          Enables remote shell access (with default configuration) to this Neo4j instance, if the Neo4j shell component is available on the classpath.
 boolean enableRemoteShell(Map<String,Serializable> initialProperties)
          Enables remote shell access to this Neo4j instance, if the Neo4j shell component is available on the classpath.
 Iterable<Node> getAllNodes()
          Returns all nodes in the node space.
 Config getConfig()
          Returns a non-standard configuration object.
 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.
 String getStoreDir()
           
static Map<String,String> loadConfigurations(String file)
          A non-standard Convenience method that loads a standard property file and converts it into a generic Map.
 void shutdown()
          Shuts down Neo4j.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EmbeddedNeo

public EmbeddedNeo(String storeDir)
Creates an embedded NeoService with a store located in storeDir, which will be created if it doesn't already exist.

Parameters:
storeDir - the store directory for the neo db files

EmbeddedNeo

public EmbeddedNeo(String storeDir,
                   Map<String,String> params)
A non-standard way of creating an embedded NeoService with a set of configuration parameters. Will most likely be removed in future releases.

Parameters:
storeDir - the store directory for the db files
params - configuration parameters
Method Detail

loadConfigurations

public static Map<String,String> loadConfigurations(String file)
A non-standard Convenience method that loads a standard property file and converts it into a generic Map. Will most likely be removed in future releases.

Parameters:
file - the property file to load
Returns:
a map containing the properties from the file
Throws:
IllegalArgumentException - if file does not exist

createNode

public Node createNode()
Description copied from interface: NeoService
Creates a new node.

Specified by:
createNode in interface NeoService
Returns:
the created node.

getNodeById

public Node getNodeById(long id)
Description copied from interface: NeoService
Looks up a node by id.

Specified by:
getNodeById in interface NeoService
Parameters:
id - the id of the node
Returns:
the node with id id if found

getRelationshipById

public Relationship getRelationshipById(long id)
Description copied from interface: NeoService
Looks up a relationship by id.

Specified by:
getRelationshipById in interface NeoService
Parameters:
id - the id of the relationship
Returns:
the relationship with id id if found

getReferenceNode

public Node getReferenceNode()
Description copied from interface: NeoService
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.

Specified by:
getReferenceNode in interface NeoService
Returns:
the reference node

shutdown

public void shutdown()
Description copied from interface: NeoService
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 NeoService should be discarded.

Specified by:
shutdown in interface NeoService

enableRemoteShell

public boolean enableRemoteShell()
Description copied from interface: NeoService
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 ).

Specified by:
enableRemoteShell in interface NeoService
Returns:
true if the shell has been enabled, false otherwise (false usually indicates that the shell jar dependency is not on the classpath)

enableRemoteShell

public boolean enableRemoteShell(Map<String,Serializable> initialProperties)
Description copied from interface: NeoService
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.util.shell.ShellClient from the Neo4J shell project. Typically, the 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:

Specified by:
enableRemoteShell in interface NeoService
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)

getRelationshipTypes

public Iterable<RelationshipType> getRelationshipTypes()
Description copied from interface: NeoService
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).

Specified by:
getRelationshipTypes in interface NeoService
Returns:
all relationship types in the underlying store

beginTx

public Transaction beginTx()
Description copied from interface: NeoService
Starts a new transaction.

Specified by:
beginTx in interface NeoService
Returns:
a new transaction instance
Throws:
TransactionFailureException - if unable to start transaction

getConfig

public Config getConfig()
Returns a non-standard configuration object. Will most likely be removed in future releases.

Returns:
a configuration object

toString

public String toString()
Overrides:
toString in class Object

getStoreDir

public String getStoreDir()

getAllNodes

public Iterable<Node> getAllNodes()
Description copied from interface: NeoService
Returns all nodes in the node space.

Specified by:
getAllNodes in interface NeoService
Returns:
all nodes in the node space


Copyright © 2009 Neo4j. All Rights Reserved.