Top Description Fields Constructors Methods
org.apache.catalina.webresources

public Class DirResourceSet

extends AbstractFileResourceSet
Class Inheritance
Imports
java.io.File, .FileInputStream, .IOException, .InputStream, java.nio.file.Files, .StandardCopyOption, java.util.Set, java.util.jar.Manifest, org.apache.catalina.LifecycleException, .WebResource, .WebResourceRoot, .WebResourceRoot.ResourceSetType, org.apache.catalina.util.ResourceSet, org.apache.juli.logging.Log, .LogFactory

Represents a org.apache.catalina.WebResourceSet based on a directory.

Field Summary

Modifier and TypeField and Description
private static final Log
Inherited from org.apache.catalina.webresources.AbstractFileResourceSet:
EMPTY_STRING_ARRAY

Constructor Summary

AccessConstructor and Description
public
DirResourceSet()

A no argument constructor is required for this to work with the digester.

public
DirResourceSet(WebResourceRoot root, String
The path within the web application at which this org.apache.catalina.WebResourceSet will be mounted. For example, to add a directory of JARs to a web application, the directory would be mounted at "/WEB-INF/lib/"
webAppMount
,
String
The absolute path to the directory on the file system from which the resources will be served.
base
,
String
The path within this new org.apache.catalina.WebResourceSet where resources will be served from.
internalPath
)

Creates a new org.apache.catalina.WebResourceSet based on a directory.

Method Summary

Modifier and TypeMethod and Description
protected void
public WebResource
getResource(String
The path for the resource of interest relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceSet.getResource.

Obtain the object that represents the resource at the given path.

protected void
initInternal()

Overrides org.apache.catalina.webresources.AbstractFileResourceSet.initInternal.

Sub-classes implement this method to perform any instance initialisation required.

public String[]
list(String
The path for the resource of interest relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceSet.list.

Obtain the list of the names of all of the files and directories located in the specified directory.

public Set<String>
listWebAppPaths(String
The path for the resource of interest relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceSet.listWebAppPaths.

Obtain the Set of the web applications pathnames of all of the files and directories located in the specified directory.

public boolean
mkdir(String
The path for the new resource to create relative to the root of the web application. It must start with '/'.
path
)

Implements org.apache.catalina.WebResourceSet.mkdir.

Create a new directory at the given path.

public boolean
write(String
The path to be used for the new Resource. It is relative to the root of the web application and must start with '/'.
path
,
InputStream
The InputStream that will provide the content for the new Resource.
is
,
boolean
If true and the resource already exists it will be overwritten. If false and the resource already exists the write will fail.
overwrite
)

Implements org.apache.catalina.WebResourceSet.write.

Create a new resource at the requested path using the provided InputStream.

Inherited from org.apache.catalina.webresources.AbstractFileResourceSet:
filegcgetBaseUrlgetFileBaseisReadOnlylogIgnoredSymlinksetReadOnly

Field Detail

logback to summary
private static final Log log

Hides org.apache.catalina.webresources.AbstractFileResourceSet.log.

Constructor Detail

DirResourceSetback to summary
public DirResourceSet()

A no argument constructor is required for this to work with the digester.

DirResourceSetback to summary
public DirResourceSet(WebResourceRoot root, String webAppMount, String base, String internalPath)

Creates a new org.apache.catalina.WebResourceSet based on a directory.

Parameters
root:WebResourceRoot

The WebResourceRoot this new org.apache.catalina.WebResourceSet will be added to.

webAppMount:String

The path within the web application at which this org.apache.catalina.WebResourceSet will be mounted. For example, to add a directory of JARs to a web application, the directory would be mounted at "/WEB-INF/lib/"

base:String

The absolute path to the directory on the file system from which the resources will be served.

internalPath:String

The path within this new org.apache.catalina.WebResourceSet where resources will be served from.

Method Detail

checkTypeback to summary
protected void checkType(File file)

Implements abstract org.apache.catalina.webresources.AbstractFileResourceSet.checkType.

Annotations
@Override
getResourceback to summary
public WebResource getResource(String path)

Implements org.apache.catalina.WebResourceSet.getResource.

Doc from org.apache.catalina.WebResourceSet.getResource.

Obtain the object that represents the resource at the given path. Note the resource at that path may not exist.

Parameters
path:String

The path for the resource of interest relative to the root of the web application. It must start with '/'.

Returns:WebResource

The object that represents the resource at the given path

Annotations
@Override
initInternalback to summary
protected void initInternal() throws LifecycleException

Overrides org.apache.catalina.webresources.AbstractFileResourceSet.initInternal.

Doc from org.apache.catalina.util.LifecycleBase.initInternal.

Sub-classes implement this method to perform any instance initialisation required.

Annotations
@Override
Exceptions
LifecycleException:
If the initialisation fails
listback to summary
public String[] list(String path)

Implements org.apache.catalina.WebResourceSet.list.

Doc from org.apache.catalina.WebResourceSet.list.

Obtain the list of the names of all of the files and directories located in the specified directory.

Parameters
path:String

The path for the resource of interest relative to the root of the web application. It must start with '/'.

Returns:String[]

The list of resources. If path does not refer to a directory then a zero length array will be returned.

Annotations
@Override
listWebAppPathsback to summary
public Set<String> listWebAppPaths(String path)

Implements org.apache.catalina.WebResourceSet.listWebAppPaths.

Doc from org.apache.catalina.WebResourceSet.listWebAppPaths.

Obtain the Set of the web applications pathnames of all of the files and directories located in the specified directory. Paths representing directories will end with a "/" character.

Parameters
path:String

The path for the resource of interest relative to the root of the web application. It must start with '/'.

Returns:Set<String>

The Set of resources. If path does not refer to a directory then an empty set will be returned.

Annotations
@Override
mkdirback to summary
public boolean mkdir(String path)

Implements org.apache.catalina.WebResourceSet.mkdir.

Doc from org.apache.catalina.WebResourceSet.mkdir.

Create a new directory at the given path.

Parameters
path:String

The path for the new resource to create relative to the root of the web application. It must start with '/'.

Returns:boolean

true if the directory was created, otherwise false

Annotations
@Override
writeback to summary
public boolean write(String path, InputStream is, boolean overwrite)

Implements org.apache.catalina.WebResourceSet.write.

Doc from org.apache.catalina.WebResourceSet.write.

Create a new resource at the requested path using the provided InputStream.

Parameters
path:String

The path to be used for the new Resource. It is relative to the root of the web application and must start with '/'.

is:InputStream

The InputStream that will provide the content for the new Resource.

overwrite:boolean

If true and the resource already exists it will be overwritten. If false and the resource already exists the write will fail.

Returns:boolean

true if and only if the new Resource is written

Annotations
@Override