1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.view.facelets.compiler; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
import java.net.URL; |
23 | |
import java.util.ArrayList; |
24 | |
import java.util.Collection; |
25 | |
import java.util.List; |
26 | |
|
27 | |
import javax.faces.context.ExternalContext; |
28 | |
import org.apache.myfaces.shared.config.MyfacesConfig; |
29 | |
|
30 | |
import org.apache.myfaces.shared.util.ClassUtils; |
31 | |
import org.apache.myfaces.spi.FaceletConfigResourceProvider; |
32 | |
import org.apache.myfaces.util.ContainerUtils; |
33 | |
import org.apache.myfaces.config.util.GAEUtils; |
34 | |
import org.apache.myfaces.view.facelets.util.Classpath; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
public class DefaultFaceletConfigResourceProvider extends FaceletConfigResourceProvider |
42 | |
{ |
43 | |
private static final String META_INF_PREFIX = "META-INF/"; |
44 | |
|
45 | |
private static final String FACELET_TAGLIB_SUFFIX = ".taglib.xml"; |
46 | |
|
47 | |
public DefaultFaceletConfigResourceProvider() |
48 | |
{ |
49 | 0 | super(); |
50 | 0 | } |
51 | |
|
52 | |
@Override |
53 | |
public Collection<URL> getFaceletTagLibConfigurationResources( |
54 | |
ExternalContext context) throws IOException |
55 | |
{ |
56 | 0 | List<URL> urlSet = new ArrayList<URL>(); |
57 | |
|
58 | 0 | String jarFilesToScanParam = MyfacesConfig.getCurrentInstance(context).getGaeJsfJarFiles(); |
59 | 0 | jarFilesToScanParam = jarFilesToScanParam != null ? jarFilesToScanParam.trim() : null; |
60 | 0 | if (ContainerUtils.isRunningOnGoogleAppEngine(context) && |
61 | |
jarFilesToScanParam != null && |
62 | |
jarFilesToScanParam.length() > 0) |
63 | |
{ |
64 | 0 | Collection<URL> urlsGAE = GAEUtils.searchInWebLib( |
65 | |
context, getClassLoader(), jarFilesToScanParam, META_INF_PREFIX, FACELET_TAGLIB_SUFFIX); |
66 | 0 | if (urlsGAE != null) |
67 | |
{ |
68 | 0 | urlSet.addAll(urlsGAE); |
69 | |
} |
70 | 0 | } |
71 | |
else |
72 | |
{ |
73 | |
|
74 | 0 | URL[] urls = Classpath.search(getClassLoader(), META_INF_PREFIX, FACELET_TAGLIB_SUFFIX); |
75 | 0 | for (int i = 0; i < urls.length; i++) |
76 | |
{ |
77 | 0 | urlSet.add(urls[i]); |
78 | |
} |
79 | |
} |
80 | 0 | return urlSet; |
81 | |
} |
82 | |
|
83 | |
private ClassLoader getClassLoader() |
84 | |
{ |
85 | 0 | ClassLoader loader = ClassUtils.getContextClassLoader(); |
86 | 0 | if (loader == null) |
87 | |
{ |
88 | 0 | loader = this.getClass().getClassLoader(); |
89 | |
} |
90 | 0 | return loader; |
91 | |
} |
92 | |
} |