/** * Starts the server * * @throws Exception */ public XMLRPCServer() throws Exception { if (LocalSettings.hasProperty(LocalSettings.SERVER_PORT)) { port = Integer.valueOf(LocalSettings.getProperty(LocalSettings.SERVER_PORT)); } webServer = new WebServer(getPort()); XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer(); ((XmlRpcStreamServer) xmlRpcServer) .setErrorLogger( new XmlRpcErrorLogger() { @Override public void log(java.lang.String pMessage) { Log.Debug(this, pMessage); } @Override public void log(java.lang.String pMessage, java.lang.Throwable pThrowable) { Log.Debug(this, pMessage); Log.Debug(pThrowable); } }); PropertyHandlerMapping phm = new XPropertyHandlerMapping(); // ArrayList<Context> cx = Context.getImportableContexts(); // for (int i = 0; i < cx.size(); i++) { // Context context = cx.get(i); // } phm.addHandler("remote", XMLRPCHandler.class); xmlRpcServer.setHandlerMapping(phm); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig(); serverConfig.setEnabledForExtensions(true); serverConfig.setContentLengthOptional(false); PropertyHandlerMapping mapping = (PropertyHandlerMapping) ((XmlRpcStreamServer) xmlRpcServer).getHandlerMapping(); XmlRpcSystemImpl.addSystemHandler(mapping); webServer.start(); Log.Debug(this, "XML RPC Server started! Listening port: " + port); if (Log.getLoglevel() == Log.LOGLEVEL_DEBUG) { Log.Debug(this, "XML RPC Server handler: "); String[] lm = phm.getListMethods(); for (int i = 0; i < lm.length; i++) { String string = lm[i]; Log.Debug(this, string); } } }
public static void main(String[] args) { System.out.println("Attempting to start RPC Server..."); WebServer server = new WebServer(80); server.acceptClient("127.0.0.1"); try { server.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Started successfully."); System.out.println("Accepting requests. (Halt program to stop.)"); }