
javarepl.console.rest.RestConsole Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javarepl Show documentation
Show all versions of javarepl Show documentation
Java REPL is a simple Read-Eval-Print-Loop for Java language.
package javarepl.console.rest;
import com.googlecode.utterlyidle.ServerConfiguration;
import com.googlecode.utterlyidle.httpserver.RestServer;
import javarepl.console.Console;
import javarepl.console.DelegatingConsole;
import static com.googlecode.utterlyidle.BasePath.basePath;
import static com.googlecode.utterlyidle.ServerConfiguration.defaultConfiguration;
public class RestConsole extends DelegatingConsole {
private final RestServer server;
private final Integer port;
public RestConsole(Console console, Integer port) throws Exception {
super(console);
ServerConfiguration configuration = defaultConfiguration().port(port);
RestConsoleApplication application = new RestConsoleApplication(basePath("/"), this);
this.server = new RestServer(application, configuration);
this.port = port;
}
public final Integer port() {
return port;
}
@Override
public void shutdown() {
try {
server.close();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
super.shutdown();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy