public class

PortletContextResource

extends AbstractFileResolvingResource
implements ContextResource
java.lang.Object
   ↳ org.springframework.core.io.AbstractResource
     ↳ org.springframework.core.io.AbstractFileResolvingResource
       ↳ org.springframework.web.portlet.context.PortletContextResource

Class Overview

Resource implementation for javax.portlet.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.

See Also
  • javax.portlet.PortletContext#getResourceAsStream
  • javax.portlet.PortletContext#getRealPath

Summary

Public Constructors
PortletContextResource(PortletContext portletContext, String path)
Create a new PortletContextResource.
Public Methods
Resource createRelative(String relativePath)
This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.
boolean equals(Object obj)
This implementation compares description strings.
boolean exists()
This implementation checks PortletContext.getResource.
String getDescription()
Return a description for this resource, to be used for error output when working with the resource.
File getFile()
This implementation delegates to PortletContext.getRealPath, but throws a FileNotFoundException if not found or not resolvable.
String getFilename()
This implementation always throws IllegalStateException, assuming that the resource does not have a filename.
InputStream getInputStream()
This implementation delegates to PortletContext.getResourceAsStream, but throws a FileNotFoundException if not found.
final String getPath()
Return the path for this resource.
String getPathWithinContext()
Return the path within the enclosing 'context'.
final 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()
This implementation returns the description's hash code.
[Expand]
Inherited Methods
From class org.springframework.core.io.AbstractFileResolvingResource
From class org.springframework.core.io.AbstractResource
From class java.lang.Object
From interface org.springframework.core.io.ContextResource
From interface org.springframework.core.io.InputStreamSource
From interface org.springframework.core.io.Resource

Public Constructors

public PortletContextResource (PortletContext portletContext, String path)

Create a new PortletContextResource.

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.

Parameters
portletContext the PortletContext to load from
path the path of the resource

Public Methods

public Resource createRelative (String relativePath)

This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource.

Parameters
relativePath the relative path (relative to this resource)
Returns
  • the resource handle for the relative resource

public boolean equals (Object obj)

This implementation compares description strings.

public boolean exists ()

This implementation checks PortletContext.getResource.

See Also
  • javax.portlet.PortletContext#getResource(String)

public String getDescription ()

Return a description for this resource, to be used for error output when working with the resource.

Implementations are also encouraged to return this value from their toString method.

public File getFile ()

This implementation delegates to PortletContext.getRealPath, but throws a FileNotFoundException if not found or not resolvable.

Throws
IOException
See Also
  • javax.portlet.PortletContext#getRealPath(String)

public String getFilename ()

This implementation always throws IllegalStateException, assuming that the resource does not have a filename.

public InputStream getInputStream ()

This implementation delegates to PortletContext.getResourceAsStream, but throws a FileNotFoundException if not found.

Throws
IOException
See Also
  • javax.portlet.PortletContext#getResourceAsStream(String)

public final String getPath ()

Return the path for this resource.

public String getPathWithinContext ()

Return the path within the enclosing 'context'.

This is typically path relative to a context-specific root directory, e.g. a ServletContext root or a PortletContext root.

public final PortletContext getPortletContext ()

Return the PortletContext for this resource.

public URL getURL ()

This implementation delegates to PortletContext.getResource, but throws a FileNotFoundException if no resource found.

Throws
IOException
See Also
  • javax.portlet.PortletContext#getResource(String)

public int hashCode ()

This implementation returns the description's hash code.