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