org.mmbase.framework
Class CachedRenderer
java.lang.Object
org.mmbase.framework.AbstractRenderer
org.mmbase.framework.WrappedRenderer
org.mmbase.framework.CachedRenderer
- All Implemented Interfaces:
- Renderer
- Direct Known Subclasses:
- DocumentationRenderer
public class CachedRenderer
- extends WrappedRenderer
This renderer caches other renderers. If you need caching for a certain block, then you define
another block with this class CachedRenderer, and refer the to-be-cached block. Like so:
<block name="statistics_uncached"
mimetype="text/html">
<body>
<class name="org.mmbase.framework.ResourceRenderer">
<param name="resource">documentation/mmstatistics.xml</param>
<param name="type">config</param>
<param name="xslt">xslt/docbook2block.xslt</param>
</class>
</body>
</block>
<block name="statistics"
classification="mmbase.documentation"
mimetype="text/html">
<body>
<class name="org.mmbase.framework.CachedRenderer">
<param name="wrapsBlock">statistics_uncached</param>
<param name="includeRenderTime">xml-comments</param>
</class>
</body>
</block>
*
Caching can be based on an 'expires' property. If that is not specified, caching will happen according the HTTP specifications on the URI returned by Renderer.getUri().
- Since:
- MMBase-1.9.1
- Version:
- $Id: CachedRenderer.java 40167 2009-12-08 18:00:55Z michiel $
- Author:
- Michiel Meeuwissen
|
Method Summary |
protected File |
getCacheFile(Parameters blockParameters,
RenderHints hints)
|
protected File |
getETagFile(File file)
|
protected File |
getExpiresFile(File file)
|
protected String |
getKey(Parameters blockParameters)
|
protected String |
readETag(File f)
|
protected long |
readExpires(File f)
|
void |
render(Parameters blockParameters,
Writer w,
RenderHints hints)
Renders to a writer. |
protected void |
renderFile(File f,
Writer w)
|
protected void |
renderWrappedAndFile(File f,
Parameters blockParameters,
Writer w,
RenderHints hints,
Runnable ready)
Renders the wrapped renderer, and writes the result to both a file, and to the writer. |
void |
setDirectory(String d)
|
void |
setExpires(int e)
|
void |
setIncludeRenderTime(String type)
|
void |
setTimeout(int t)
If using an HttpURLConnection, then use the given timeout. |
void |
setWait(int t)
If rendering of the cached renderer takes very long, you may choose to not wait for the
result. |
String |
toString()
|
protected void |
writeETag(File f,
String etag)
|
protected void |
writeExpires(File f,
long expires)
|
protected void |
writeRenderTime(Date time,
Writer w)
|
CachedRenderer
public CachedRenderer(Renderer.Type t,
Block parent)
setExpires
public void setExpires(int e)
setDirectory
public void setDirectory(String d)
setTimeout
public void setTimeout(int t)
- If using an HttpURLConnection, then use the given timeout. Defaults to 2 seconds.
- Parameters:
t - Timeout in milliseconds
setWait
public void setWait(int t)
- If rendering of the cached renderer takes very long, you may choose to not wait for the
result. But serve an message or the old version. The job can be joined later.
- Parameters:
t - Wait-time in milliseconds
setIncludeRenderTime
public void setIncludeRenderTime(String type)
writeRenderTime
protected void writeRenderTime(Date time,
Writer w)
throws FrameworkException,
IOException
- Throws:
FrameworkException
IOException
getKey
protected String getKey(Parameters blockParameters)
getCacheFile
protected File getCacheFile(Parameters blockParameters,
RenderHints hints)
getETagFile
protected File getETagFile(File file)
writeETag
protected void writeETag(File f,
String etag)
throws IOException
- Throws:
IOException
readETag
protected String readETag(File f)
throws IOException
- Throws:
IOException
getExpiresFile
protected File getExpiresFile(File file)
writeExpires
protected void writeExpires(File f,
long expires)
throws IOException
- Throws:
IOException
readExpires
protected long readExpires(File f)
throws IOException
- Throws:
IOException
renderFile
protected void renderFile(File f,
Writer w)
throws FrameworkException,
IOException
- Throws:
FrameworkException
IOException
renderWrappedAndFile
protected void renderWrappedAndFile(File f,
Parameters blockParameters,
Writer w,
RenderHints hints,
Runnable ready)
throws FrameworkException,
IOException
- Renders the wrapped renderer, and writes the result to both a file, and to the writer.
- Throws:
FrameworkException
IOException
render
public void render(Parameters blockParameters,
Writer w,
RenderHints hints)
throws FrameworkException
- Description copied from interface:
Renderer
- Renders to a writer. In case of e.g. a JSPView, the parameters must also contain
the Http Servlet response and request, besided specific parameters for this component.
- Specified by:
render in interface Renderer- Overrides:
render in class WrappedRenderer
- Throws:
FrameworkException
toString
public String toString()
- Overrides:
toString in class WrappedRenderer
MMBase 2.0-SNAPSHOT - null