Interface SecondaryStorage
- All Known Implementing Classes:
NoopSecondaryStorage,TempDirSecondaryStorage
public interface SecondaryStorage
This is a mechanism that allows large SiteMesh requests to be spilled out of memory
and into secondary storage. This means that a fixed amount of memory can be used for a SiteMesh
request instead of filling till memory is exhausted.
An implementation of this interface should be LAZY. It should not open its secondary storage until the first char has been written to it. This will ensure its as cheap as possible IF there is no need to spill into it.
And implementation MUST also assume that it lives for the life of a request. A new one will be constructed on every request, another reason to be LAZY on file creation say.
An implementation of this interface should be LAZY. It should not open its secondary storage until the first char has been written to it. This will ensure its as cheap as possible IF there is no need to spill into it.
And implementation MUST also assume that it lives for the life of a request. A new one will be constructed on every request, another reason to be LAZY on file creation say.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanUp()This allows you to ask the secondary storage to clean up after itself.longReturns the number of characters that should be stored in memory before this secondary storage.voidwrite(char[] chars, int off, int len) voidwrite(int c) voidvoidvoidThis method will close the "secondary storage" and write the captured output to the specified output writer.
-
Method Details
-
getMemoryLimitBeforeUse
long getMemoryLimitBeforeUse()Returns the number of characters that should be stored in memory before this secondary storage. If this value is 0 or below then it is in fact disabled.- Returns:
- the memory limits in force
-
write
- Throws:
IOException- See Also:
-
write
- Throws:
IOException- See Also:
-
write
- Throws:
IOException- See Also:
-
write
- Throws:
IOException- See Also:
-
writeTo
This method will close the "secondary storage" and write the captured output to the specified output writer.- Parameters:
out- the output writer to send the stored data- Throws:
IOException- if the data cant be written
-
cleanUp
void cleanUp()This allows you to ask the secondary storage to clean up after itself. A try / finally would be a good place to put this.
This should be able to be called multiple times because we want to be able to always cleanup in case of exceptions as well an blue sky paths.
Really no exceptions should be propagated from this method.
-