On Wed, Mar 18, 2009 at 4:02 AM, Tassilo Horn <[email protected]> wrote:
>
> Tassilo Horn <[email protected]> writes:
>
>>> Take a look at this blog post:
>>> http://avodonosov.blogspot.com/2008/12/simpler-clojureslime-embedding.html
>>>
>>> I think you will find it useful.
>>
>> Cool, but I had to modify it a bit to get it working:
>>
>> (add-classpath "file:///home/horn/repos/el/swank-clojure/")
>> (require 'swank.swank 'clojure.main)
>> (clojure.main/with-bindings
>>  (swank.swank/ignore-protocol-version "2008-11-23")
>>  (swank.swank/start-server "nul" :encoding "utf-8-unix" :port 7777))
>
> Ok, so now I can start a swank server from Java and can connect to it
> using SLIME.  But now comes the next problem: How do I access the
> objects of the running java app?
>
> Basically all our apps operate on a graph, and that's what I'd like to
> have accessible from clojure.  So I want something like that:
>
>     ...
>     Graph g = GraphIO.loadGraphFromFile("foo.tg");
>     defInClojure("graph", g);
>     ...
>
> so that from inside SLIME I have a variable graph holding a reference to
> the graph g from the java app.  If possible, how would I do this?
>

You can create a Clojure var from Java with:

 clojure.lang.RT.var("my-app.graphs", "my-graph", g);

>From Clojure, you would refer to this with;

 my-app.graphs/my-graph


> Another approach would be to find the object of interest from inside
> SLIME.  Something like (find-objects-of-class foo.bar.Graph) returning a
> seq of all graphs.  Is something like that available?
>

I have no idea if SLIME has any such call. Nor can I really think of
how I might accomplish that, even directly from Java. Any takers?

/mike.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to