1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.ant;
20
21 import java.io.File;
22 import java.util.Iterator;
23 import java.util.List;
24
25 import org.eclipse.jetty.ant.utils.TaskLog;
26 import org.eclipse.jetty.util.log.Log;
27 import org.eclipse.jetty.util.log.Logger;
28 import org.eclipse.jetty.webapp.WebAppClassLoader;
29 import org.eclipse.jetty.webapp.WebAppContext;
30 import org.eclipse.jetty.webapp.WebXmlConfiguration;
31
32
33
34
35
36
37
38
39 public class AntWebXmlConfiguration extends WebXmlConfiguration
40 {
41 private static final Logger LOG = Log.getLogger(WebXmlConfiguration.class);
42
43
44
45
46 private List classPathFiles;
47
48
49 private File webAppBaseDir;
50
51
52 private File webXmlFile;
53
54 private File webDefaultXmlFile;
55
56 public AntWebXmlConfiguration() throws ClassNotFoundException
57 {
58 }
59
60 public File getWebDefaultXmlFile()
61 {
62 return this.webDefaultXmlFile;
63 }
64
65 public void setWebDefaultXmlFile(File webDefaultXmlfile)
66 {
67 this.webDefaultXmlFile = webDefaultXmlfile;
68 }
69
70 public void setClassPathFiles(List classPathFiles)
71 {
72 this.classPathFiles = classPathFiles;
73 }
74
75 public void setWebAppBaseDir(File webAppBaseDir)
76 {
77 this.webAppBaseDir = webAppBaseDir;
78 }
79
80 public void setWebXmlFile(File webXmlFile)
81 {
82 this.webXmlFile = webXmlFile;
83
84 if (webXmlFile.exists())
85 {
86 TaskLog.log("web.xml file = " + webXmlFile);
87 }
88 }
89
90
91
92
93
94
95
96 public void configure(WebAppContext context) throws Exception
97 {
98 if (context.isStarted())
99 {
100 TaskLog.log("Cannot configure webapp after it is started");
101 return;
102 }
103
104
105 if (webXmlFile.exists())
106 {
107 context.setDescriptor(webXmlFile.getCanonicalPath());
108 }
109
110 super.configure(context);
111
112 Iterator filesIterator = classPathFiles.iterator();
113
114 while (filesIterator.hasNext())
115 {
116 File classPathFile = (File) filesIterator.next();
117 if (classPathFile.exists())
118 {
119 ((WebAppClassLoader) context.getClassLoader())
120 .addClassPath(classPathFile.getCanonicalPath());
121 }
122 }
123 }
124 }