StandardContextSF (Apache Tomcat 9.0.120 API Documentation)
Description: declaration: package: org.apache.catalina.storeconfig, class: StandardContextSF

# Class StandardContextSF

java.lang.Object
org.apache.catalina.storeconfig.StoreFactoryBase
org.apache.catalina.storeconfig.StandardContextSF

All Implemented Interfaces:
  `IStoreFactory`

public class StandardContextSF extends StoreFactoryBase
Store server.xml Context element with all children

- Store all context at server.xml
- Store existing app.xml context a conf/enginename/hostname/app.xml
- Store with backup

- ## Field Summary

  ### Fields inherited from class StoreFactoryBase

  `sm`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StandardContextSF()`
  Constructs a new StandardContextSF instance for storing Context elements in server.xml.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected File`
  `configBase(Context context)`
  Return a File object representing the "configuration root" directory for our associated Host.
  `protected String[]`
  `filterWatchedResources(StandardContext context, String[] wresources)`
  Filter out the default watched resources, to remove standard ones.
  `protected StoreFileMover`
  `getConfigFileWriter(Context context)`
  Get explicit writer for context (context.getConfigFile()).
  `void`
  `store(PrintWriter aWriter, int indent, Object aContext)`
  Store a Context as Separate file as configFile value from context exists. filename can be relative to catalina.base.
  `void`
  `storeChildren(PrintWriter aWriter, int indent, Object aContext, StoreDescription parentDesc)`
  Store the specified context element children.
  `protected void`
  `storeContextSeparate(PrintWriter aWriter, int indent, StandardContext aContext)`
  Store a Context without backup add separate file or when configFile = null a aWriter.
  `protected void`
  `storeWithBackup(StandardContext aContext)`
  Store the Context with a Backup.

  ### Methods inherited from class StoreFactoryBase

  `getInfo, getRegistry, getStoreAppender, setRegistry, setStoreAppender, storeElement, storeElementArray, storeXMLHead`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### StandardContextSF

    public StandardContextSF()
    Constructs a new StandardContextSF instance for storing Context elements in server.xml.

- ## Method Details

  - ### store

    public void store(PrintWriter aWriter, int indent, Object aContext) throws Exception
    Store a Context as Separate file as configFile value from context exists. filename can be relative to catalina.base.
    Specified by:
      `store` in interface `IStoreFactory`
    Overrides:
      `store` in class `StoreFactoryBase`
    Parameters:
      `aWriter` - the writer to write to
      `indent` - the indentation
      `aContext` - the element to write
    Throws:
      `Exception` - if an error occurs
    See Also:
      - `IStoreFactory.store(java.io.PrintWriter, int, java.lang.Object)`

  - ### storeContextSeparate

    protected void storeContextSeparate(PrintWriter aWriter, int indent, StandardContext aContext) throws Exception
    Store a Context without backup add separate file or when configFile = null a aWriter.
    Parameters:
      `aWriter` - Current output writer
      `indent` - Indentation level
      `aContext` - The context which will be stored
    Throws:
      `Exception` - Configuration storing error

  - ### storeWithBackup

    protected void storeWithBackup(StandardContext aContext) throws Exception
    Store the Context with a Backup.
    Parameters:
      `aContext` - The context which will be stored
    Throws:
      `Exception` - Configuration storing error

  - ### getConfigFileWriter

    protected StoreFileMover getConfigFileWriter(Context context) throws Exception
    Get explicit writer for context (context.getConfigFile()).
    Parameters:
      `context` - The context which will be stored
    Returns:
      The file mover
    Throws:
      `Exception` - Error getting a writer for the configuration file

  - ### storeChildren

    public void storeChildren(PrintWriter aWriter, int indent, Object aContext, StoreDescription parentDesc) throws Exception
    Store the specified context element children.

    Must Implement at subclass for custom store children handling.

    Overrides:
      `storeChildren` in class `StoreFactoryBase`
    Parameters:
      `aWriter` - Current output writer
      `indent` - Indentation level
      `aContext` - Current element
      `parentDesc` - The element description
    Throws:
      `Exception` - Configuration storing error

  - ### configBase

    protected File configBase(Context context)
    Return a File object representing the "configuration root" directory for our associated Host.
    Parameters:
      `context` - The context instance
    Returns:
      a file to the configuration base path

  - ### filterWatchedResources

    protected String[] filterWatchedResources(StandardContext context, String[] wresources) throws Exception
    Filter out the default watched resources, to remove standard ones.

    TODO relative watched resources

    TODO absolute handling configFile

    TODO Filename case handling for Windows?

    TODO digester variable substitution $catalina.base, $catalina.home

    Parameters:
      `context` - The context instance
      `wresources` - The raw watched resources list
    Returns:
      The filtered watched resources
    Throws:
      `Exception` - Configuration storing error