[armedbear-devel] how to load local file?

Alessio Stalla alessiostalla at gmail.com
Tue Jun 4 23:43:57 UTC 2013


In addition to what Erik said, if I remember correctly, LOAD can take a
stream as a parameter too, so if you can obtain a Java InputStream to the
resource, you should be fine. I'm thinking about something like the
following:

LispObject theLoadFunction = interpreter.eval("#'cl:load");
Stream resourceStream = new Stream(theJavaInputStream);
theLoadFunction.execute(resourceStream);

this is from memory and untested, so probably it won't work, but you should
get the idea.

Of course, if you use the JSR-223 interface, that is handled for you
already, but you're using Interpreter directly, and switching is not
without cost, so you'll probably be better off if you follow Erik's
suggestion or mine.

Alessio


On Tue, Jun 4, 2013 at 9:57 PM, Erik Huelsmann <ehuels at gmail.com> wrote:

> Hi Joe,
>
>
> On Tue, Jun 4, 2013 at 7:17 PM, Joe Corneli <holtzermann17 at gmail.com>wrote:
>
>> Hello:
>>
>> I'm working with a Java developer and she tells me that this works:
>>
>> interpreter.eval("(load
>> \"/http://people.kmi.open.ac.uk/ning/atms/decipher-atms-single-file.lisp\
>> ")");
>>
>
> (Assuming the leading dash in "/http" is a typo, this should indeed
> work...)
>
>
>> but this doesn't:
>>
>> interpreter.eval("(load
>> \"/Decipher/codes/decipher-atms-single-file.lisp\")");
>>
>
> But: this should work as well. Can you tell a bit more about the
> environment? Is this a Windows environment, ie an environment with multiple
> filesystem root directories? If not and this is on a *nix-like filesystem,
> I would not understand why this shouldn't work.
>
> What means "doesn't work"? Does it mean something throws a Java exception?
> Does it mean the file content doesn't actually get loaded, but you see no
> errors? Is there a Common Lisp condition being thrown?
>
>
>> Any idea about why this would be, and how we can load local code from
>> a WAR web service?
>>
>
> What I did in the past is pick a class which I know to be included in the
> JAR/WAR, something like "org.armedbear.lisp.Lisp", take its class and get
> the URL of the required resource from it like this (taken from
> src/org/armedbear/lisp/Site.java):
>
>         URL url = Lisp.class.getResource("boot.lisp");
>
>
> HTH,
>
>
> Erik.
>



-- 
Some gratuitous spam:

http://ripple.com <http://ripple-project.org> Ripple, social credit system
http://common-lisp.net/project/armedbear ABCL, Common Lisp on the JVM
http://code.google.com/p/tapulli my Lisp open source projects
http://www.manydesigns.com/ ManyDesigns Portofino, open source model-driven
Java web application framework
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/armedbear-devel/attachments/20130605/7e98a6f6/attachment.html>


More information about the armedbear-devel mailing list