public RhinoConsoleMain() {
this.rhinoInterpreter = new RhinoInterpreter();
}
public void startXmlRpcServer(int port) throws IOException {
WebServer webServer = new WebServer(port);
XmlRpcServer serverToHandleRawInput = webServer.getXmlRpcServer();
final Map<String, XmlRpcHandler> nameToHandler = new HashMap<String, XmlRpcHandler>();
nameToHandler.put("addExec", new AddExecXmlRpcHandler(this));
nameToHandler.put("getCompletions", new GetCompletionsXmlRpcHandler(this));
nameToHandler.put("getDescription", new GetDescriptionXmlRpcHandler(this));
nameToHandler.put("close", new CloseXmlRpcHandler(webServer, this));
nameToHandler.put("hello", new HelloXmlRpcHandler());
serverToHandleRawInput.setHandlerMapping(new XmlRpcHandlerMapping() {
public XmlRpcHandler getHandler(String handlerName) throws XmlRpcNoSuchHandlerException, XmlRpcException {
XmlRpcHandler handler = nameToHandler.get(handlerName);
if (handler != null) {
return handler;
}
throw new XmlRpcNoSuchHandlerException("No handler for method " + handlerName);
}
});
webServer.start();
}