public class DynamicAttachment extends Attachment
Note that a DynamicAttachment might not be available before it is actually created by a component (e.g. plugin), and therefore trying to access it before that component has been invoked, might result in a surprising 404.
DynamicAttachments are not listed among regular attachments in the current version.
Usage:
class MyDynamicComponent implements DynamicAttachmentProvider
{
...
DynamicAttachment destatt = mgr.getDynamicAttachment( destattname );
if( destatt == null )
{
destatt = new DynamicAttachment( context.getEngine(),
context.getPage().getName(),
destfilename,
this );
destatt.setCacheable( false );
}
// This is used to check whether the attachment is modified or not
// so don't forget to update this if your attachment source changes!
// Else JSPWiki will be serving 304s to anyone who asks...
destatt.setLastModified( context.getPage().getLastModified() );
mgr.storeDynamicAttachment( context, destatt );
...
public InputStream getAttachmentData( WikiContext context, Attachment att )
throws IOException
{
byte[] bytes = "This is a test".getBytes(StandardCharsets.UTF_8);
return new ByteArrayInputStream( bytes );
}
ALIAS, CHANGENOTE, DESCRIPTION, REDIRECT| Constructor and Description |
|---|
DynamicAttachment(WikiEngine engine,
java.lang.String parentPage,
java.lang.String fileName,
DynamicAttachmentProvider provider)
Creates a DynamicAttachment.
|
| Modifier and Type | Method and Description |
|---|---|
DynamicAttachmentProvider |
getProvider()
Returns the provider which is used to generate this attachment.
|
getFileName, getParentName, isCacheable, setCacheable, setFileName, toStringclone, compareTo, equals, getAcl, getAttribute, getAttributes, getAuthor, getLastModified, getLayerId, getName, getSize, getTransId, getVersion, getWiki, hashCode, hasMetadata, invalidateMetadata, removeAttribute, setAcl, setAttribute, setAuthor, setHasMetadata, setLastModified, setLayerId, setSize, setTransId, setVersionpublic DynamicAttachment(WikiEngine engine, java.lang.String parentPage, java.lang.String fileName, DynamicAttachmentProvider provider)
engine - The engine which owns this attachmentparentPage - The page which owns this attachmentfileName - The filename of the attachmentprovider - The provider which will be used to generate the attachment.public DynamicAttachmentProvider getProvider()
stSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.