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