org.apache.tinkerpop.gremlin.server

## Class Context

- java.lang.Object
- - org.apache.tinkerpop.gremlin.server.Context

- Direct Known Subclasses:
    SessionTask

      public class Context
      extends Object

  The context of Gremlin Server within which a particular request is made.
  Author:
    Stephen Mallette (http://stephen.genoprime.com)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Context.RequestContentType` The type of the request as determined by the contents of `Tokens.ARGS_GREMLIN`.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Context(RequestMessage requestMessage, ChannelHandlerContext ctx, Settings settings, GraphManager graphManager, GremlinExecutor gremlinExecutor, ScheduledExecutorService scheduledExecutorService)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `flush()` Flushes messages to the underlying transport.
    `ChannelHandlerContext` | `getChannelHandlerContext()` Gets the Netty context.
    `GraphManager` | `getGraphManager()` Gets the set of `Graph` objects configured in Gremlin Server.
    `Object` | `getGremlinArgument()`
    `GremlinExecutor` | `getGremlinExecutor()` Gets the executor chosen to evaluate incoming Gremlin scripts based on the request.
    `Context.RequestContentType` | `getRequestContentType()`
    `RequestMessage` | `getRequestMessage()` Gets the current request to Gremlin Server.
    `long` | `getRequestTimeout()` The timeout for the request.
    `ScheduledExecutorService` | `getScheduledExecutorService()`
    `Settings` | `getSettings()` Gets the current configuration of Gremlin Server.
    `boolean` | `isFinalResponseWritten()`
    `void` | `write(ResponseMessage message)`
    `void` | `write(ResponseStatusCode code, Object responseMessage)`
    `void` | `writeAndFlush(ResponseMessage message)` Writes a response message to the underlying channel while ensuring that at most one `final` response is written.
    `void` | `writeAndFlush(ResponseStatusCode code, Object responseMessage)` Writes a response message to the underlying channel while ensuring that at most one `final` response is written.

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

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

- - ### Constructor Detail

    - #### Context

          public Context(RequestMessage requestMessage,
                         ChannelHandlerContext ctx,
                         Settings settings,
                         GraphManager graphManager,
                         GremlinExecutor gremlinExecutor,
                         ScheduledExecutorService scheduledExecutorService)

  - ### Method Detail

    - #### getRequestTimeout

          public long getRequestTimeout()

      The timeout for the request. If the request is a script it examines the script for a timeout setting using `with()`. If that is not found then it examines the request itself to see if the timeout is provided by `Tokens.ARGS_EVAL_TIMEOUT`. If that is not provided then the `Settings.evaluationTimeout` is utilized as the default.

    - #### isFinalResponseWritten

          public boolean isFinalResponseWritten()

    - #### getRequestContentType

          public Context.RequestContentType getRequestContentType()

    - #### getGremlinArgument

          public Object getGremlinArgument()

    - #### getScheduledExecutorService

          public ScheduledExecutorService getScheduledExecutorService()

    - #### getRequestMessage

          public RequestMessage getRequestMessage()

      Gets the current request to Gremlin Server.

    - #### getChannelHandlerContext

          public ChannelHandlerContext getChannelHandlerContext()

      Gets the Netty context.

    - #### getSettings

          public Settings getSettings()

      Gets the current configuration of Gremlin Server.

    - #### getGraphManager

          public GraphManager getGraphManager()

      Gets the set of `Graph` objects configured in Gremlin Server.

    - #### getGremlinExecutor

          public GremlinExecutor getGremlinExecutor()

      Gets the executor chosen to evaluate incoming Gremlin scripts based on the request.

    - #### writeAndFlush

          public void writeAndFlush(ResponseMessage message)

      Writes a response message to the underlying channel while ensuring that at most one `final` response is written.

      Note: this method should be used instead of writing to the channel directly when multiple threads are expected to produce response messages concurrently.

      Attempts to write more than one final response message will be ignored.

      See Also:
        `writeAndFlush(ResponseStatusCode, Object)`

    - #### writeAndFlush

          public void writeAndFlush(ResponseStatusCode code,
                                    Object responseMessage)

      Writes a response message to the underlying channel while ensuring that at most one `final` response is written.

      The caller must make sure that the provided response status code matches the content of the message.

      Note: this method should be used instead of writing to the channel directly when multiple threads are expected to produce response messages concurrently.

      Attempts to write more than one final response message will be ignored.

      See Also:
        `writeAndFlush(ResponseMessage)`

    - #### write

          public void write(ResponseMessage message)

    - #### write

          public void write(ResponseStatusCode code,
                            Object responseMessage)

    - #### flush

          public void flush()

      Flushes messages to the underlying transport.

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