Class RequestContext

java.lang.Object
io.milton.context.Context
io.milton.context.RequestContext
All Implemented Interfaces:
Contextual, RemovalCallback

public class RequestContext extends Context implements RemovalCallback
  • Method Details

    • C

      public static <T> T C(Class<T> c) throws ClassNotInContextException
      For convenience, equivalent to RequestContext.getCurrent().get(c) This method assumes that the requested class is required and will throw an exception if it is not found
      Type Parameters:
      T - - the type expected to be returned
      Parameters:
      c - - the class to
      Returns:
      - an object of the given type
      Throws:
      ClassNotInContextException
    • C

      public static <T> T C(Class<T> c, boolean required) throws ClassNotInContextException
      For convenience, equivalent to RequestContext.getCurrent().get(c) Returns the object in context of the given type or null if not found and required is false.
      Type Parameters:
      T -
      Parameters:
      c -
      required - - if true will throw an exception if the requested class is not found. Otherwise will return null.
      Returns:
      - an object of the given type
      Throws:
      ClassNotInContextException
    • getCurrent

      public static RequestContext getCurrent()
    • getInstance

      public static RequestContext getInstance(RootContext parent)
    • peekInstance

      public static RequestContext peekInstance()
    • getRootContext

      public RootContext getRootContext()
    • getRegistration

      protected Registration getRegistration(Class c)
      Overrides:
      getRegistration in class Context
    • getRegistration

      protected Registration getRegistration(String id)
      Overrides:
      getRegistration in class Context
    • getOrCreateRegistration

      protected Registration getOrCreateRegistration(Class c, Context context)
    • onRemove

      public void onRemove(Object item)
      Called when this request context goes out of context. Should shutdown all of its contents
      Specified by:
      onRemove in interface RemovalCallback