Class TempDirSecondaryStorage
java.lang.Object
com.opensymphony.module.sitemesh.scalability.secondarystorage.TempDirSecondaryStorage
- All Implemented Interfaces:
SecondaryStorage
A SecondaryStorage implementation that uses the File.createTempFile() method
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTempDirSecondaryStorage(long memoryLimitBeforeUse) TempDirSecondaryStorage(long memoryLimitBeforeUse, File tempDirectory) -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanUp()This allows you to ask the secondary storage to clean up after itself.protected voidprotected voidlongReturns the number of characters that should be stored in memory before this secondary storage.protected FileBy default creates a temporary file ingetTempDirectory().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.
-
Field Details
-
logger
-
-
Constructor Details
-
TempDirSecondaryStorage
public TempDirSecondaryStorage(long memoryLimitBeforeUse) -
TempDirSecondaryStorage
-
-
Method Details
-
getMemoryLimitBeforeUse
public long getMemoryLimitBeforeUse()Description copied from interface:SecondaryStorageReturns 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.- Specified by:
getMemoryLimitBeforeUsein interfaceSecondaryStorage- Returns:
- the memory limits in force
-
getTempDirectory
-
ensureIsOpen
protected void ensureIsOpen() -
getTempFile
By default creates a temporary file ingetTempDirectory(). The JavaFile.createTempFile(String, String, java.io.File)ensures that the file is unique.- Returns:
- a write-able temporary file
- Throws:
IOException
-
write
- Specified by:
writein interfaceSecondaryStorage- Throws:
IOException- See Also:
-
write
- Specified by:
writein interfaceSecondaryStorage- Throws:
IOException- See Also:
-
write
- Specified by:
writein interfaceSecondaryStorage- Throws:
IOException- See Also:
-
write
- Specified by:
writein interfaceSecondaryStorage- Throws:
IOException- See Also:
-
writeTo
Description copied from interface:SecondaryStorageThis method will close the "secondary storage" and write the captured output to the specified output writer.- Specified by:
writeToin interfaceSecondaryStorage- Parameters:
out- the output writer to send the stored data- Throws:
IOException- if the data cant be written
-
cleanUp
public void cleanUp()Description copied from interface:SecondaryStorageThis 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.- Specified by:
cleanUpin interfaceSecondaryStorage
-
cleanupImplementation
- Throws:
IOException
-