Commits

Stephen McKamey committed ee1cc29

improving reloading of CDN references; reving to v0.6.3

Comments (0)

Files changed (6)

duel-compiler/pom.xml

 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-compiler</artifactId>
-	<version>0.6.2</version>
+	<version>0.6.3</version>
 	<packaging>jar</packaging>
 
 	<name>DUEL Compiler</name>
 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-js</artifactId>
-	<version>0.6.2</version>
+	<version>0.6.3</version>
 	<packaging>pom</packaging>
 
 	<name>DUEL Client Scripts</name>

duel-js/target/duel.js

 
 /**
  * @fileoverview duel.js: client-side engine
- * @version DUEL v0.6.2 http://duelengine.org
+ * @version DUEL v0.6.3 http://duelengine.org
  * 
  * Copyright (c) 2006-2011 Stephen M. McKamey
  * Licensed under the MIT License (http://duelengine.org/license.txt)

duel-maven-plugin/pom.xml

 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-maven-plugin</artifactId>
-	<version>0.6.2</version>
+	<version>0.6.3</version>
 	<packaging>maven-plugin</packaging>
 
 	<name>DUEL Maven Plugin</name>

duel-runtime/pom.xml

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

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

 	 * @throws URISyntaxException
 	 */
 	public CDNLinkInterceptor(String cdnHost, ResourceBundle cdnBundle, boolean isDevMode) throws URISyntaxException {
-		this(cdnHost, bundleAsMap(cdnBundle), isDevMode);
+		this(cdnHost, bundleAsMap(cdnBundle, isDevMode), isDevMode);
 	}
 
 	/**
 	 * @param cdnBundle
 	 * @return
 	 */
-	private static Map<String, String> bundleAsMap(ResourceBundle cdnBundle) {
-		Set<String> keys = cdnBundle.keySet();
-		Map<String, String> cdnMap = new HashMap<String, String>(keys.size());
-		for (String key : keys) {
-			cdnMap.put(key, cdnBundle.getString(key));
+	private static Map<String, String> bundleAsMap(final ResourceBundle bundle, boolean isDevMode) {
+
+		if (!isDevMode) {
+			// dump key-value pairs into simple map
+			Set<String> keys = bundle.keySet();
+			Map<String, String> map = new HashMap<String, String>(keys.size());
+			for (String key : keys) {
+				map.put(key, bundle.getString(key));
+			}
+			return map;
 		}
-		return cdnMap;
+
+		// wrap bundle with an adaptor to allow dynamic reloading of bundle
+		return new Map<String, String>() {
+
+			@Override
+			public void clear() {}
+
+			@Override
+			public boolean containsKey(Object arg0) {
+				return bundle.containsKey((String)arg0);
+			}
+
+			@Override
+			public boolean containsValue(Object arg0) { return false; }
+
+			@Override
+			public Set<java.util.Map.Entry<String, String>> entrySet() { return null; }
+
+			@Override
+			public String get(Object arg0) {
+				return (String)bundle.getObject((String)arg0);
+			}
+
+			@Override
+			public boolean isEmpty() { return false; }
+
+			@Override
+			public Set<String> keySet() { return null; }
+
+			@Override
+			public String put(String arg0, String arg1) { return null; }
+
+			@Override
+			public void putAll(Map<? extends String, ? extends String> arg0) {}
+
+			@Override
+			public String remove(Object arg0) { return null; }
+
+			@Override
+			public int size() { return 0; }
+
+			@Override
+			public Collection<String> values() { return null; }
+		};
 	}
 }