8000 Change the TldProvider interface so that it returns tld entry with gr… · javaee/jstl-api@7b562a9 · GitHub < 8000 link rel="icon" class="js-site-favicon" type="image/svg+xml" href="https://github.githubassets.com/favicons/favicon.svg" data-base-href="https://github.githubassets.com/favicons/favicon">
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Commit 7b562a9

Browse files
author
Kin Man Chung
committed
Change the TldProvider interface so that it returns tld entry with grouping
under the same jar name. This allows the implementation not to open the jar too many times when there are multiple tld in a given jar. Reviewed by Jan Luehe. Original author: swchan2 Date: 2008-05-27 16:47:24.940543+00:00 svn path=/trunk/; revision=18
1 parent a07341c commit 7b562a9

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

impl/src/main/java/org/glassfish/jstl/integration/GlassFishTldProvider.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
import java.net.URI;
4242
import java.net.MalformedURLException;
4343
import java.util.ArrayList;
44+
import java.util.HashMap;
4445
import java.util.List;
45-
import java.util.Collections;
46+
import java.util.Map;
4647
import java.util.regex.Pattern;
4748

4849
import org.glassfish.api.web.TldProvider;
@@ -68,15 +69,15 @@ public class GlassFishTldProvider implements TldProvider, PostConstruct {
6869
@Inject
6970
ModulesRegistry registry;
7071

71-
private List<URL> tldList = Collections.emptyList();
72-
72+
private Map<URL, List<String>> tldMap = new HashMap<URL, List<String>>();
73+
7374
/**
74-
* Get a list of URL that corresponding to Tld entries
75+
* Get a Map with key URL and value as a list of tld entries.
7576
*/
76-
public URL[] getTldURLs() {
77-
return tldList.toArray(new URL[tldList.size()]);
77+
public Map<URL, List<String>> getTldMap() {
78+
return (Map<URL, List<String>>)((HashMap)tldMap).clone();
7879
}
79-
80+
8081
public void postConstruct() {
8182
URL[] urls = null;
8283
Module m = registry.find(getClass());
@@ -102,9 +103,15 @@ public void postConstruct() {
102103
"] is not of type URLClassLoader");
103104
}
104105
}
105-
if (urls!=null) {
106+
107+
if (urls != null) {
106108
Pattern pattern = Pattern.compile("META-INF/.*\\.tld");
107-
tldList = JarURLPattern.getJarEntryURLs(urls, pattern);
109+
for (URL url : urls) {
110+
List entries = JarURLPattern.getJarEntries(url, pattern);
111+
if (entries != null && entries.size() > 0) {
112+
tldMap.put(url, entries);
113+
}
114+
}
108115
}
109116
}
110117
}

0 commit comments

Comments
 (0)
0