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