Class ServletActionContext

All Implemented Interfaces:
Map<String,Object>, org.apache.commons.chain.Context, ActionContext

public class ServletActionContext extends WebActionContext
Implement ActionContext interface while making Servlet API-specific values available.
  • Constructor Details

    • ServletActionContext

      public ServletActionContext(org.apache.commons.chain.web.jakarta.servlet.ServletWebContext context)
      Instantiate this composite by wrapping a ServletWebContext.
      Parameters:
      context - The ServletWebContext to wrap
    • ServletActionContext

      public ServletActionContext(ServletContext context, HttpServletRequest request, HttpServletResponse response)
      Instantiate this Context for a given ServletContext, HttpServletRequest, and HttpServletResponse.
      Parameters:
      context - The instant ServletContext
      request - The instant HttpServletRequest
      response - The instant HttpServletResponse
  • Method Details

    • servletWebContext

      protected org.apache.commons.chain.web.jakarta.servlet.ServletWebContext servletWebContext()
      Provide the ServletWebContext for this composite.
      Returns:
      Our ServletWebContext
    • release

      public void release()
      Description copied from interface: ActionContext
      Signal to the instance that it will not be used any more, so that any resources which should be cleaned up can be cleaned up.
      Specified by:
      release in interface ActionContext
      Overrides:
      release in class WebActionContext
    • getContext

      public ServletContext getContext()
      Return the ServletContext for this context.
      Returns:
      Our ServletContext
    • getRequest

      public HttpServletRequest getRequest()
      Return the HttpServletRequest for this context.
      Returns:
      Our HttpServletRequest
    • getResponse

      public HttpServletResponse getResponse()
      Return the HttpServletResponse for this context.
      Returns:
      Our HttpServletResponse
    • getActionServlet

      public ActionServlet getActionServlet()
      Return the ActionServlet for this context.
      Returns:
      Our ActionServlet
    • setActionServlet

      public void setActionServlet(ActionServlet servlet)
      Set the ActionServlet instance for this context.
      Parameters:
      servlet - Our ActionServlet instance
    • setActionConfig

      public void setActionConfig(ActionConfig actionConfig)
      Description copied from interface: ActionContext

      Set the ActionConfig class contains the details for processing this request.

      Specified by:
      setActionConfig in interface ActionContext
      Overrides:
      setActionConfig in class ActionContextBase
      Parameters:
      actionConfig - The ActionConfig class to use with this request
    • getMessageResources

      public MessageResources getMessageResources()
      Description copied from interface: ActionContext

      Return the default message resources for the current module.

      Specified by:
      getMessageResources in interface ActionContext
      Overrides:
      getMessageResources in class ActionContextBase
    • getMessageResources

      public MessageResources getMessageResources(String key)
      Description copied from interface: ActionContext

      Return the specified message resources for the current module.

      Specified by:
      getMessageResources in interface ActionContext
      Overrides:
      getMessageResources in class ActionContextBase
      Parameters:
      key - The key specified in the <message-resources> element for the requested bundle
    • setMessageResources

      public void setMessageResources(MessageResources resources)
      Description copied from interface: ActionContext

      Set the default message resources for the current module.

      Specified by:
      setMessageResources in interface ActionContext
      Overrides:
      setMessageResources in class ActionContextBase
    • setMessageResources

      public void setMessageResources(String key, MessageResources resources)
      Store the message resources for the current module under the given request attribute key.
      Parameters:
      key - Request attribute key
      resources - Message resources to store
    • saveErrors

      public void saveErrors(ActionMessages errors)
      Description copied from interface: ActionContext

      Save the given error messages to the internal cache, clearing any previous messages in the cache.

      If the parameter is null or empty, the internal cache is removed.

      Specified by:
      saveErrors in interface ActionContext
      Overrides:
      saveErrors in class ActionContextBase
      Parameters:
      errors - ActionMesssages to cache as errors
    • saveMessages

      public void saveMessages(ActionMessages messages)
      Description copied from interface: ActionContext

      Save the given messages to the internal cache, clearing any previous messages in the cache.

      If the parameter is null or empty, the internal cache is removed.

      Specified by:
      saveMessages in interface ActionContext
      Overrides:
      saveMessages in class ActionContextBase
      Parameters:
      messages - ActionMesssages to cache
    • addMessages

      public void addMessages(ActionMessages messages)
      Description copied from interface: ActionContext

      Append the given messages keys to an internal cache, creating the cache if one is not already present.

      Specified by:
      addMessages in interface ActionContext
      Overrides:
      addMessages in class ActionContextBase
      Parameters:
      messages - New ActionMessages to cache
    • addErrors

      public void addErrors(ActionMessages errors)
      Description copied from interface: ActionContext

      Append the given errors keys to an internal cache, creating the cache if one is not already present.

      Specified by:
      addErrors in interface ActionContext
      Overrides:
      addErrors in class ActionContextBase
      Parameters:
      errors - New ActionMessages to cache as errors
    • getErrors

      public ActionMessages getErrors()
      Description copied from interface: ActionContext

      Retrieve error messages from an internal cache, creating an empty cache if one is not already present.

      Specified by:
      getErrors in interface ActionContext
      Overrides:
      getErrors in class ActionContextBase
      Returns:
      The ActionMessage cache for errors
    • getMessages

      public ActionMessages getMessages()
      Description copied from interface: ActionContext

      Retrieve messages from an internal cache, creating an empty cache if one is not already present.

      Specified by:
      getMessages in interface ActionContext
      Overrides:
      getMessages in class ActionContextBase
      Returns:
      The ActionMessage cache for errors
    • saveToken

      public void saveToken()
      Description copied from interface: ActionContext

      Save a new transaction token in the "session" scope for this context, creating new resources, if needed.

      Specified by:
      saveToken in interface ActionContext
      Overrides:
      saveToken in class ActionContextBase
    • generateToken

      public String generateToken()
      Description copied from interface: ActionContext

      Generate a new transaction token, to be used for enforcing a single request for a particular transaction.

      Specified by:
      generateToken in interface ActionContext
      Overrides:
      generateToken in class ActionContextBase
    • isTokenValid

      public boolean isTokenValid(boolean reset)
      Description copied from interface: ActionContext

      Indicate whether a transaction token is stored in the "session" scope for this context, optionally clearing the token, so that the next check would return false.

      Specified by:
      isTokenValid in interface ActionContext
      Overrides:
      isTokenValid in class ActionContextBase
      Parameters:
      reset - On true, clear the transactional token
    • resetToken

      public void resetToken()
      Description copied from interface: ActionContext

      Clear any transactional token stored in the "session" scope for this context, so that the next check would return false.

      Specified by:
      resetToken in interface ActionContext
      Overrides:
      resetToken in class ActionContextBase