public class FileSystemResourceOrigin extends AbstractResourceOrigin<FileSystemResource>
ResourceOrigin
which loads resources on the file system.ResourceOrigin.ResourceNotFoundException
Modifier and Type | Field and Description |
---|---|
static String |
RESOURCES_DIR_PROPERTY |
Modifier and Type | Method and Description |
---|---|
protected ExclusionsFilter |
buildExclusionsFilter()
TODO: The current implementation makes assumptions about what directories to excludes;
Except for META-INF and WEB-INF, the others are highly installation dependent.
|
protected InputStream |
doOpenStream(FileSystemResource resource) |
protected boolean |
existsAndAllowed(Path filePath) |
FileSystemResource |
getByPath(String path)
Retrieves a
Resource object based on the given path. |
protected Charset |
getCharsetFor(FileSystemResource resource)
|
protected long |
getLastModified(FileSystemResource resource) |
protected String |
getName(FileSystemResource resource) |
protected FileSystemResource |
getParent(FileSystemResource resource) |
protected String |
getPath(FileSystemResource resource) |
protected Path |
getPath(String path) |
FileSystemResource |
getRoot()
Returns the
Resource for this origin's declared root. |
boolean |
hasPath(String path) |
protected boolean |
isDirectory(FileSystemResource resource) |
protected boolean |
isFile(FileSystemResource resource) |
protected List<FileSystemResource> |
listChildren(FileSystemResource resource) |
protected FileSystemResource |
newResource(Path path)
Create a
Resource out of a relative path. |
protected Path |
validateRootPath(String path) |
void |
watchForChanges(ResourceVisitor visitor)
Sets up observation for this origin, and hooks it to the given callback
ResourceVisitor . |
getName, isEditable, openReader, openStream, traverseWith
public static final String RESOURCES_DIR_PROPERTY
protected ExclusionsFilter buildExclusionsFilter()
public FileSystemResource getRoot()
ResourceOrigin
Resource
for this origin's declared root.public void watchForChanges(ResourceVisitor visitor)
ResourceOrigin
ResourceVisitor
.ResourceVisitor
,
PredicatedResourceVisitor
public FileSystemResource getByPath(String path)
ResourceOrigin
Resource
object based on the given path. The given path may or may not start with a
leading /, but will always be considered relative to whatever root path this origin uses; for the user of this
class, such paths should thus be considered absolute, depending on the implementation, they may be relative
to some other path. Directory traversal navigation should be prohibited by implementations for security reasons.public boolean hasPath(String path)
protected boolean isFile(FileSystemResource resource)
isFile
in class AbstractResourceOrigin<FileSystemResource>
Resource.isFile()
protected boolean isDirectory(FileSystemResource resource)
isDirectory
in class AbstractResourceOrigin<FileSystemResource>
Resource.isDirectory()
protected String getPath(FileSystemResource resource)
getPath
in class AbstractResourceOrigin<FileSystemResource>
Resource.getPath()
protected String getName(FileSystemResource resource)
getName
in class AbstractResourceOrigin<FileSystemResource>
Resource.getName()
protected long getLastModified(FileSystemResource resource)
getLastModified
in class AbstractResourceOrigin<FileSystemResource>
Resource.getLastModified()
protected List<FileSystemResource> listChildren(FileSystemResource resource)
listChildren
in class AbstractResourceOrigin<FileSystemResource>
Resource.listChildren()
protected FileSystemResource getParent(FileSystemResource resource)
getParent
in class AbstractResourceOrigin<FileSystemResource>
Resource.getParent()
protected InputStream doOpenStream(FileSystemResource resource) throws IOException
doOpenStream
in class AbstractResourceOrigin<FileSystemResource>
IOException
protected Charset getCharsetFor(FileSystemResource resource)
AbstractResourceOrigin
getCharsetFor
in class AbstractResourceOrigin<FileSystemResource>
protected boolean existsAndAllowed(Path filePath)
protected FileSystemResource newResource(Path path)
Resource
out of a relative path.path
- expected to be a relative path under the rootPathCopyright © 2003–2015 Magnolia International Ltd.. All rights reserved.