|
Lines 33-69
Link Here
|
| 33 |
public class WtpDirContext extends FileDirContext { |
33 |
public class WtpDirContext extends FileDirContext { |
| 34 |
// Map<String, File> |
34 |
// Map<String, File> |
| 35 |
private Map virtualMappings; |
35 |
private Map virtualMappings; |
| 36 |
|
36 |
|
| 37 |
// Map<String, File> |
37 |
// Map<String, File> |
| 38 |
private Map tagfileMappings; |
38 |
private Map tagfileMappings; |
| 39 |
|
39 |
|
|
|
40 |
// Map<String, String> |
| 41 |
private Map webResourcesMapping; |
| 42 |
|
| 40 |
private String virtualClasspath; |
43 |
private String virtualClasspath; |
|
|
44 |
|
| 45 |
private String webResources; |
| 41 |
|
46 |
|
| 42 |
/** |
47 |
/** |
| 43 |
* Tomcat digester will automatically set this property to the value of the |
48 |
* Tomcat digester will automatically set this property to the value of the |
| 44 |
* "virtualClasspath" xml attribute. |
49 |
* "virtualClasspath" xml attribute. |
| 45 |
* @param path ; separated list of path elements. |
50 |
* @param path ; separated list of path elements. |
| 46 |
*/ |
51 |
*/ |
| 47 |
public void setVirtualClasspath(String path) { |
52 |
public void setVirtualClasspath(String path) { |
| 48 |
virtualClasspath = path; |
53 |
virtualClasspath = path; |
| 49 |
} |
54 |
} |
| 50 |
|
55 |
|
|
|
56 |
/** |
| 57 |
* Tomcat digester will automatically set this property to the value of the |
| 58 |
* "webResources" xml attribute. |
| 59 |
* @param path ; separated list of path elements. |
| 60 |
*/ |
| 61 |
public void setWebResources(String path) { |
| 62 |
webResources = path; |
| 63 |
} |
| 64 |
|
| 51 |
public void allocate() { |
65 |
public void allocate() { |
| 52 |
super.allocate(); |
66 |
super.allocate(); |
| 53 |
virtualMappings = new Hashtable(); // new Hashtable<String, File>(); |
67 |
virtualMappings = new Hashtable(); // new Hashtable<String, File>(); |
| 54 |
tagfileMappings = new Hashtable(); // new Hashtable<String, File>(); |
68 |
tagfileMappings = new Hashtable(); // new Hashtable<String, File>(); |
| 55 |
|
69 |
webResourcesMapping = new Hashtable(); // new Hashtable<String, String>(); |
|
|
70 |
|
| 56 |
StringTokenizer tkn = new StringTokenizer(virtualClasspath, ";"); |
71 |
StringTokenizer tkn = new StringTokenizer(virtualClasspath, ";"); |
| 57 |
while (tkn.hasMoreTokens()) { |
72 |
while (tkn.hasMoreTokens()) { |
| 58 |
File file = new File(tkn.nextToken(), "META-INF"); |
73 |
File file = new File(tkn.nextToken(), "META-INF"); |
| 59 |
|
74 |
|
| 60 |
if (!file.exists() || !file.isDirectory()) { |
75 |
if (!file.exists() || !file.isDirectory()) { |
| 61 |
continue; |
76 |
continue; |
| 62 |
} |
77 |
} |
| 63 |
scanForTlds(file); |
78 |
scanForTlds(file); |
|
|
79 |
} |
| 80 |
StringTokenizer tknwebResources = new StringTokenizer(webResources, ";"); |
| 81 |
int i = 0; |
| 82 |
while (tknwebResources.hasMoreTokens()) { |
| 83 |
i++; |
| 84 |
String token = tknwebResources.nextToken(); |
| 85 |
webResourcesMapping.put(String.valueOf(i), token); |
| 64 |
} |
86 |
} |
| 65 |
} |
87 |
} |
| 66 |
|
88 |
|
| 67 |
private void scanForTlds(File dir) { |
89 |
private void scanForTlds(File dir) { |
| 68 |
|
90 |
|
| 69 |
File[] files = dir.listFiles(); |
91 |
File[] files = dir.listFiles(); |
|
Lines 108-121
Link Here
|
| 108 |
if (file.exists()) { |
130 |
if (file.exists()) { |
| 109 |
tagfileMappings.put(name, file); |
131 |
tagfileMappings.put(name, file); |
| 110 |
return new FileResourceAttributes(file); |
132 |
return new FileResourceAttributes(file); |
| 111 |
} |
133 |
} |
| 112 |
} |
134 |
} |
| 113 |
} |
135 |
} |
|
|
136 |
Attributes superAttr; |
| 114 |
|
137 |
|
| 115 |
return super.getAttributes(name); |
138 |
try { |
|
|
139 |
superAttr = super.getAttributes(name); |
| 140 |
return superAttr; |
| 141 |
} catch (NamingException ex) { |
| 142 |
superAttr = null; |
| 143 |
} |
| 144 |
for (Object webResourcesDir : webResourcesMapping.values()){ |
| 145 |
String dir = (String) webResourcesDir; |
| 146 |
File f = new File (dir + "/" + name); |
| 147 |
if (f.exists() && f.isFile()) { |
| 148 |
FileResourceAttributes fra = new FileResourceAttributes(f); |
| 149 |
superAttr = fra; |
| 150 |
} |
| 151 |
} |
| 152 |
if (superAttr == null) { |
| 153 |
throw new NamingException(); |
| 154 |
} |
| 155 |
return superAttr; |
| 116 |
} |
156 |
} |
| 117 |
|
157 |
|
| 118 |
protected ArrayList list(File file) { |
158 |
protected ArrayList list(File file) { |
| 119 |
ArrayList entries = super.list(file); |
159 |
ArrayList entries = super.list(file); |
| 120 |
if ("WEB-INF".equals(file.getName())) { |
160 |
if ("WEB-INF".equals(file.getName())) { |
| 121 |
entries.addAll(getVirtualNamingEntries()); |
161 |
entries.addAll(getVirtualNamingEntries()); |
|
Lines 131-145
Link Here
|
| 131 |
} |
171 |
} |
| 132 |
} else if (name.startsWith("/META-INF/tags") && name.endsWith(".tag") |
172 |
} else if (name.startsWith("/META-INF/tags") && name.endsWith(".tag") |
| 133 |
|| name.endsWith(".tagx")) { |
173 |
|| name.endsWith(".tagx")) { |
| 134 |
|
174 |
|
| 135 |
// already loaded tag file |
175 |
// already loaded tag file |
| 136 |
return new FileResource((File) tagfileMappings.get(name)); |
176 |
return new FileResource((File) tagfileMappings.get(name)); |
| 137 |
} |
177 |
} |
| 138 |
|
178 |
|
| 139 |
return super.lookup(name); |
179 |
Object retSuper; |
|
|
180 |
try { |
| 181 |
retSuper = super.lookup(name); |
| 182 |
return retSuper; |
| 183 |
} catch (NamingException ex) { |
| 184 |
retSuper = null; |
| 185 |
} |
| 186 |
|
| 187 |
for (Object webResourcesDit : webResourcesMapping.values()){ |
| 188 |
String dir = (String) webResourcesDit; |
| 189 |
File f = new File (dir + "/" + name); |
| 190 |
if (f.exists() && f.isFile()) { |
| 191 |
FileResource fr = new FileResource(f); |
| 192 |
retSuper = fr; |
| 193 |
} |
| 194 |
} |
| 195 |
if (retSuper == null) { |
| 196 |
throw new NamingException(); |
| 197 |
} |
| 198 |
return retSuper; |
| 140 |
} |
199 |
} |
| 141 |
|
200 |
|
| 142 |
private List getVirtualNamingEntries() { |
201 |
private List getVirtualNamingEntries() { |
| 143 |
List virtual = new ArrayList(); |
202 |
List virtual = new ArrayList(); |
| 144 |
for (Iterator iter = virtualMappings.keySet().iterator(); iter |
203 |
for (Iterator iter = virtualMappings.keySet().iterator(); iter |
| 145 |
.hasNext();) { |
204 |
.hasNext();) { |