You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by pr...@apache.org on 2003/09/04 03:32:46 UTC
cvs commit: jakarta-commons/jelly/src/java/org/apache/commons/jelly Jelly.java
proyal 2003/09/03 18:32:46
Modified: jelly/src/java/org/apache/commons/jelly/util
CommandLineParser.java
jelly/src/java/org/apache/commons/jelly Jelly.java
Log:
[JELLY-75] Search classpath before creating files. For applets and JNLP
Patch from Sean Ferguson
Revision Changes Path
1.3 +11 -7 jakarta-commons/jelly/src/java/org/apache/commons/jelly/util/CommandLineParser.java
Index: CommandLineParser.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/util/CommandLineParser.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CommandLineParser.java 30 Oct 2002 19:16:27 -0000 1.2
+++ CommandLineParser.java 4 Sep 2003 01:32:45 -0000 1.3
@@ -64,6 +64,7 @@
import java.io.File;
import java.io.FileWriter;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Properties;
import java.util.StringTokenizer;
@@ -102,7 +103,6 @@
* Parse out the command line options and configure
* the give Jelly instance.
*
- * @param jelly Jelly instance to configure
* @param args options from the command line
* @exception JellyException
* if the command line could not be parsed
@@ -123,8 +123,12 @@
scriptFile = args[0];
}
+ //
+ // Use classloader to find file
+ //
+ URL url = this.getClass().getClassLoader().getResource(scriptFile);
// check if the script file exists
- if (!(new File(scriptFile)).exists()) {
+ if (url == null && !(new File(scriptFile)).exists()) {
throw new JellyException("Script file " + scriptFile + " not found");
}
1.27 +18 -9 jakarta-commons/jelly/src/java/org/apache/commons/jelly/Jelly.java
Index: Jelly.java
===================================================================
RCS file: /home/cvs/jakarta-commons/jelly/src/java/org/apache/commons/jelly/Jelly.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- Jelly.java 24 Jan 2003 02:22:59 -0000 1.26
+++ Jelly.java 4 Sep 2003 01:32:45 -0000 1.27
@@ -263,11 +263,20 @@
* @return the URL for the relative file name or absolute URL
*/
protected URL resolveURL(String name) throws MalformedURLException {
- File file = new File(name);
- if (file.exists()) {
- return file.toURL();
+
+ URL url = this.getClass().getClassLoader().getResource(name);
+ if (url != null)
+ {
+ return url;
+ }
+ else
+ {
+ File file = new File(name);
+ if (file.exists()) {
+ return file.toURL();
+ }
+ return new URL(name);
}
- return new URL(name);
}
/**