package server;

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 service.TaskService;

public class Server {
	
	private static final int port = 8080;
    public static void main(String[] args) throws Exception {
        WebServer webServer = new WebServer(port);

        XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer();

        PropertyHandlerMapping phm = new PropertyHandlerMapping();

        /* 从配置文件中加载.
         * The property file might look like:
         *   Calculator=org.apache.xmlrpc.demo.Calculator
         *   org.apache.xmlrpc.demo.proxy.Adder=org.apache.xmlrpc.demo.proxy.AdderImpl
         */
        //phm.load(Thread.currentThread().getContextClassLoader(), "service.properties");
        phm.addHandler(TaskService.class.getSimpleName(), TaskService.class);
        /* 也可以像这样直接指定:
         * phm.addHandler("Calculator", org.apache.xmlrpc.demo.Calculator.class);
         * phm.addHandler(org.apache.xmlrpc.demo.proxy.Adder.class.getName(), org.apache.xmlrpc.demo.proxy.AdderImpl.class);
         */
        xmlRpcServer.setHandlerMapping(phm);

        XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) xmlRpcServer.getConfig();
        serverConfig.setEnabledForExtensions(true);
        serverConfig.setContentLengthOptional(false);

        webServer.start();
    }
}

@@ -266,17 +266,16 @@
 erver %7B%0A
-%09
 %0A%09privat
@@ -306,20 +306,18 @@
 = 8080;%0A
-    
+%0A%09
 public s
@@ -366,24 +366,18 @@
 ption %7B%0A
-        
+%09%09
 WebServe
@@ -408,32 +408,26 @@
 ver(port);%0A%0A
-        
+%09%09
 XmlRpcServer
@@ -472,24 +472,18 @@
 ver();%0A%0A
-        
+%09%09
 Property
@@ -534,25 +534,24 @@
 ing();%0A%0A
-        /
+%09%09/*%0A%09%09 
 * %E4%BB%8E%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E4%B8%AD
@@ -553,27 +553,16 @@
 %E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E4%B8%AD%E5%8A%A0%E8%BD%BD.
-%0A         *
  The pro
@@ -589,28 +589,20 @@
 k like:%0A
-         *  
+%09%09 *
  Calcula
@@ -643,20 +643,12 @@
 tor%0A
-         *  
+%09%09 *
  org
@@ -668,24 +668,30 @@
 c.demo.proxy
+%0A%09%09 * 
 .Adder=org.a
@@ -728,30 +728,19 @@
 mpl%0A
-         */%0A        
+%09%09 */%0A%09%09
 //
+ 
 phm.
@@ -791,16 +791,21 @@
 oader(),
+%0A%09%09//
  %22servic
@@ -820,24 +820,18 @@
 ties%22);%0A
-        
+%09%09
 phm.addH
@@ -896,17 +896,16 @@
 s);%0A
-        /
+%09%09/*%0A%09%09 
 * %E4%B9%9F%E5%8F%AF
@@ -913,27 +913,16 @@
 %E5%83%8F%E8%BF%99%E6%A0%B7%E7%9B%B4%E6%8E%A5%E6%8C%87%E5%AE%9A:
-%0A         *
  phm.add
@@ -942,16 +942,21 @@
 ulator%22,
+%0A%09%09 *
  org.apa
@@ -990,24 +990,18 @@
 class);%0A
-        
+%09%09
  * phm.a
@@ -1061,16 +1061,21 @@
 tName(),
+%0A%09%09 *
  org.apa
@@ -1118,28 +1118,16 @@
 s);%0A
-         */%0A        
+%09%09 */%0A%09%09
 xmlR
@@ -1160,24 +1160,18 @@
 (phm);%0A%0A
-        
+%09%09
 XmlRpcSe
@@ -1233,24 +1233,29 @@
 xmlRpcServer
+%0A%09%09%09%09
 .getConfig()
@@ -1256,24 +1256,18 @@
 nfig();%0A
-        
+%09%09
 serverCo
@@ -1302,24 +1302,18 @@
 (true);%0A
-        
+%09%09
 serverCo
@@ -1355,16 +1355,10 @@
 );%0A%0A
-        
+%09%09
 webS
@@ -1376,12 +1376,9 @@
 ();%0A
-    
+%09
 %7D%0A%7D%0A

add a task server