Class SecondaryStorageBufferWriter

java.lang.Object
java.io.Writer
com.opensymphony.module.sitemesh.util.CharArrayWriter
com.opensymphony.module.sitemesh.scalability.secondarystorage.SecondaryStorageBufferWriter
All Implemented Interfaces:
SitemeshWriter, Closeable, Flushable, Appendable, AutoCloseable

public class SecondaryStorageBufferWriter extends CharArrayWriter implements SitemeshWriter
This writer allows for secondary storage to be use If the body of the response its really large
It will ensure that everything up to the <body> tage is in memory before spilling over, so that further parsing can use memory access to find important page details. But if the page gets really large then it will spill into the secondary storage area.
This of course falls down if the <head> section was megabytes in size say but we are deliberately not catering for this situation and hence it would be worse than SiteMesh without spill over.
  • Constructor Details

    • SecondaryStorageBufferWriter

      public SecondaryStorageBufferWriter(SecondaryStorage secondaryStorage)
    • SecondaryStorageBufferWriter

      public SecondaryStorageBufferWriter(int initialBufferSize, SecondaryStorage secondaryStorage)
  • Method Details

    • getUnderlyingWriter

      public Writer getUnderlyingWriter()
      Description copied from interface: SitemeshWriter
      Because writer is a class and not an interface we need a way to self reference so we can pass the underlying Writer onto other Writers.
      Specified by:
      getUnderlyingWriter in interface SitemeshWriter
      Returns:
      a self reference to this so it can be wrapped say.
    • write

      public void write(int c)
      Description copied from class: CharArrayWriter
      Writes a character to the buffer.
      Specified by:
      write in interface SitemeshWriter
      Overrides:
      write in class CharArrayWriter
      Parameters:
      c - the character to write
    • write

      public void write(char[] chars, int off, int len)
      Description copied from class: CharArrayWriter
      Writes characters to the buffer.
      Specified by:
      write in interface SitemeshWriter
      Overrides:
      write in class CharArrayWriter
      Parameters:
      chars - the data to be written
      off - the start offset in the data
      len - the number of chars that are written
    • write

      public void write(char[] chars) throws IOException
      Description copied from interface: SitemeshWriter
      Taken from Writer
      Specified by:
      write in interface SitemeshWriter
      Overrides:
      write in class Writer
      Parameters:
      chars - the characters to write
      Throws:
      IOException
    • write

      public void write(String str, int off, int len)
      Description copied from class: CharArrayWriter
      Write a portion of a string to the buffer.
      Specified by:
      write in interface SitemeshWriter
      Overrides:
      write in class CharArrayWriter
      Parameters:
      str - String to be written from
      off - Offset from which to start reading characters
      len - Number of characters to be written
    • write

      public void write(String str) throws IOException
      Description copied from interface: SitemeshWriter
      Taken from Writer
      Specified by:
      write in interface SitemeshWriter
      Overrides:
      write in class Writer
      Parameters:
      str - the characters to write
      Throws:
      IOException
    • writeSitemeshBufferFragment

      public boolean writeSitemeshBufferFragment(SitemeshBufferFragment bufferFragment) throws IOException
      Description copied from interface: SitemeshWriter
      Write a sitemesh buffer fragment to the writer. This may not be written immediately, it may be stored and written later, when this buffer is written out to a writer.
      Specified by:
      writeSitemeshBufferFragment in interface SitemeshWriter
      Parameters:
      bufferFragment - The buffer fragment to write
      Returns:
      True if the buffer was written immediately, or false if it will be written later
      Throws:
      IOException - If an IOException occurred
    • getSitemeshBuffer

      public SitemeshBuffer getSitemeshBuffer()
      Description copied from interface: SitemeshWriter
      Get the underlying buffer for the writer
      Specified by:
      getSitemeshBuffer in interface SitemeshWriter
      Returns:
      The underlying buffer