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 String[] server_classes = new String[2+(old_server_classes==null?0:old_server_classes.length)];
100 server_classes[0]="-org.mortbay.jetty.";
101 server_classes[1]="-org.mortbay.util.";
102 if (server_classes!=null)
103 System.arraycopy(old_server_classes, 0, server_classes, 2, old_server_classes.length);
104
105 _context.setServerClasses(server_classes);
106 if(Log.isDebugEnabled())
107 Log.debug("Configure: "+jetty);
108 XmlConfiguration jetty_config=new XmlConfiguration(jetty.getURL());
109 jetty_config.configure(getWebAppContext());
110 }
111 finally
112 {
113 _context.setServerClasses(old_server_classes);
114 }
115 }
116 }
117 }
118
119
120
121
122
123 public void deconfigureWebApp () throws Exception
124 {
125
126 }
127
128 }