Commits

Stephen McKamey committed c9ec72a

minor cleanup that had to wait until v0.8.2

  • Participants
  • Parent commits 1a7edee

Comments (0)

Files changed (4)

File duel-runtime/pom.xml

 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-runtime</artifactId>
-	<version>0.8.1</version>
+	<version>0.8.2</version>
 	<packaging>jar</packaging>
 
 	<name>DUEL Runtime</name>

File duel-runtime/src/main/java/org/duelengine/duel/CDNLinkInterceptor.java

 public class CDNLinkInterceptor implements LinkInterceptor {
 
 	private static final Logger log = LoggerFactory.getLogger(CDNLinkInterceptor.class);
-	private final boolean isDevMode;
-	private final String cdnHost;
+	protected final boolean isDevMode;
+	protected final String cdnHost;
 	private final Map<String, String> cdnMap;
 
 	/**
 	 * @param isDevMode uses normal paths unless compacted form has a dev form (e.g., "/foo.js" => "/foo.min.js" => "/foo.test.js", else "/foo.js")
 	 * @throws URISyntaxException
 	 */
-	public CDNLinkInterceptor(String cdnHost, ResourceBundle cdnBundle, boolean isDevMode) throws URISyntaxException {
+	public CDNLinkInterceptor(String cdnHost, ResourceBundle cdnBundle, boolean isDevMode)
+			throws URISyntaxException {
+
 		this(cdnHost, bundleAsMap(cdnBundle, isDevMode), isDevMode);
 	}
 
 	 * @param isDevMode uses normal paths unless compacted form has a dev form (e.g., "/foo.js" => "/foo.min.js" => "/foo.test.js", else "/foo.js")
 	 * @throws URISyntaxException
 	 */
-	public CDNLinkInterceptor(String cdnHost, Map<String, String> cdnMap, boolean isDevMode) throws URISyntaxException {
+	public CDNLinkInterceptor(String cdnHost, Map<String, String> cdnMap, boolean isDevMode)
+			throws URISyntaxException {
 
 		if (cdnMap == null) {
 			cdnMap = Collections.emptyMap();

File duel-staticapps/pom.xml

 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-staticapps</artifactId>
-	<version>0.8.1</version>
+	<version>0.8.2</version>
 	<packaging>jar</packaging>
 
 	<name>DUEL Static Apps</name>

File duel-staticapps/src/main/java/org/duelengine/duel/staticapps/StaticLinkInterceptor.java

 class StaticLinkInterceptor extends CDNLinkInterceptor {
 
 	private final Map<String, String> cache = new HashMap<String, String>();
-	private final ResourceBundle linksBundle;
-	private final boolean isDevMode;
+	private final Map<String, String> linksBundle;
 	private final int cdnHostPrefix;
 
 	public StaticLinkInterceptor(String cdnHost, ResourceBundle cdnBundle, ResourceBundle linksBundle, boolean isDevMode)
 			throws URISyntaxException {
 
+		this(cdnHost, bundleAsMap(cdnBundle, isDevMode), bundleAsMap(linksBundle, isDevMode), isDevMode);
+	}
+
+	public StaticLinkInterceptor(String cdnHost, Map<String, String> cdnBundle, Map<String, String> linksBundle, boolean isDevMode)
+			throws URISyntaxException {
+
 		super(cdnHost, cdnBundle, isDevMode);
 
-		// TODO: replace with: bundleAsMap(linksBundle, isDevMode)
 		this.linksBundle = linksBundle;
-		// TODO: replace with super.isDevMode
-		this.isDevMode = isDevMode;
-
-		this.cdnHostPrefix = (cdnHost == null) ? 0 : cdnHost.length();
+		this.cdnHostPrefix = cdnHost.length();
 	}
 
 	public Map<String, String> getLinkCache() {
 		cache.put(url, cdnURL);
 
 		// recursively transform and cache child links
-		if (linksBundle != null) {
-			if (linksBundle.containsKey(url)) {
-				String childLinks = linksBundle.getString(url);
-				if (childLinks != null && !childLinks.isEmpty()) {
-					for (String child : childLinks.split("\\|")) {
-						if (child == null || child.isEmpty()) {
-							continue;
-						}
+		if (linksBundle.containsKey(url)) {
+			String childLinks = linksBundle.get(url);
+			if (childLinks != null && !childLinks.isEmpty()) {
+				for (String child : childLinks.split("\\|")) {
+					if (child == null || child.isEmpty()) {
+						continue;
+					}
 
-						// ignore result, we only care about caching
-						this.transformURL(child);
-					}
+					// ignore result, we only care about caching
+					this.transformURL(child);
 				}
 			}
+		}
 
-			if (isDevMode && cdnURL.length() > cdnHostPrefix && linksBundle.containsKey(cdnURL.substring(cdnHostPrefix))) {
-				// note must trim the CDN host to match
-				String childLinks = linksBundle.getString(cdnURL.substring(cdnHostPrefix));
-				if (childLinks != null && !childLinks.isEmpty()) {
-					for (String child : childLinks.split("\\|")) {
-						if (child == null || child.isEmpty()) {
-							continue;
-						}
+		if (isDevMode && (cdnURL.length() > cdnHostPrefix) && linksBundle.containsKey(cdnURL.substring(cdnHostPrefix))) {
+			// note must trim the CDN host to match
+			String childLinks = linksBundle.get(cdnURL.substring(cdnHostPrefix));
+			if (childLinks != null && !childLinks.isEmpty()) {
+				for (String child : childLinks.split("\\|")) {
+					if (child == null || child.isEmpty()) {
+						continue;
+					}
 
-						// ignore result, we only care about caching
-						this.transformURL(child);
-					}
+					// ignore result, we only care about caching
+					this.transformURL(child);
 				}
 			}
 		}