On 7/12/06, Nick Sieger <[EMAIL PROTECTED]> wrote:
How do these libraries form the absolute path to the files -- is it based on something from "rbconfig" or RUBY_LIB?  A wild idea, but what if, when running JRuby with a command like "java -jar jruby.jar" or when embedding, that we default jruby.home to a value like "classloader:", and then intercept all file resolution calls to check for that prefix, and if so, attempt to use ClassLoader.getResource () to resolve the file?

The code in question is in irb/locale.rb, but it essentially boils down to this:

    for path in $:
      lc_path = search_file(path + "/" + dir, base)
      return real_load(lc_path, priv) if lc_path
    end

It manually searches the load patch for the file in question, and there's some substitution of local postfix going on around this as well.

What you're suggesting is basically what I'm hoping to do, except that I think we could just have the load path explicitly contain all jars on the classpath, so that when you do a load it will search classpath jars as well. That part's not too difficult...what's difficult is then allowing that resource location, ultimately a resource URL, to be File.open'ed like a normal java.io.File (albeit a read-only one). We have many layers of abstractions that depend on Ruby File being a File, along with some nio stuff.

It's certainly not impossible, and maybe just needs some time and effort, but it would require a new constructor for RubyFile that accepts a URL and all code that works with the java.io.File or its nio channels would have to additionally work with a URL.

--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ www.jruby.org
Application Architect @ www.ventera.com
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel

Reply via email to