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