public synchronized void startREPLServer() {
if (ackREPLServer == null) {
try {
// TODO use ClojureOSGi.withBundle instead
Var startServer = BundleUtils.requireAndGetVar(getBundle().getSymbolicName(), "clojure.tools.nrepl.server/start-server");
Object defaultHandler = BundleUtils.requireAndGetVar(
getBundle().getSymbolicName(),
"clojure.tools.nrepl.server/default-handler").invoke();
Object handler = BundleUtils.requireAndGetVar(
getBundle().getSymbolicName(),
"clojure.tools.nrepl.ack/handle-ack").invoke(defaultHandler);
ackREPLServer = (ServerSocket)((Map)startServer.invoke(Keyword.intern("handler"), handler)).get(Keyword.intern("server-socket"));
CCWPlugin.log("Started ccw nREPL server: nrepl://127.0.0.1:" + ackREPLServer.getLocalPort());
} catch (Exception e) {
CCWPlugin.logError("Could not start plugin-hosted REPL server", e);
throw new RuntimeException("Could not start plugin-hosted REPL server", e);
}