org.apache.tinkerpop.gremlin.server.util

## Class DefaultGraphManager

- java.lang.Object
- - org.apache.tinkerpop.gremlin.server.util.DefaultGraphManager

- All Implemented Interfaces:
    GraphManager

      public final class DefaultGraphManager
      extends Object
      implements GraphManager

  Holder for `Graph` and `TraversalSource` instances configured for the server to be passed to script engine bindings. The `Graph` instances are read from the `Settings` for Gremlin Server as defined in the configuration file. The `TraversalSource` instances are rebound to the `GraphManager` once initialization scripts construct them.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultGraphManager(Settings settings)` Create a new instance using the `Settings` from Gremlin Server.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `commit(Set<String> graphSourceNamesToCloseTxOn)` Selectively commit transactions on the specified graphs or the graphs of traversal sources.
    `void` | `commitAll()` Commit transactions across all `Graph` objects.
    `Bindings` | `getAsBindings()` Get the `Graph` and `TraversalSource` list as a set of bindings.
    `Graph` | `getGraph(String graphName)` Get `Graph` instance whose name matches `graphName`.
    `Set<String>` | `getGraphNames()` Get a `Set` of `String` graphNames corresponding to names stored in the graph's reference tracker.
    `TraversalSource` | `getTraversalSource(String traversalSourceName)` Get `TraversalSource` instance whose name matches `traversalSourceName`
    `Set<String>` | `getTraversalSourceNames()` Get a `Set` of the names of the the stored `TraversalSource` instances.
    `Graph` | `openGraph(String graphName, Function<String,Graph> supplier)` Implementation that allows for custom graph-opening implementations; if the `Map` tracking graph references has a `Graph` object corresponding to the graph name, then we return that `Graph`-- otherwise, we use the custom `Function` to instantiate a new `Graph`, add it to the `Map` tracking graph references, and return said `Graph`.
    `void` | `putGraph(String graphName, Graph g)` Add or update the specified `Graph` with the specified name to `Map<String, Graph>` .
    `void` | `putTraversalSource(String tsName, TraversalSource ts)` Add or update the specified `TraversalSource` with the specified name.
    `Graph` | `removeGraph(String graphName)` Implementation that allows for custom graph closing implementations; this method should remove the `Graph` from the `GraphManager`.
    `TraversalSource` | `removeTraversalSource(String tsName)` Remove `TraversalSource` by name.
    `void` | `rollback(Set<String> graphSourceNamesToCloseTxOn)` Selectively rollback transactions on the specified graphs or the graphs of traversal sources.
    `void` | `rollbackAll()` Rollback transactions across all `Graph` objects.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultGraphManager

          public DefaultGraphManager(Settings settings)

      Create a new instance using the `Settings` from Gremlin Server.

  - ### Method Detail

    - #### getGraphNames

          public final Set<String> getGraphNames()

      Description copied from interface: `GraphManager`
      Get a `Set` of `String` graphNames corresponding to names stored in the graph's reference tracker.
      Specified by:
        `getGraphNames` in interface `GraphManager`

    - #### getGraph

          public final Graph getGraph(String graphName)

      Description copied from interface: `GraphManager`
      Get `Graph` instance whose name matches `graphName`.
      Specified by:
        `getGraph` in interface `GraphManager`
      Returns:
        `Graph` if exists, else null

    - #### putGraph

          public final void putGraph(String graphName,
                                     Graph g)

      Description copied from interface: `GraphManager`
      Add or update the specified `Graph` with the specified name to `Map<String, Graph>` .
      Specified by:
        `putGraph` in interface `GraphManager`

    - #### getTraversalSourceNames

          public final Set<String> getTraversalSourceNames()

      Description copied from interface: `GraphManager`
      Get a `Set` of the names of the the stored `TraversalSource` instances.
      Specified by:
        `getTraversalSourceNames` in interface `GraphManager`

    - #### getTraversalSource

          public final TraversalSource getTraversalSource(String traversalSourceName)

      Description copied from interface: `GraphManager`
      Get `TraversalSource` instance whose name matches `traversalSourceName`
      Specified by:
        `getTraversalSource` in interface `GraphManager`
      Returns:
        `TraversalSource` if exists, else null

    - #### putTraversalSource

          public final void putTraversalSource(String tsName,
                                               TraversalSource ts)

      Description copied from interface: `GraphManager`
      Add or update the specified `TraversalSource` with the specified name.
      Specified by:
        `putTraversalSource` in interface `GraphManager`

    - #### removeTraversalSource

          public final TraversalSource removeTraversalSource(String tsName)

      Description copied from interface: `GraphManager`
      Remove `TraversalSource` by name.
      Specified by:
        `removeTraversalSource` in interface `GraphManager`

    - #### getAsBindings

          public final Bindings getAsBindings()

      Get the `Graph` and `TraversalSource` list as a set of bindings.
      Specified by:
        `getAsBindings` in interface `GraphManager`

    - #### rollbackAll

          public final void rollbackAll()

      Rollback transactions across all `Graph` objects.
      Specified by:
        `rollbackAll` in interface `GraphManager`

    - #### rollback

          public final void rollback(Set<String> graphSourceNamesToCloseTxOn)

      Selectively rollback transactions on the specified graphs or the graphs of traversal sources.
      Specified by:
        `rollback` in interface `GraphManager`

    - #### commitAll

          public final void commitAll()

      Commit transactions across all `Graph` objects.
      Specified by:
        `commitAll` in interface `GraphManager`

    - #### commit

          public final void commit(Set<String> graphSourceNamesToCloseTxOn)

      Selectively commit transactions on the specified graphs or the graphs of traversal sources.
      Specified by:
        `commit` in interface `GraphManager`

    - #### openGraph

          public final Graph openGraph(String graphName,
                                       Function<String,Graph> supplier)

      Implementation that allows for custom graph-opening implementations; if the `Map` tracking graph references has a `Graph` object corresponding to the graph name, then we return that `Graph`-- otherwise, we use the custom `Function` to instantiate a new `Graph`, add it to the `Map` tracking graph references, and return said `Graph`.
      Specified by:
        `openGraph` in interface `GraphManager`

    - #### removeGraph

          public final Graph removeGraph(String graphName)
                                  throws Exception

      Implementation that allows for custom graph closing implementations; this method should remove the `Graph` from the `GraphManager`.
      Specified by:
        `removeGraph` in interface `GraphManager`
      Throws:
        `Exception`

Copyright © 2013–2019 Apache Software Foundation. All rights reserved.