Interface BaseExecutionContext

All Known Subinterfaces:
BaseMessageExecutionContext, ExecutionContext, GenericExecutionContext, HttpBaseExecutionContext, HttpExecutionContext, HttpExecutionContext, HttpMessageExecutionContext, HttpPlainExecutionContext, KafkaConnectionContext, KafkaExecutionContext, KafkaMessageExecutionContext, MessageExecutionContext, NativeExecutionContext, NativeMessageExecutionContext, TcpExecutionContext, TcpExecutionContext

public interface BaseExecutionContext
Base interface any execution context interface can inherit from. It defines the common concepts of an execution context (attributes, internal attributes, template engine, ...).
Author:
Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com), GraviteeSource Team
  • Field Details

  • Method Details

    • getComponent

      <T> T getComponent(Class<T> componentClass)
    • setAttribute

      void setAttribute(String name, Object value)
      Parameters:
      name - a String specifying the name of the attribute.
      value - the Object to be stored.
    • putAttribute

      void putAttribute(String name, Object value)
      Stores an attribute in this request. Attributes are reset between requests. Note: prefer use of putInternalAttribute(String, Object) in case the attribute is not set by the user itself.
      Parameters:
      name - a String specifying the name of the attribute.
      value - the Object to be stored.
    • removeAttribute

      void removeAttribute(String name)
      Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled.
      Parameters:
      name - the name of the attribute to remove.
    • getAttribute

      <T> T getAttribute(String name)
      Returns the value of the attribute cast in the expected type T, or null if no attribute for the given name exists.
      Type Parameters:
      T - the expected type of the attribute value. Specify Object if you expect value of any type.
      Parameters:
      name - the name of the attribute.
      Returns:
      an Object containing the value of the attribute, or null if the attribute does not exist.
    • getAttributeAsList

      <T> List<T> getAttributeAsList(String name)
      Return the attribute as an immutable List. This method acts differently depending on the type of the attribute's value. Elements of the List are mapped as follows:

      For String:

      • comma separated string are spitted and returned trimmed
      • Parsable JSON Array elements are returned as strings (including objects)
      • if none of the above, the string is simply wrapped

      For Collection:

      • Elements of the collection are wrapped in a new List

      For Array:

      • Each elements of the is wrapped into the returned List

      For any other cases: the value is simply wrapped into the returned List. Notes: One calling setAttribute(String, Object) with a mutable collection will retrieve an immutable one.

      Type Parameters:
      T - the expected type of the attribute value. Specify Object if you expect value of any type.
      Parameters:
      name - the name of the attribute.
      Returns:
      an immutable List with the attribute values.
    • getAttributeNames

      Set<String> getAttributeNames()
      Returns an Enumeration containing the names of the attributes available to this request. This method returns an empty Enumeration if the request has no attributes available to it.
      Returns:
      a set of strings containing the names of the request's attributes.
    • getAttributes

      <T> Map<String,T> getAttributes()
      Get all attributes available.
      Type Parameters:
      T - the expected type of the attribute values. Specify Object if you expect values of any types.
      Returns:
      the list of all the attributes.
    • setInternalAttribute

      void setInternalAttribute(String name, Object value)
      Parameters:
      name - the name of the attribute.
      value - the Object to be stored.
    • putInternalAttribute

      void putInternalAttribute(String name, Object value)
      Stores an internal attribute in this request. Attributes are reset between requests. Internal attributes can be used to avoid mixin with attributes set by the user during the request processing.
      Parameters:
      name - the name of the attribute.
      value - the Object to be stored.
    • removeInternalAttribute

      void removeInternalAttribute(String name)
      Removes an internal attribute from this request.
      Parameters:
      name - the name of the internal attribute to remove.
    • getInternalAttribute

      <T> T getInternalAttribute(String name)
      Returns the value of the internal attribute cast in the expected type T, or null if no attribute for the given name exists.
      Type Parameters:
      T - the expected type of the attribute value. Specify Object if you expect value of any type.
      Parameters:
      name - a String specifying the name of the attribute.
      Returns:
      an Object containing the value of the attribute, or null if the attribute does not exist
    • getInternalAttributes

      <T> Map<String,T> getInternalAttributes()
      Get all internal attributes available. Internal attributes are not intended to be manipulated by end-users. You can safely use internal attribute to temporary store useful objects required during different phases of the execution.
      Type Parameters:
      T - the expected type of the values. Specify Object if you expect values of any types.
      Returns:
      the list of all the internal attributes.
    • getTemplateEngine

      io.gravitee.el.TemplateEngine getTemplateEngine()
      Get the TemplateEngine that can be used to evaluate EL expressions.
      Returns:
      the El TemplateEngine.
    • getTracer

      Tracer getTracer()
      Get the Tracer that can be used to trace any spans.
      Returns:
      the Tracer contextualized.
    • timestamp

      long timestamp()
    • remoteAddress

      String remoteAddress()
      Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
      Returns:
      a String containing the IP address of the client that sent the request.
    • localAddress

      String localAddress()
      Returns the Internet Protocol (IP) address of the interface on which the request was received.
      Returns:
      a String containing the IP address on which the request was received.
    • tlsSession

      TlsSession tlsSession()
      Returns:
      TlsSession associated to the request. Acts as a SSLSession, with additional mechanisms. It can for example extract a client certificate from a given header.
      See Also:
    • warnWith

      void warnWith(ExecutionWarn warn)
      Adds a warning to the execution context without interrupting the flow. The warning will be stored and can be accessed later through metrics.