public class LayeredResourceOrigin extends AbstractResourceOrigin<LayeredResource>
ResourceOrigin
which aggregates
other instances of ResourceOrigin
; resources located on the same path will
be served from the foremost ResourceOrigin, but resources that exist only on one path will always be served.ResourceOrigin.ResourceNotFoundException
Modifier and Type | Method and Description |
---|---|
protected InputStream |
doOpenStream(LayeredResource resource) |
LayeredResource |
getByPath(String path)
Retrieves a
Resource object based on the given path. |
protected Charset |
getCharsetFor(LayeredResource resource)
Overridden to throw an exception; since we override
openReader(LayeredResource) ,
this method used in AbstractResourceOrigin.openReader(info.magnolia.resourceloader.AbstractResource)
should never be called. |
protected long |
getLastModified(LayeredResource resource) |
protected String |
getName(LayeredResource resource) |
protected LayeredResource |
getParent(LayeredResource resource) |
protected String |
getPath(LayeredResource resource) |
LayeredResource |
getRoot()
Returns the
Resource for this origin's declared root. |
boolean |
hasPath(String path) |
protected boolean |
isDirectory(LayeredResource resource) |
protected boolean |
isEditable(LayeredResource resource) |
protected boolean |
isFile(LayeredResource resource) |
protected List<LayeredResource> |
listChildren(LayeredResource resource) |
protected LayeredResource |
newLayeredResource(List<Resource> resources) |
protected Reader |
openReader(LayeredResource resource) |
void |
watchForChanges(ResourceVisitor visitor)
Sets up observation for this origin, and hooks it to the given callback
ResourceVisitor . |
getName, openStream, traverseWith
public LayeredResource getRoot()
ResourceOrigin
Resource
for this origin's declared root.public void watchForChanges(ResourceVisitor visitor)
ResourceOrigin
ResourceVisitor
.ResourceVisitor
,
PredicatedResourceVisitor
public LayeredResource 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(LayeredResource resource)
isFile
in class AbstractResourceOrigin<LayeredResource>
Resource.isFile()
protected boolean isDirectory(LayeredResource resource)
isDirectory
in class AbstractResourceOrigin<LayeredResource>
Resource.isDirectory()
protected boolean isEditable(LayeredResource resource)
isEditable
in class AbstractResourceOrigin<LayeredResource>
Resource.isEditable()
protected String getPath(LayeredResource resource)
getPath
in class AbstractResourceOrigin<LayeredResource>
Resource.getPath()
protected String getName(LayeredResource resource)
getName
in class AbstractResourceOrigin<LayeredResource>
Resource.getName()
protected long getLastModified(LayeredResource resource)
getLastModified
in class AbstractResourceOrigin<LayeredResource>
Resource.getLastModified()
protected List<LayeredResource> listChildren(LayeredResource resource)
listChildren
in class AbstractResourceOrigin<LayeredResource>
Resource.listChildren()
protected LayeredResource getParent(LayeredResource resource)
getParent
in class AbstractResourceOrigin<LayeredResource>
Resource.getParent()
protected InputStream doOpenStream(LayeredResource resource) throws IOException
doOpenStream
in class AbstractResourceOrigin<LayeredResource>
IOException
protected Reader openReader(LayeredResource resource) throws IOException
openReader
in class AbstractResourceOrigin<LayeredResource>
IOException
Resource.openReader()
protected Charset getCharsetFor(LayeredResource resource)
openReader(LayeredResource)
,
this method used in AbstractResourceOrigin.openReader(info.magnolia.resourceloader.AbstractResource)
should never be called.getCharsetFor
in class AbstractResourceOrigin<LayeredResource>
protected LayeredResource newLayeredResource(List<Resource> resources)
Copyright © 2003–2016 Magnolia International Ltd.. All rights reserved.