Revision: 4669 http://sourceforge.net/p/vexi/code/4669 Author: mkpg2 Date: 2014-03-05 13:34:16 +0000 (Wed, 05 Mar 2014) Log Message: ----------- Ignore duplicate locations (with a warning) when creating vexi resource path.
Modified Paths: -------------- branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Main.java branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Fountain.java Modified: branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Main.java =================================================================== --- branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Main.java 2014-03-03 20:30:17 UTC (rev 4668) +++ branches/vexi3/org.vexi-core.main/src/main/java/org/vexi/core/Main.java 2014-03-05 13:34:16 UTC (rev 4669) @@ -194,7 +194,6 @@ origin = args[startargs]; // resource root? - Fountain rr; Fountain vexi_rr = null; Multiple multiStream = null; //Basket.Hash paramValues = new Basket.Hash(); @@ -208,24 +207,26 @@ loadParam(args[i]); } else { - rr = Resources.fountainForArg(args[i]); - if (rr!=null) { + Fountain f = Resources.fountainForArg(args[i]); + if (f!=null) { if (vexi_rr == null) { - vexi_rr = rr; + vexi_rr = f; } else { if (multiStream==null) { multiStream = new Multiple(args.length-startargs); multiStream.addOverrideStream(vexi_rr); vexi_rr = multiStream; } - multiStream.addOverrideStream(rr); + if(!multiStream.addOverrideStream(f)){ + Log.warn(Main.class, "[Warning] Duplication location: "+ args[i]); + } } if (args[i].startsWith("http://") || args[i].startsWith("https://")) { // FIXME restore splash functionality //initialTemplate = "org.vexi.builtin.splash"; } } else { - Log.warn(Main.class, "[Error] Non-existent location: "+ args[i]); + Log.warn(Main.class, "[Warning] Non-existent location: "+ args[i]); } } } Modified: branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Fountain.java =================================================================== --- branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Fountain.java 2014-03-03 20:30:17 UTC (rev 4668) +++ branches/vexi3/org.vexi-library.js/src/main/java/org/ibex/js/Fountain.java 2014-03-05 13:34:16 UTC (rev 4669) @@ -15,17 +15,18 @@ import java.io.OutputStream; import java.lang.ref.WeakReference; import java.net.URL; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; -import java.util.Vector; import java.util.jar.JarFile; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import org.ibex.net.HTTPFactory; import org.ibex.net.HTTP.HTTPEntityInfo; import org.ibex.net.HTTP.HTTPResponse; +import org.ibex.net.HTTPFactory; import org.ibex.util.Cache; import org.ibex.util.Callable; import org.ibex.util.IOUtil; @@ -360,8 +361,12 @@ } return s; } - public long getTimestamp() { - return new java.io.File(path).lastModified(); + private java.io.File file(){ return new java.io.File(path); } + public long getTimestamp() { return file().lastModified(); } + public int hashCode() { return file().hashCode(); } + public boolean equals(Object obj) { + if(!(obj instanceof File)) return false; + return file().equals(((File)obj).file()); } } @@ -501,8 +506,13 @@ } return s; } - public long getTimestamp() { - return new java.io.File(parent.getName()).lastModified(); + + private java.io.File file(){ return new java.io.File(parent.getName()); } + public long getTimestamp() { return file().lastModified(); } + public int hashCode() { return file().hashCode(); } + public boolean equals(Object obj) { + if(!(obj instanceof ZipFile)) return false; + return file().equals(((ZipFile)obj).file()); } } @@ -571,22 +581,22 @@ public static class Multiple extends Fountain { private boolean cached; - private Vector fountains = null; + private List fountains = null; private String path = ""; public Multiple(int size) { - fountains = new Vector(size); + fountains = new ArrayList(size); cached = false; } - public Multiple(Vector parentStreams, JS key, String parentPath) { + public Multiple(List parentStreams, JS key, String parentPath) { this.cached = true; int len = parentStreams.size(); - fountains = new Vector(len); + fountains = new ArrayList(len); try { path = parentPath + java.io.File.separatorChar + key.coerceToString(); for (int i=0; i<len; i++) { - Fountain stream = (Fountain)parentStreams.elementAt(i); - if (stream!=null)fountains.addElement(stream.get(key)); + Fountain stream = (Fountain)parentStreams.get(i); + if (stream!=null)fountains.add(stream.get(key)); } } catch(JSExn e) @@ -596,15 +606,17 @@ // FIXME: consider not doing loop when chosen!=null cached = true; for (int i=0; i<fountains.size(); i++) - ((Fountain)fountains.elementAt(i)).cache(principal==null?this:principal); + ((Fountain)fountains.get(i)).cache(principal==null?this:principal); } // FEATURE: it would be nice if toString() would show which sub-stream the object came from // public String canonical() { return "multi:" + path; } - public void addOverrideStream(Fountain fountain) { - if (fountain!=null) - fountains.insertElementAt(fountain, 0); + public boolean addOverrideStream(Fountain fountain) { + if (fountain==null) return false; + if(fountains.contains(fountain)) return false; + fountains.add(0, fountain); + return true; } public JS _get(JS key) throws JSExn { try {if(!cached)cache(this);} catch (IOException e) { @@ -615,7 +627,7 @@ InputStream is; // FIXME: consider not doing loop when chosen!=null for (int i=0; i< fountains.size(); i++) { - Fountain stream = (Fountain)fountains.elementAt(i); + Fountain stream = (Fountain)fountains.get(i); if (stream!=null) { try { is = stream.getInputStream(this, expect); @@ -632,7 +644,7 @@ Set s = new HashSet(); // Done in 'correct' order, but actually order here is unimportant. for (int i=fountains.size()-1; i>=0 ; i--) { - Fountain stream = (Fountain)fountains.elementAt(i); + Fountain stream = (Fountain)fountains.get(i); try{ Set s2 = stream.getKeySet(); s.addAll(s2); @@ -646,7 +658,7 @@ public long getTimestamp() { long r = Long.MIN_VALUE; for (int i=fountains.size()-1; i>=0 ; i--) { - Fountain stream = (Fountain)fountains.elementAt(i); + Fountain stream = (Fountain)fountains.get(i); r = Math.max(r, stream.getTimestamp()); } return r; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn