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.Map;
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
49 @Override
50 public void postConfigure(WebAppContext context) throws Exception
51 {
52 context.setAttribute(FRAGMENT_RESOURCES, null);
53 }
54
55
56
57
58
59
60
61 public void findWebFragments (final WebAppContext context, final MetaData metaData) throws Exception
62 {
63 @SuppressWarnings("unchecked")
64 Map<Resource, Resource> frags = (Map<Resource,Resource>)context.getAttribute(FRAGMENT_RESOURCES);
65 if (frags!=null)
66 {
67 for (Resource key : frags.keySet())
68 {
69 if (key.isDirectory())
70 {
71 metaData.addFragment(key, frags.get(key));
72 }
73 else
74 {
75 metaData.addFragment(key, frags.get(key));
76 }
77 }
78 }
79 }
80 }