1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mortbay.jetty.plugin;
17
18 import java.io.File;
19 import java.util.List;
20
21 import org.mortbay.jetty.plus.webapp.EnvConfiguration;
22 import org.mortbay.jetty.webapp.Configuration;
23 import org.mortbay.jetty.webapp.JettyWebXmlConfiguration;
24 import org.mortbay.jetty.webapp.TagLibConfiguration;
25 import org.mortbay.jetty.webapp.WebAppContext;
26 import org.mortbay.jetty.webapp.WebInfConfiguration;
27
28
29
30
31
32
33 public class Jetty6PluginWebAppContext extends WebAppContext
34 {
35 private List classpathFiles;
36 private File jettyEnvXmlFile;
37 private File webXmlFile;
38 private WebInfConfiguration webInfConfig = new WebInfConfiguration();
39 private EnvConfiguration envConfig = new EnvConfiguration();
40 private Jetty6MavenConfiguration mvnConfig = new Jetty6MavenConfiguration();
41 private JettyWebXmlConfiguration jettyWebConfig = new JettyWebXmlConfiguration();
42 private TagLibConfiguration tagConfig = new TagLibConfiguration();
43 private Configuration[] configs = new Configuration[]{webInfConfig,envConfig, mvnConfig, jettyWebConfig, tagConfig};
44 private String contextPath = null;
45
46 public Jetty6PluginWebAppContext ()
47 {
48 super();
49 setConfigurations(configs);
50 }
51
52 public void setContextPath(String path)
53 {
54 this.contextPath = path;
55 }
56
57 public String getContextPath()
58 {
59 return contextPath;
60 }
61
62 public void setClassPathFiles(List classpathFiles)
63 {
64 this.classpathFiles = classpathFiles;
65 }
66
67 public List getClassPathFiles()
68 {
69 return this.classpathFiles;
70 }
71
72 public void setWebXmlFile(File webXmlFile)
73 {
74 this.webXmlFile = webXmlFile;
75 }
76
77 public File getWebXmlFile()
78 {
79 return this.webXmlFile;
80 }
81
82 public void setJettyEnvXmlFile (File jettyEnvXmlFile)
83 {
84 this.jettyEnvXmlFile = jettyEnvXmlFile;
85 }
86
87 public File getJettyEnvXmlFile()
88 {
89 return this.jettyEnvXmlFile;
90 }
91
92 public void configure ()
93 {
94 if (this.contextPath != null)
95 super.setContextPath(this.contextPath);
96
97 setConfigurations(configs);
98 mvnConfig.setClassPathConfiguration (classpathFiles);
99 mvnConfig.setWebXml (webXmlFile);
100 try
101 {
102 if (this.jettyEnvXmlFile != null)
103 envConfig.setJettyEnvXml(this.jettyEnvXmlFile.toURL());
104 }
105 catch (Exception e)
106 {
107 throw new RuntimeException(e);
108 }
109 }
110
111
112 public void doStart () throws Exception
113 {
114 setShutdown(false);
115 super.doStart();
116 }
117
118 public void doStop () throws Exception
119 {
120 setShutdown(true);
121
122 Thread.currentThread().sleep(500L);
123 super.doStop();
124 }
125 }