1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.eclipse.jetty.webapp;
16
17 import java.util.List;
18
19 import org.eclipse.jetty.util.resource.Resource;
20
21
22
23
24
25
26
27
28 public class FragmentConfiguration implements Configuration
29 {
30 public final static String FRAGMENT_RESOURCES="org.eclipse.jetty.webFragments";
31
32 public void preConfigure(WebAppContext context) throws Exception
33 {
34 if (!context.isConfigurationDiscovered())
35 return;
36
37 WebXmlProcessor processor = (WebXmlProcessor)context.getAttribute(WebXmlProcessor.WEB_PROCESSOR);
38 if (processor == null)
39 {
40 processor = new WebXmlProcessor (context);
41 context.setAttribute(WebXmlProcessor.WEB_PROCESSOR, processor);
42 }
43
44
45
46 parseWebFragments(context, processor);
47
48
49
50 }
51
52 public void configure(WebAppContext context) throws Exception
53 {
54 if (!context.isConfigurationDiscovered())
55 return;
56
57
58
59 WebXmlProcessor processor = (WebXmlProcessor)context.getAttribute(WebXmlProcessor.WEB_PROCESSOR);
60 if (processor == null)
61 {
62 processor = new WebXmlProcessor (context);
63 context.setAttribute(WebXmlProcessor.WEB_PROCESSOR, processor);
64 }
65
66 processor.processFragments();
67 }
68
69 public void deconfigure(WebAppContext context) throws Exception
70 {
71
72 }
73
74 public void postConfigure(WebAppContext context) throws Exception
75 {
76 context.setAttribute(FRAGMENT_RESOURCES, null);
77 }
78
79
80
81
82
83
84
85 public void parseWebFragments (final WebAppContext context, final WebXmlProcessor processor) throws Exception
86 {
87 List<Resource> frags = (List<Resource>)context.getAttribute(FRAGMENT_RESOURCES);
88 if (frags!=null)
89 {
90 for (Resource frag : frags)
91 {
92 processor.parseFragment(Resource.newResource("jar:"+frag.getURL()+"!/META-INF/web-fragment.xml"));
93 }
94 }
95 }
96
97 }