Class StaticAppContext

All Implemented Interfaces:
AliasCheck, Deployable, Handler, Handler.Container, Handler.Singleton, Request.Handler, Attributes, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, Invocable

public class StaticAppContext extends ContextHandler
A ContextHandler that only serves static content from any source supported by ResourceHandler.

To set the directory to serve content from, set the base resource via the following methods.

This is basically just a ResourceHandler with a context-path.

  • Constructor Details

    • StaticAppContext

      public StaticAppContext()
      Create a StaticAppContext.
    • StaticAppContext

      public StaticAppContext(String contextPath)
      Create a StaticAppContext on a specific contextPath.
      Parameters:
      contextPath - the context path to serve static content from
    • StaticAppContext

      public StaticAppContext(String contextPath, ResourceHandler resourceHandler)
      Create a StaticAppContext on a specific contextPath using a configured ResourceHandler.
      Parameters:
      contextPath - the context path
      resourceHandler - the resource handler
  • Method Details

    • newResourceHandler

      protected ResourceHandler newResourceHandler()
      Override to customize a dynamically created ResourceHandler (such as from deploy).
      Returns:
      the customized ResourceHandler.
    • getResourceHandler

      public ResourceHandler getResourceHandler()
    • initializeDefault

      protected void initializeDefault(String keyName, Object value)
      Description copied from class: ContextHandler
      Called for each attribute key encountered during the Deployable.initializeDefaults(Attributes) processing.
      Overrides:
      initializeDefault in class ContextHandler
      Parameters:
      keyName - the key name
      value - the value
    • setBaseResource

      public void setBaseResource(Resource baseResource)
      Description copied from class: ContextHandler

      Set the base resource to serve content from for this context, which must exist and be readable when the context is started.

      Overrides:
      setBaseResource in class ContextHandler
      Parameters:
      baseResource - The base resource for the context.