org.neo4j.remote
Class RemoteGraphDatabase

java.lang.Object
  extended by org.neo4j.remote.RemoteGraphDatabase
All Implemented Interfaces:
GraphDatabaseService

public final class RemoteGraphDatabase
extends Object
implements GraphDatabaseService

A remote connection to a running Graph Database instance, providing access to the Neo4j Graph Database API.

Author:
Tobias Ivarsson

Constructor Summary
RemoteGraphDatabase(ConfigurationModule config, ConnectionTarget site)
          Creates a new remote graph database connection.
RemoteGraphDatabase(ConfigurationModule config, ConnectionTarget site, String username, String password)
          Creates a new remote graph database connection.
RemoteGraphDatabase(ConfigurationModule config, String resourceUri)
          Create a remote graph database connection.
RemoteGraphDatabase(ConfigurationModule config, String resourceUri, String username, String password)
          Create a remote graph database connection.
RemoteGraphDatabase(ConnectionTarget site)
          Creates a new remote graph database connection.
RemoteGraphDatabase(ConnectionTarget site, String username, String password)
          Creates a new remote graph database connection.
RemoteGraphDatabase(String resourceUri)
          Create a remote graph database connection.
RemoteGraphDatabase(String resourceUri, String username, String password)
          Create a remote graph database connection.
 
Method Summary
 Transaction beginTx()
          Starts a new transaction and associates it with the current thread.
 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.
 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.
static void registerProtocol(Transport factory)
          Register a ConnectionTarget implementation with a specified protocol.
 void shutdown()
          Shuts down Neo4j.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteGraphDatabase

public RemoteGraphDatabase(ConnectionTarget site)
Creates a new remote graph database connection.

Parameters:
site - The connection layer to be used.

RemoteGraphDatabase

public RemoteGraphDatabase(ConfigurationModule config,
                           ConnectionTarget site)
Creates a new remote graph database connection.

Parameters:
config - the ConfigurationModule containing the configurations of the subsystems of the graph database.
site - The connection layer to be used.

RemoteGraphDatabase

public RemoteGraphDatabase(ConnectionTarget site,
                           String username,
                           String password)
Creates a new remote graph database connection.

Parameters:
site - The connection layer to be used.
username - the name of the user to log in as on the remote site. ( null means anonymous)
password - the password for the user to log in as on the remote site.

RemoteGraphDatabase

public RemoteGraphDatabase(ConfigurationModule config,
                           ConnectionTarget site,
                           String username,
                           String password)
Creates a new remote graph database connection.

Parameters:
config - the ConfigurationModule containing the configurations of the subsystems of the graph database.
site - The connection layer to be used.
username - the name of the user to log in as on the remote site. ( null means anonymous)
password - the password for the user to log in as on the remote site.

RemoteGraphDatabase

public RemoteGraphDatabase(String resourceUri)
                    throws URISyntaxException
Create a remote graph database connection. Select implementation depending on the supplied URI.

Parameters:
resourceUri - the URI where the connection resource is located.
Throws:
URISyntaxException - if the resource URI is malformed.

RemoteGraphDatabase

public RemoteGraphDatabase(ConfigurationModule config,
                           String resourceUri)
                    throws URISyntaxException
Create a remote graph database connection. Select implementation depending on the supplied URI.

Parameters:
config - the ConfigurationModule containing the configurations of the subsystems of the graph database.
resourceUri - the URI where the connection resource is located.
Throws:
URISyntaxException - if the resource URI is malformed.

RemoteGraphDatabase

public RemoteGraphDatabase(String resourceUri,
                           String username,
                           String password)
                    throws URISyntaxException
Create a remote graph database connection. Select implementation depending on the supplied URI.

Parameters:
resourceUri - the URI where the connection resource is located.
username - the name of the user to log in as on the remote site. ( null means anonymous)
password - the password for the user to log in as on the remote site.
Throws:
URISyntaxException - if the resource URI is malformed.

RemoteGraphDatabase

public RemoteGraphDatabase(ConfigurationModule config,
                           String resourceUri,
                           String username,
                           String password)
                    throws URISyntaxException
Create a remote graph database connection. Select implementation depending on the supplied URI.

Parameters:
config - the ConfigurationModule containing the configurations of the subsystems of the graph database.
resourceUri - the URI where the connection resource is located.
username - the name of the user to log in as on the remote site. ( null means anonymous)
password - the password for the user to log in as on the remote site.
Throws:
URISyntaxException - if the resource URI is malformed.
Method Detail

registerProtocol

public static void registerProtocol(Transport factory)
Register a ConnectionTarget implementation with a specified protocol.

Parameters:
factory - a factory to create the site once it's required.

beginTx

public Transaction beginTx()
Description copied from interface: GraphDatabaseService
Starts a new transaction and associates it with the current thread.

Specified by:
beginTx in interface GraphDatabaseService
Returns:
a new transaction instance

createNode

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

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

getNodeById

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

Specified by:
getNodeById in interface GraphDatabaseService
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: GraphDatabaseService
Looks up a relationship by id.

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

getReferenceNode

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

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

getRelationshipTypes

public Iterable<RelationshipType> getRelationshipTypes()
Description copied from interface: GraphDatabaseService
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 GraphDatabaseService
Returns:
all relationship types in the underlying store

getAllNodes

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

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

shutdown

public void shutdown()
Description copied from interface: GraphDatabaseService
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.

Specified by:
shutdown in interface GraphDatabaseService

enableRemoteShell

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

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


Copyright © 2010 Neo4j. All Rights Reserved.