diff --git a/pom.xml b/pom.xml
index a90aa22..cd39af1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,6 +97,12 @@
3.1.1
test
+
+ org.webjars.bower
+ js-base64
+ 2.3.2
+ test
+
diff --git a/src/main/java/org/webjars/WebJarVersionLocator.java b/src/main/java/org/webjars/WebJarVersionLocator.java
index 6cd6803..dcc4e3c 100644
--- a/src/main/java/org/webjars/WebJarVersionLocator.java
+++ b/src/main/java/org/webjars/WebJarVersionLocator.java
@@ -5,6 +5,9 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
@@ -25,6 +28,9 @@ public class WebJarVersionLocator {
private static final String NPM = "org.webjars.npm/";
private static final String PLAIN = "org.webjars/";
private static final String POM_PROPERTIES = "/pom.properties";
+ private static final String LOCATOR_PROPERTIES = "META-INF/resources/webjars-locator.properties";
+
+ private static final String CACHE_KEY_PREFIX = "version-";
private static final ClassLoader LOADER = WebJarVersionLocator.class.getClassLoader();
@@ -32,10 +38,12 @@ public class WebJarVersionLocator {
public WebJarVersionLocator() {
this.cache = new WebJarCacheDefault(new ConcurrentHashMap<>());
+ readLocatorProperties();
}
WebJarVersionLocator(WebJarCache cache) {
this.cache = cache;
+ readLocatorProperties();
}
/**
@@ -83,7 +91,7 @@ public String path(final String webJarName, final String exactPath) {
*/
@Nullable
public String version(final String webJarName) {
- final String cacheKey = "version-" + webJarName;
+ final String cacheKey = CACHE_KEY_PREFIX + webJarName;
final Optional optionalVersion = cache.computeIfAbsent(cacheKey, (key) -> {
InputStream resource = LOADER.getResourceAsStream(PROPERTIES_ROOT + NPM + webJarName + POM_PROPERTIES);
if (resource == null) {
@@ -126,6 +134,36 @@ public String version(final String webJarName) {
return optionalVersion.orElse(null);
}
+ private void readLocatorProperties() {
+ try {
+ Enumeration resources = LOADER.getResources(LOCATOR_PROPERTIES);
+ while (resources.hasMoreElements()) {
+ URL resourceUrl = resources.nextElement();
+ try (InputStream resource = resourceUrl.openStream()) {
+ Properties properties = new Properties();
+ properties.load(resource);
+ for (Map.Entry