You can absolutely run an nREPL server from a mostly-Java application. Something like this would do (just a sketch, untested):
//// private static IFn startServer, stopServer; static { try { RT.var("clojure.core", "require").invoke(Symbol.intern("clojure.tools.nrepl.server")); startServer = RT.var("clojure.tools.nrepl.server", "start-server"); stopServer = RT.var("clojure.tools.nrepl.server", "stop-server"); } catch (Exception e) { throw new RuntimeException(e); } } public static Object startServer (int port) { return startServer.invoke(Keyword.intern("port"), port); } public static void stopServer (Object server) { stopServer.invoke(server); } //// There's already a thin Java wrapper for the nREPL client API (https://github.com/clojure/tools.nrepl/blob/master/src/main/java/clojure/tools/nrepl/Connection.java); one for the server side would be good to cover that use case as well. - Chas On Feb 15, 2012, at 8:46 AM, Stathis Sideris wrote: > It sounds great Chas, especially the wide acceptance that nREPL seems > to already have with the various tools. > > I wanted to ask about the potential of this as an embedded Clojure > REPL in existing Java applications for the purpose of connecting > remotely and performing inspection (and possibly manipulation?) of the > current state of the application for debugging purposes. Is this a > legitimate use case? How easy do you think it would be to achieve this > with the current version of nREPL? > > Thanks! > > Stathis > > > On Feb 14, 2:42 pm, Chas Emerick <c...@cemerick.com> wrote: >> I have released nREPL 0.2.0-beta1, which should show up in Maven central >> soon. >> >> For those that don't know, nREPL is "a Clojure network REPL that provides a >> REPL server and client, along with some common APIs of use to IDEs and other >> tools that may need to evaluate Clojure code in remote environments": >> >> https://github.com/clojure/tools.nrepl >> >> This release is the result of gathering ideas, feedback, and requirements >> from dozens of people that need to have a REPL backend in a variety of >> environments, and want to maximize interoperability of Clojure tooling — >> much of which inevitably ends up grounding out at running or connecting to a >> REPL somewhere. >> >> This release marks a thorough breaking change from every aspect the last >> release of nREPL, 0.0.5. (The rationale for this is detailed in design >> notes in the project's wiki, for those that haven't followed along.) The >> result is that a design that settles a number of failings of nREPL's >> original design, and which provides a number of different vectors of >> extensibility — similar in many respects to those provided by Ring — that I >> hope people will take advantage of to build astonishingly cool tools. >> >> Note that pre-release versions of many Clojure tools are already using >> snapshots of nREPL 0.2.0, including Counterclockwise, Leiningen, and Reply, >> and as far as I know, more are on their way. >> >> My plans for the near future are to continue to tighten up the >> documentation, and release an HTTP transport: a Ring handler that exposes >> nREPL as an HTTP API. >> >> If you have any questions or find some shortcoming, bug, or problem with >> this release, please reply here or ping me on irc or twitter (`cemerick` in >> either case). >> >> Happy tooling, >> >> - Chas > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en