1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.components.util.system;
18
19 import java.io.File;
20 import java.net.MalformedURLException;
21 import java.net.URL;
22
23 /***
24 * <p>
25 * ClassLoaderSystemResourceUtilImpl
26 * </p>
27 *
28 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
29 * @version $Id: ClassLoaderSystemResourceUtilImpl.java 516448 2007-03-09 16:25:47Z ate $
30 *
31 */
32 public class ClassLoaderSystemResourceUtilImpl implements SystemResourceUtil
33 {
34
35 private ClassLoader cl;
36
37 /***
38 *
39 * @param cl ClassLoader that will be used to locate a resource
40 */
41 public ClassLoaderSystemResourceUtilImpl(ClassLoader cl)
42 {
43 this.cl = cl;
44 }
45
46
47 /***
48 * For this implementation, always returns "/"
49 */
50 public String getSystemRoot()
51 {
52 return "/";
53 }
54
55 /***
56 * @see org.apache.jetspeed.components.util.system.SystemResourceUtil#getURL(java.lang.String)
57 */
58 public URL getURL(String relativePath) throws MalformedURLException
59 {
60 return cl.getResource(convertFSSeperatorToSlash(relativePath));
61 }
62
63 private String convertFSSeperatorToSlash(String path)
64 {
65 return path.replace(File.separatorChar, '/');
66 }
67
68 }