net.sourceforge.stripes.controller
Class DynamicMappingFilter.TempBufferWriter
java.lang.Object
java.io.Writer
net.sourceforge.stripes.controller.DynamicMappingFilter.TempBufferWriter
- All Implemented Interfaces:
- Closeable, Flushable, Appendable
- Enclosing class:
- DynamicMappingFilter
public static class DynamicMappingFilter.TempBufferWriter
- extends Writer
A Writer
that passes characters to a PrintWriter
. It buffers the first
N
characters written to it and automatically overflows when the number of characters
written exceeds the limit. The size of the buffer defaults to 1024 characters, but it can be
changed using the IncludeBufferSize
filter init-param in web.xml
. If
IncludeBufferSize
is zero or negative, then a DynamicMappingFilter.TempBufferWriter
will not be
used at all. This is only a good idea if your servlet container does not write an error
message to output when it can't find an included resource or if you only include resources
that do not depend on this filter to be delivered, such as other servlets, JSPs, static
resources, ActionBeans that are mapped with a prefix (/action/*
) or suffix (*.action
),
etc.
This writer is used to partially buffer the output of includes. Some (all?) servlet
containers write a message to the output stream indicating if an included resource is missing
because if the response has already been committed, they cannot send a 404 error. Since the
filter depends on getting a 404 before it attempts to dispatch an ActionBean
, that
is problematic. So in using this writer, we assume that the length of the "missing resource"
message will be less than the buffer size and we discard that message if we're able to map
the included URL to an ActionBean
. If there is no 404 then the output will be sent
normally. If there is a 404 and the URL does not match an ActionBean then the "missing
resource" message is sent through.
- Since:
- Stripes 1.5
- Author:
- Ben Gunter
Method Summary |
void |
close()
|
void |
flush()
|
protected void |
overflow()
Write the contents of the buffer to the underlying writer. |
void |
write(char[] chars,
int offset,
int length)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DynamicMappingFilter.TempBufferWriter
public DynamicMappingFilter.TempBufferWriter(PrintWriter out)
close
public void close()
throws IOException
- Specified by:
close
in interface Closeable
- Specified by:
close
in class Writer
- Throws:
IOException
flush
public void flush()
throws IOException
- Specified by:
flush
in interface Flushable
- Specified by:
flush
in class Writer
- Throws:
IOException
write
public void write(char[] chars,
int offset,
int length)
throws IOException
- Specified by:
write
in class Writer
- Throws:
IOException
overflow
protected void overflow()
- Write the contents of the buffer to the underlying writer. After a call to
overflow()
, all future writes to this writer will pass directly to the
underlying writer.
? Copyright 2005-2006, Stripes Development Team.