MCPcopy Index your code
hub / github.com/apache/tomcat / DirResourceSet

Class DirResourceSet

java/org/apache/catalina/webresources/DirResourceSet.java:47–422  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

45 * Represents a {@link org.apache.catalina.WebResourceSet} based on a directory.
46 */
47public class DirResourceSet extends AbstractFileResourceSet implements WebResourceLockSet {
48
49 private static final Log log = LogFactory.getLog(DirResourceSet.class);
50
51 private KeyedReentrantReadWriteLock resourceLocksByPath = new KeyedReentrantReadWriteLock();
52
53
54 /**
55 * A no argument constructor is required for this to work with the digester.
56 */
57 public DirResourceSet() {
58 super("/");
59 }
60
61 /**
62 * Creates a new {@link org.apache.catalina.WebResourceSet} based on a directory.
63 *
64 * @param root The {@link WebResourceRoot} this new {@link org.apache.catalina.WebResourceSet} will be added
65 * to.
66 * @param webAppMount The path within the web application at which this {@link org.apache.catalina.WebResourceSet}
67 * will be mounted. For example, to add a directory of JARs to a web application, the
68 * directory would be mounted at "/WEB-INF/lib/"
69 * @param base The absolute path to the directory on the file system from which the resources will be
70 * served.
71 * @param internalPath The path within this new {@link org.apache.catalina.WebResourceSet} where resources will be
72 * served from.
73 */
74 public DirResourceSet(WebResourceRoot root, String webAppMount, String base, String internalPath) {
75 super(internalPath);
76 setRoot(root);
77 setWebAppMount(webAppMount);
78 setBase(base);
79
80 if (root.getContext().getAddWebinfClassesResources()) {
81 File f = new File(base, internalPath);
82 f = new File(f, "/WEB-INF/classes/META-INF/resources");
83
84 if (f.isDirectory()) {
85 root.createWebResourceSet(ResourceSetType.RESOURCE_JAR, "/", f.getAbsolutePath(), null, "/");
86 }
87 }
88
89 if (getRoot().getState().isAvailable()) {
90 try {
91 start();
92 } catch (LifecycleException e) {
93 throw new IllegalStateException(e);
94 }
95 }
96 }
97
98
99 @Override
100 public WebResource getResource(String path) {
101 checkPath(path);
102 String webAppMount = getWebAppMount();
103 WebResourceRoot root = getRoot();
104 boolean readOnly = isReadOnly();

Callers

nothing calls this directly

Calls 1

getLogMethod · 0.95

Tested by

no test coverage detected