1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.eclipse.jetty.webapp;
15
16 import org.eclipse.jetty.util.log.Log;
17 import org.eclipse.jetty.util.resource.Resource;
18 import org.eclipse.jetty.xml.XmlConfiguration;
19
20
21
22
23
24
25
26
27
28
29
30 public class JettyWebXmlConfiguration implements Configuration
31 {
32 public void preConfigure(WebAppContext context) throws Exception
33 {
34
35
36 }
37
38
39
40
41
42
43
44 public void configure (WebAppContext context) throws Exception
45 {
46
47 if (context.isStarted())
48 {
49 if (Log.isDebugEnabled()){Log.debug("Cannot configure webapp after it is started");}
50 return;
51 }
52
53 if(Log.isDebugEnabled())
54 Log.debug("Configuring web-jetty.xml");
55
56 Resource web_inf = context.getWebInf();
57
58 if(web_inf!=null&&web_inf.isDirectory())
59 {
60
61 Resource jetty=web_inf.addPath("jetty7-web.xml");
62 if(!jetty.exists())
63 jetty=web_inf.addPath("jetty-web.xml");
64 if(!jetty.exists())
65 jetty=web_inf.addPath("web-jetty.xml");
66
67 if(jetty.exists())
68 {
69
70 String[] old_server_classes = context.getServerClasses();
71 try
72 {
73 context.setServerClasses(null);
74 if(Log.isDebugEnabled())
75 Log.debug("Configure: "+jetty);
76 XmlConfiguration jetty_config=new XmlConfiguration(jetty.getURL());
77 jetty_config.configure(context);
78 }
79 finally
80 {
81 if (context.getServerClasses()==null)
82 context.setServerClasses(old_server_classes);
83 }
84 }
85 }
86 }
87
88
89 public void postConfigure(WebAppContext context) throws Exception
90 {
91
92
93 }
94
95
96 public void deconfigure(WebAppContext context) throws Exception
97 {
98
99
100 }
101 }