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

# Class StoreContextAppender

java.lang.Object
org.apache.catalina.storeconfig.StoreAppender
org.apache.catalina.storeconfig.StoreContextAppender

public class StoreContextAppender extends StoreAppender
store StandardContext Attributes ...

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StoreContextAppender()`
  Constructs a new StoreContextAppender for handling StandardContext serialization.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `defaultInstance(Object bean)`
  Generate a real default StandardContext
  `protected File`
  `getAppBase(StandardHost host)`
  Resolves the absolute canonical path of the application base directory for the given host.
  `protected String`
  `getDefaultWorkDir(StandardContext context)`
  Make default Work Dir.
  `protected File`
  `getDocBase(StandardContext context, File appBase)`
  Resolves the absolute canonical path of the document base directory for the given context.
  `boolean`
  `isPrintValue(Object bean, Object bean2, String attrName, StoreDescription desc)`
  Print Context Values.
  `protected void`
  `printAttribute(PrintWriter writer, int indent, Object bean, StoreDescription desc, String attributeName, Object bean2, Object value)`
  Store the specified of the specified JavaBean.

  ### Methods inherited from class StoreAppender

  `checkAttribute, isPersistable, printAttributes, printAttributes, printCloseTag, printIndent, printOpenTag, printTag, printTagArray, printTagContent, printValue`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### StoreContextAppender

    public StoreContextAppender()
    Constructs a new StoreContextAppender for handling StandardContext serialization.

- ## Method Details

  - ### printAttribute

    protected void printAttribute(PrintWriter writer, int indent, Object bean, StoreDescription desc, String attributeName, Object bean2, Object value)
    Store the specified of the specified JavaBean. Adds special handling for `docBase`.
    Overrides:
      `printAttribute` in class `StoreAppender`
    Parameters:
      `writer` - PrintWriter to which we are storing
      `indent` - Indentation level
      `bean` - The current bean
      `desc` - Store description from this bean
      `attributeName` - The attribute name to store
      `bean2` - A default instance of the bean for comparison
      `value` - The attribute value

  - ### isPrintValue

    public boolean isPrintValue(Object bean, Object bean2, String attrName, StoreDescription desc)
    Print Context Values.
    - Special handling to default workDir.
    - Don't save path at external context.xml
    - Don't generate docBase for host.appBase webapps
    Determine if the attribute value needs to be stored.
    Overrides:
      `isPrintValue` in class `StoreAppender`
    Parameters:
      `bean` - original bean
      `bean2` - default bean
      `attrName` - attribute name
      `desc` - Store description from this bean
    Returns:
      `true` if the value should be stored

  - ### getAppBase

    protected File getAppBase(StandardHost host)
    Resolves the absolute canonical path of the application base directory for the given host.
    Parameters:
      `host` - The StandardHost instance
    Returns:
      The canonical File representing the appBase directory

  - ### getDocBase

    protected File getDocBase(StandardContext context, File appBase)
    Resolves the absolute canonical path of the document base directory for the given context.
    Parameters:
      `context` - The StandardContext instance
      `appBase` - The application base directory
    Returns:
      The canonical File representing the docBase directory

  - ### getDefaultWorkDir

    protected String getDefaultWorkDir(StandardContext context)
    Make default Work Dir.
    Parameters:
      `context` - The context
    Returns:
      The default working directory for the context.

  - ### defaultInstance

    public Object defaultInstance(Object bean) throws ReflectiveOperationException
    Generate a real default StandardContext

    TODO read and interpret the default context.xml and context.xml.default

    TODO Cache a Default StandardContext ( with reloading strategy)

    TODO remove really all elements, but detection is hard... To Listener or Valve from same class?

    Overrides:
      `defaultInstance` in class `StoreAppender`
    Parameters:
      `bean` - The bean
    Returns:
      an object from same class as bean parameter
    Throws:
      `ReflectiveOperationException` - Error creating a new instance
    See Also:
      - `StoreAppender.defaultInstance(java.lang.Object)`