public class PortletContextResource
extends org.springframework.core.io.AbstractFileResolvingResource
implements org.springframework.core.io.ContextResource
Resource implementation for
PortletContext resources, interpreting
relative paths within the portlet application root directory.
Always supports stream access and URL access, but only allows
java.io.File access when the portlet application archive
is expanded.
PortletContext.getResourceAsStream(java.lang.String),
PortletContext.getRealPath(java.lang.String)| Constructor and Description |
|---|
PortletContextResource(PortletContext portletContext,
String path)
Create a new PortletContextResource.
|
| Modifier and Type | Method and Description |
|---|---|
org.springframework.core.io.Resource |
createRelative(String relativePath) |
boolean |
equals(Object obj) |
boolean |
exists()
This implementation checks
PortletContext.getResource. |
String |
getDescription() |
File |
getFile()
This implementation resolves "file:" URLs or alternatively delegates to
PortletContext.getRealPath, throwing a FileNotFoundException
if not found or not resolvable. |
String |
getFilename() |
InputStream |
getInputStream()
This implementation delegates to
PortletContext.getResourceAsStream,
but throws a FileNotFoundException if not found. |
String |
getPath()
Return the path for this resource.
|
String |
getPathWithinContext() |
PortletContext |
getPortletContext()
Return the PortletContext for this resource.
|
URL |
getURL()
This implementation delegates to
PortletContext.getResource,
but throws a FileNotFoundException if no resource found. |
int |
hashCode() |
boolean |
isReadable()
This implementation delegates to
PortletContext.getResourceAsStream,
which returns null in case of a non-readable resource (e.g. |
contentLength, customizeConnection, customizeConnection, getFile, getFileForLastModifiedCheck, lastModifiedpublic PortletContextResource(PortletContext portletContext, String path)
The Portlet spec requires that resource paths start with a slash, even if many containers accept paths without leading slash too. Consequently, the given path will be prepended with a slash if it doesn't already start with one.
portletContext - the PortletContext to load frompath - the path of the resourcepublic final PortletContext getPortletContext()
public final String getPath()
public boolean exists()
PortletContext.getResource.exists in interface org.springframework.core.io.Resourceexists in class org.springframework.core.io.AbstractFileResolvingResourcePortletContext.getResource(String)public boolean isReadable()
PortletContext.getResourceAsStream,
which returns null in case of a non-readable resource (e.g. a directory).isReadable in interface org.springframework.core.io.ResourceisReadable in class org.springframework.core.io.AbstractFileResolvingResourcePortletContext.getResourceAsStream(String)public InputStream getInputStream() throws IOException
PortletContext.getResourceAsStream,
but throws a FileNotFoundException if not found.getInputStream in interface org.springframework.core.io.InputStreamSourceIOExceptionPortletContext.getResourceAsStream(String)public URL getURL() throws IOException
PortletContext.getResource,
but throws a FileNotFoundException if no resource found.getURL in interface org.springframework.core.io.ResourcegetURL in class org.springframework.core.io.AbstractResourceIOExceptionPortletContext.getResource(String)public File getFile() throws IOException
PortletContext.getRealPath, throwing a FileNotFoundException
if not found or not resolvable.getFile in interface org.springframework.core.io.ResourcegetFile in class org.springframework.core.io.AbstractFileResolvingResourceIOExceptionPortletContext.getResource(String),
PortletContext.getRealPath(String)public org.springframework.core.io.Resource createRelative(String relativePath)
createRelative in interface org.springframework.core.io.ResourcecreateRelative in class org.springframework.core.io.AbstractResourcepublic String getFilename()
getFilename in interface org.springframework.core.io.ResourcegetFilename in class org.springframework.core.io.AbstractResourcepublic String getDescription()
getDescription in interface org.springframework.core.io.Resourcepublic String getPathWithinContext()
getPathWithinContext in interface org.springframework.core.io.ContextResourcepublic boolean equals(Object obj)
equals in class org.springframework.core.io.AbstractResourcepublic int hashCode()
hashCode in class org.springframework.core.io.AbstractResource