Created
March 20, 2011 22:32
-
-
Save rbackhouse/878744 to your computer and use it in GitHub Desktop.
File Based Resource Loader extending JSCompressorResourceLoader that enables javascript compression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.IOException; | |
import java.net.URL; | |
import org.dojotoolkit.compressor.JSCompressorFactory; | |
import org.dojotoolkit.compressor.JSCompressorResourceLoader; | |
public class FileBasedCompressingResourceLoader extends JSCompressorResourceLoader { | |
private File root = null; | |
public FileBasedCompressingResourceLoader(File root, JSCompressorFactory jsCompressorFactory) { | |
super (jsCompressorFactory); | |
this.root = root; | |
} | |
protected URL _getResource(String path) throws IOException { | |
File resourceFile = new File(root, path); | |
if (resourceFile.exists()) { | |
timestampLookup.put(path, resourceFile.toURI().toURL()); | |
return resourceFile.toURI().toURL(); | |
} else { | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment