This won't work if the codebase leaves the vm, and now what happens if
the path contains a '+' ?

----- Original Message -----
From: "Hiram Chirino" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 24, 2001 11:54 PM
Subject: Re: [JBoss-dev] (no subject)


>
> Ok.. if finished that workaround.  I don't know if it will break anything
> else, but at least it fixes our test case.  To use it, add the following
> line to the top of the tstMO main() method.
>
>    FileURLSpaceFixer.install();
>
> below is the FileURLSpaceFixer.java file.
> -------------------------
> import java.net.URL;
> import java.net.URLStreamHandlerFactory;
> import java.net.URLStreamHandler;
> import java.net.URLConnection;
>
> /**
> * Used to fix the problem with the RMI classloader for
> * when a space appears in the path to where a class
> * should be loaded from.
> *
> * @author: Hiram Chirino
> */
> class FileURLSpaceFixer {
>
>    private static FileHandler fileHander= new FileHandler();
>    private static CustomURLStreamHandlerFactory
> customURLStreamHandlerFactory= new CustomURLStreamHandlerFactory();
>
>    //
>    // This class is used to hook into the URL protocol parsing sysytem
>    //
>    private static class CustomURLStreamHandlerFactory implements
> URLStreamHandlerFactory {
>       public URLStreamHandler createURLStreamHandler(String protocol) {
>          if (protocol.equals("file"))
>             return fileHander;
>          return null;
>       }
>    }
>
>    //
>    // This class will override how the file handler is implemented.
>    //
>    private static class FileHandler extends
> sun.net.www.protocol.file.Handler {
>
>       // When we externalize the URL we want to make all the spaces in the
> file name
>       // a '+' character
>       protected String toExternalForm(URL u) {
>          String s= super.toExternalForm(u);
>          return s.replace(' ', '+');
>       }
>
>       // When we load a URL in we want to convert all the '+' characters
in
> the file name
>       // into spaces.
>       protected void parseURL(URL u, String spec, int start, int limit) {
>          super.parseURL(u, spec, start, limit);
>          setURL(u, u.getProtocol(), u.getHost(), u.getPort(),
> u.getFile().replace('+', ' '), u.getRef());
>       }
>    }
>
>    // use this method to install this fix.
>    public static void install() {
>       URL.setURLStreamHandlerFactory(customURLStreamHandlerFactory);
>    }
> }
> -----------------
>
> Regards,
> Hiram
>



_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to