tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Berry Crawford" <be...@bondisoftware.com>
Subject Re: PATCH: running ANT from classpath (i.e., w/o jar)
Date Fri, 10 Dec 1999 16:28:34 GMT
I thought that I followed instructions to unsubscribe to the list but for
some reason Im still getting messages.  Is there a secret trick?

----- Original Message -----
From: <rubys@us.ibm.com>
To: <tomcat-dev@jakarta.apache.org>
Sent: Friday, December 10, 1999 8:58 AM
Subject: PATCH: running ANT from classpath (i.e., w/o jar)


>
>
> The first fix simply goes to the resource bundle directly if no class
> loader can be found.  The second fix makes the properties file match the
> location in the build.
>
> Fixes do not appear to be OS or JDK version dependent.
>
> Index: Parser.java
> ===================================================================
> RCS file:
> /home/cvs/jakarta-tools/ant/src/main/org/apache/tools/ant/Parser.java,v
> retrieving revision 1.1
> diff -u -r1.1 Parser.java
> --- Parser.java     1999/12/03 12:44:11  1.1
> +++ Parser.java     1999/12/10 14:56:40
> @@ -58,6 +58,7 @@
>  import java.io.InputStream;
>  import java.io.IOException;
>  import java.util.Properties;
> +import java.util.ResourceBundle;
>  import org.w3c.dom.Document;
>  import org.xml.sax.SAXException;
>
> @@ -77,18 +78,30 @@
>      public static Parser getParser(Project project)
>      throws BuildException {
>          ClassLoader loader=project.getClass().getClassLoader();
> -        InputStream in=loader.getResourceAsStream(properties);
> -        if (in==null) throw new BuildException("Cannot find properties
> file");
> +    String name=null;
>
> -        String name;
> -        try {
> -            Properties prop=new Properties();
> -            prop.load(in);
> -            name=prop.getProperty("parser");
> -            if (name==null) throw new BuildException("Parser name not
> found");
> -        } catch(IOException e) {
> -            throw new BuildException("Cannot load properties file");
> +    if (loader == null) {
> +        String bundleName=properties;
> +        if (bundleName.endsWith(".properties"))
> +
> bundleName=bundleName.substring(0,bundleName.lastIndexOf(".properties"));
> +        ResourceBundle bundle = ResourceBundle.getBundle(bundleName);
> +        if (bundle==null) throw new BuildException("Cannot find
properties
>  file");
> +        name=bundle.getString("parser");
> +    } else {
> +        InputStream in=loader.getResourceAsStream(properties);
> +        if (in==null) throw new BuildException("Cannot find properties
> file");
> +
> +        try {
> +         Properties prop=new Properties();
> +         prop.load(in);
> +         name=prop.getProperty("parser");
> +        } catch(IOException e) {
> +         throw new BuildException("Cannot load properties file");
> +        }
>          }
> +
> +        if (name==null) throw new BuildException("Parser name not
found");
> +
>          try {
>              return((Parser)Class.forName(name).newInstance());
>          } catch (ClassNotFoundException e) {
> @@ -109,4 +122,4 @@
>      throws SAXException, IOException;
>  }
>
> -
> \ No newline at end of file
> +
> Index: parser.properties
> ===================================================================
> RCS file:
>
/home/cvs/jakarta-tools/ant/src/main/org/apache/tools/ant/parser.properties,
v
>
> retrieving revision 1.1
> diff -u -r1.1 parser.properties
> --- parser.properties    1999/12/03 12:44:11  1.1
> +++ parser.properties    1999/12/10 14:56:40
> @@ -1 +1 @@
> -parser=org.apache.tools.ant.parsers.SunParser
> \ No newline at end of file
> +parser=org.apache.tools.ant.SunParser
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message