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

## org.neo4j.kernel
Class EmbeddedGraphDatabase

    java.lang.Object
      org.neo4j.kernel.AbstractGraphDatabase
          org.neo4j.kernel.EmbeddedGraphDatabase

All Implemented Interfaces:
  GraphDatabaseService

    public final class EmbeddedGraphDatabase

extends AbstractGraphDatabase

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

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

For more information, see `GraphDatabaseService`.

Constructor Summary
`EmbeddedGraphDatabase(String storeDir)` Creates an embedded `GraphDatabaseService` with a store located in `storeDir`, which will be created if it doesn't already exist.
`EmbeddedGraphDatabase(String storeDir, Map<String,String> params)` A non-standard way of creating an embedded `GraphDatabaseService` with a set of configuration parameters.

Method Summary
`Transaction` | `beginTx()` Starts a new transaction and associates it with the current thread.
`Node` | `createNode()` Creates a new node.
`Iterable<Node>` | `getAllNodes()` Returns all nodes in the node space.
`Config` | `getConfig()` Returns a non-standard configuration object.
`
`<T> Collection<T>`
` | `getManagementBeans(Class<T> type)`
`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()`
`IndexManager` | `index()` Returns the `IndexManager` paired with this graph database service and is the entry point for managing indexes coupled with this database.
`boolean` | `isReadOnly()`
`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`.
`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.

Methods inherited from class org.neo4j.kernel.AbstractGraphDatabase
`getManagementBean, getSingleManagementBean, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### EmbeddedGraphDatabase

    public EmbeddedGraphDatabase(String storeDir)

  Creates an embedded `GraphDatabaseService` with a store located in `storeDir`, which will be created if it doesn't already exist.

  Parameters:
    `storeDir` - the store directory for the Neo4j store files

### EmbeddedGraphDatabase

    public EmbeddedGraphDatabase(String storeDir,
                                 Map<String,String> params)

  A non-standard way of creating an embedded `GraphDatabaseService` with a set of configuration parameters. Will most likely be removed in future releases.

  Creates an embedded `GraphDatabaseService` with a store located in `storeDir`, which will be created if it doesn't already exist.

  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: `GraphDatabaseService`
  Creates a new node.

  Returns:
    the created node.

### getNodeById

    public Node getNodeById(long id)

  Description copied from interface: `GraphDatabaseService`
  Looks up a node by id.

  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.

  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.

  Returns:
    the reference node

### 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.

### 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).

  Returns:
    all relationship types in the underlying store

### beginTx

    public Transaction beginTx()

  Description copied from interface: `GraphDatabaseService`
  Starts a new transaction and associates it with the current thread.

  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.

  Specified by:
    `getConfig` in class `AbstractGraphDatabase`
  Returns:
    a configuration object

### getManagementBeans

    public <T> Collection<T> getManagementBeans(Class<T> type)

  Specified by:
    `getManagementBeans` in class `AbstractGraphDatabase`

### isReadOnly

    public boolean isReadOnly()

  Specified by:
    `isReadOnly` in class `AbstractGraphDatabase`

### getStoreDir

    public String getStoreDir()

  Specified by:
    `getStoreDir` in class `AbstractGraphDatabase`

### getAllNodes

    public Iterable<Node> getAllNodes()

  Description copied from interface: `GraphDatabaseService`
  Returns all nodes in the node space.

  Returns:
    all nodes in the node space

### registerKernelEventHandler

    public KernelEventHandler registerKernelEventHandler(KernelEventHandler handler)

  Description copied from interface: `GraphDatabaseService`
  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.

### registerTransactionEventHandler

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

  Description copied from interface: `GraphDatabaseService`
  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.

### unregisterKernelEventHandler

    public KernelEventHandler unregisterKernelEventHandler(KernelEventHandler handler)

  Description copied from interface: `GraphDatabaseService`
  Unregisters `handler` from the list of kernel event handlers. If `handler` hasn't been registered with `GraphDatabaseService.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.

### unregisterTransactionEventHandler

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

  Description copied from interface: `GraphDatabaseService`
  Unregisters `handler` from the list of transaction event handlers. If `handler` hasn't been registered with `GraphDatabaseService.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.

### index

    public IndexManager index()

  Description copied from interface: `GraphDatabaseService`
  Returns the `IndexManager` paired with this graph database service and is the entry point for managing indexes coupled with this database.

  Returns:
    the `IndexManager` for this database.

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

Copyright © 2011 The Neo4j Graph Database Project. All Rights Reserved.