Server.java

import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; import org.apache.xmlrpc.webserver.WebServer; import robot.RobotLauncher; import java.io.IOException; import java.net.InetAddress; /** * Created with IntelliJ IDEA. * User: Лидия * Date: 10.12.13 * Time: 19:44 * To change this template use File | Settings | File Templates. */ public class Server { /* public static void main(String [] args) { RobotLauncher launcher = new RobotLauncher(); System.out.println(launcher.Search("science")); } */ private static final int port = 4444; public static void main(String args[]) throws IOException, XmlRpcException { // Запускаем веб-сервер на указанном порту. System.out.println("Let's start the server!"); try { WebServer webServer = new WebServer(port); // Запускаем на веб-сервере сервер XMLRPC XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer(); PropertyHandlerMapping phm = new PropertyHandlerMapping(); // Добавляем обработчик запросов - класс RobotLauncher phm.addHandler("RobotLauncher",RobotLauncher.class); xmlRpcServer.setHandlerMapping(phm); XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig(); serverConfig.setEnabledForExtensions(true); serverConfig.setContentLengthOptional(false); // Запускаем веб-сервер. webServer.start(); RobotLauncher search = new RobotLauncher(); search.Search("computer"); //InetAddress ip; //ip = InetAddress.getLocalHost(); //System.out.println("Current IP address : " + ip.getHostAddress()); } catch(Exception exc) { System.out.println("Exception occured!"); } System.out.println("Server started!"); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.