|
ModeShape Distribution 3.0.0.Alpha6 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.modeshape.jcr.value.binary.AbstractBinaryStore
org.modeshape.jcr.value.binary.FileSystemBinaryStore
@ThreadSafe public class FileSystemBinaryStore
A BinaryStore
that stores files in a directory on the file system. The store does use file locks to prevent other
processes from concurrently writing the files, and it also uses an internal set of locks to prevent mulitple threads from
simultaneously writing to the persisted files.
Field Summary | |
---|---|
protected static String |
TRASH_DIRECTORY_NAME
|
Fields inherited from class org.modeshape.jcr.value.binary.AbstractBinaryStore |
---|
MEDIUM_BUFFER_SIZE |
Fields inherited from interface org.modeshape.jcr.value.binary.BinaryStore |
---|
DEFAULT_MINIMUM_BINARY_SIZE_IN_BYTES |
Constructor Summary | |
---|---|
protected |
FileSystemBinaryStore(File directory)
|
Method Summary | |
---|---|
static FileSystemBinaryStore |
create(File directory)
|
protected File |
findFile(File directory,
BinaryKey key,
boolean createParentDirsIfMissing)
|
File |
getDirectory()
|
InputStream |
getInputStream(BinaryKey key)
Get an InputStream to the binary content with the supplied key. |
String |
getMimeType(BinaryValue binary,
String name)
Get the MIME type for this binary value. |
String |
getText(BinaryValue binary)
Get the text that can be extracted from this binary content. |
protected void |
initializeStorage(File directory)
|
protected void |
markAsUnused(BinaryKey key)
|
void |
markAsUnused(Iterable<BinaryKey> keys)
Mark the supplied binary keys as unused, but key them in quarantine until needed again (at which point they're removed from quarantine) or until BinaryStore.removeValuesUnusedLongerThan(long, TimeUnit) is called. |
protected void |
moveFileExclusively(File original,
File destination)
|
protected void |
pruneEmptyDirectories(File directory,
File removeable)
Remove any empty directories above removeable but below directory |
void |
removeValuesUnusedLongerThan(long minimumAge,
TimeUnit unit)
Remove binary values that have been unused for at least the specified amount of time. |
BinaryValue |
storeValue(InputStream stream)
Store the binary value and return the JCR representation. |
protected void |
touch(File file)
|
Methods inherited from class org.modeshape.jcr.value.binary.AbstractBinaryStore |
---|
bestBufferSize, detector, extractor, getMinimumBinarySizeInBytes, setMimeTypeDetector, setMinimumBinarySizeInBytes, setTextExtractor, shutdown, start |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String TRASH_DIRECTORY_NAME
Constructor Detail |
---|
protected FileSystemBinaryStore(File directory)
Method Detail |
---|
public static FileSystemBinaryStore create(File directory)
public File getDirectory()
public BinaryValue storeValue(InputStream stream) throws BinaryStoreException
BinaryStore
stream
- the stream containing the binary content to be stored; may not be null
BinaryStoreException
protected final void moveFileExclusively(File original, File destination) throws BinaryStoreException
BinaryStoreException
protected final File findFile(File directory, BinaryKey key, boolean createParentDirsIfMissing) throws BinaryStoreException
BinaryStoreException
public InputStream getInputStream(BinaryKey key) throws BinaryStoreException
BinaryStore
InputStream
to the binary content with the supplied key.
key
- the key to the binary content; never null
BinaryStoreException
- if there is a problem reading the content from the storeprotected void initializeStorage(File directory) throws BinaryStoreException
BinaryStoreException
public void markAsUnused(Iterable<BinaryKey> keys) throws BinaryStoreException
BinaryStore
BinaryStore.removeValuesUnusedLongerThan(long, TimeUnit)
is called. This method ignores any keys for
values not stored within this store.
Note that the implementation must never block.
keys
- the keys for the binary values that are no longer needed
BinaryStoreException
- if there is a problem marking any of the supplied binary values as unusedprotected void markAsUnused(BinaryKey key) throws BinaryStoreException
BinaryStoreException
protected void touch(File file) throws BinaryStoreException
BinaryStoreException
protected void pruneEmptyDirectories(File directory, File removeable)
removeable
but below directory
directory
- the top-level directory to keep; may not be null and must be an ancestor of removeable
removeable
- the file or directory above which any empty directories can be removed; may not be nullpublic void removeValuesUnusedLongerThan(long minimumAge, TimeUnit unit) throws BinaryStoreException
BinaryStore
unused
for at least the specified amount of time.
Note that the implementation must never block.
minimumAge
- the minimum time that a binary value has been unused
before it can be
removed; must be non-negativeunit
- the time unit for the minimum age; may not be null
BinaryStoreException
- if there is a problem removing the unused valuespublic String getText(BinaryValue binary) throws BinaryStoreException
BinaryStore
binary
- the binary content; may not be null
BinaryStoreException
- if the binary content could not be accessedpublic String getMimeType(BinaryValue binary, String name) throws IOException, RepositoryException
BinaryStore
binary
- the binary content; may not be nullname
- the name of the content, useful for determining the MIME type; may be null if not known
IOException
- if there is a problem reading the binary content
RepositoryException
- if an error occurs.
|
ModeShape Distribution 3.0.0.Alpha6 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |