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 extends AbstractConfiguration
29 {
30 public final static String FRAGMENT_RESOURCES="org.eclipse.jetty.webFragments";
31
32 @Override
33 public void preConfigure(WebAppContext context) throws Exception
34 {
35 if (!context.isConfigurationDiscovered())
36 return;
37
38
39 findWebFragments(context, context.getMetaData());
40
41 }
42
43 @Override
44 public void configure(WebAppContext context) throws Exception
45 {
46 if (!context.isConfigurationDiscovered())
47 return;
48
49
50 context.getMetaData().orderFragments();
51 }
52
53 @Override
54 public void postConfigure(WebAppContext context) throws Exception
55 {
56 context.setAttribute(FRAGMENT_RESOURCES, null);
57 }
58
59
60
61
62
63
64
65 public void findWebFragments (final WebAppContext context, final MetaData metaData) throws Exception
66 {
67 List<Resource> frags = (List<Resource>)context.getAttribute(FRAGMENT_RESOURCES);
68 if (frags!=null)
69 {
70 for (Resource frag : frags)
71 {
72 metaData.addFragment(frag, Resource.newResource("jar:"+frag.getURL()+"!/META-INF/web-fragment.xml"));
73 }
74 }
75 }
76 }