Class SessionContext

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<String,Object>
com.netflix.zuul.context.SessionContext
All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public final class SessionContext extends HashMap<String,Object> implements Cloneable
Represents the context between client and origin server for the duration of the dedicated connection/session between them. But we're currently still only modelling single request/response pair per session. NOTE: Not threadsafe, and not intended to be used concurrently. User: Mike Smith Date: 4/28/15 Time: 6:45 PM
See Also:
  • Constructor Details

    • SessionContext

      public SessionContext()
  • Method Details

    • newKey

      public static <T> SessionContext.Key<T> newKey(String name)
    • get

      public Object get(Object key)

      This method exists for static analysis.

      Specified by:
      get in interface Map<String,Object>
      Overrides:
      get in class HashMap<String,Object>
    • get

      @Nullable public <T> T get(SessionContext.Key<T> key)
      Returns the value in the context, or null if absent.
    • getOrDefault

      public <T> T getOrDefault(SessionContext.Key<T> key, T defaultValue)
      Returns the value in the context, or defaultValue if absent.
    • put

      public Object put(String key, Object value)

      This method exists for static analysis.

      Specified by:
      put in interface Map<String,Object>
      Overrides:
      put in class HashMap<String,Object>
    • put

      @Nullable @CanIgnoreReturnValue public <T> T put(SessionContext.Key<T> key, T value)
      Returns the previous value associated with key, or null if there was no mapping for key. Unlike put(String, Object), this will never return a null value if the key is present in the map.
    • remove

      public boolean remove(Object key, Object value)

      This method exists for static analysis.

      Specified by:
      remove in interface Map<String,Object>
      Overrides:
      remove in class HashMap<String,Object>
    • remove

      public <T> boolean remove(SessionContext.Key<T> key, T value)
    • remove

      public Object remove(Object key)

      This method exists for static analysis.

      Specified by:
      remove in interface Map<String,Object>
      Overrides:
      remove in class HashMap<String,Object>
    • remove

      public <T> T remove(SessionContext.Key<T> key)
    • keys

      public Set<SessionContext.Key<?>> keys()
    • clone

      public SessionContext clone()
      Makes a copy of the RequestContext. This is used for debugging.
      Overrides:
      clone in class HashMap<String,Object>
    • getString

      public String getString(String key)
    • getBoolean

      public boolean getBoolean(String key)
      Convenience method to return a boolean value for a given key
      Returns:
      true or false depending what was set. default is false
    • getBoolean

      public boolean getBoolean(String key, boolean defaultResponse)
      Convenience method to return a boolean value for a given key
      Returns:
      true or false depending what was set. default defaultResponse
    • set

      public void set(String key)
      sets a key value to Boolean.TRUE
    • set

      public void set(String key, Object value)
      puts the key, value into the map. a null value will remove the key from the map
    • getUUID

      public String getUUID()
    • setUUID

      public void setUUID(String uuid)
    • setStaticResponse

      public void setStaticResponse(HttpResponseMessage response)
    • getStaticResponse

      public HttpResponseMessage getStaticResponse()
    • getError

      public Throwable getError()
      Gets the throwable that will be use in the Error endpoint.
    • setError

      public void setError(Throwable th)
      Sets throwable to use for generating a response in the Error endpoint.
    • getErrorEndpoint

      public String getErrorEndpoint()
    • setErrorEndpoint

      public void setErrorEndpoint(String name)
    • setDebugRouting

      public void setDebugRouting(boolean bDebug)
      sets debugRouting
    • debugRouting

      public boolean debugRouting()
      Returns:
      "debugRouting"
    • setDebugRequestHeadersOnly

      public void setDebugRequestHeadersOnly(boolean bHeadersOnly)
      sets "debugRequestHeadersOnly" to bHeadersOnly
    • debugRequestHeadersOnly

      public boolean debugRequestHeadersOnly()
      Returns:
      "debugRequestHeadersOnly"
    • setDebugRequest

      public void setDebugRequest(boolean bDebug)
      sets "debugRequest"
    • debugRequest

      public boolean debugRequest()
      gets debugRequest
      Returns:
      debugRequest
    • removeRouteHost

      public void removeRouteHost()
      removes "routeHost" key
    • setRouteHost

      public void setRouteHost(URL routeHost)
      sets routeHost
      Parameters:
      routeHost - a URL
    • getRouteHost

      public URL getRouteHost()
      Returns:
      "routeHost" URL
    • addFilterExecutionSummary

      public void addFilterExecutionSummary(String name, String status, long time)
      appends filter name and status to the filter execution history for the current request
    • getFilterExecutionSummary

      public StringBuilder getFilterExecutionSummary()
      Returns:
      String that represents the filter execution history for the current request
    • shouldSendErrorResponse

      public boolean shouldSendErrorResponse()
    • setShouldSendErrorResponse

      public void setShouldSendErrorResponse(boolean should)
      Set this to true to indicate that the Error endpoint should be applied after the end of the current filter processing phase.
    • errorResponseSent

      public boolean errorResponseSent()
    • setErrorResponseSent

      public void setErrorResponseSent(boolean should)
    • isInBrownoutMode

      public boolean isInBrownoutMode()
      This can be used by filters for flagging if the server is getting overloaded, and then choose to disable/sample/rate-limit some optional features.
    • setInBrownoutMode

      public void setInBrownoutMode()
    • stopFilterProcessing

      public void stopFilterProcessing()
      This is typically set by a filter when wanting to reject a request, and also reduce load on the server by not processing any subsequent filters for this request.
    • shouldStopFilterProcessing

      public boolean shouldStopFilterProcessing()
    • getRouteVIP

      public String getRouteVIP()
      returns the routeVIP; that is the Eureka "vip" of registered instances
    • setRouteVIP

      public void setRouteVIP(String sVip)
      sets routeVIP; that is the Eureka "vip" of registered instances
    • setEndpoint

      public void setEndpoint(String endpoint)
    • getEndpoint

      public String getEndpoint()
    • setEventProperty

      public void setEventProperty(String key, Object value)
    • getEventProperties

      public Map<String,Object> getEventProperties()
    • getFilterErrors

      public List<FilterError> getFilterErrors()
    • setOriginReportedDuration

      public void setOriginReportedDuration(int duration)
    • getOriginReportedDuration

      public int getOriginReportedDuration()
    • isCancelled

      public boolean isCancelled()
    • cancel

      public void cancel()