Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. /**
  2. * Created by alicj_390xsny on 15.03.2019.
  3. */
  4.  
  5. import org.apache.xmlrpc.WebServer;
  6.  
  7.  
  8. public class serwerRPC {
  9.  
  10. public Integer echo(int x, int y){
  11. return new Integer(x+y);
  12. }
  13.  
  14. public int execAsy(int x){
  15. System.out.println("... wywolano asy - odliczam");
  16. try{
  17. Thread.sleep(x);
  18.  
  19. } catch (InterruptedException e) {
  20. e.printStackTrace();
  21. Thread.currentThread().interrupt();
  22. }
  23.  
  24. System.out.println("... asy - koniec odliczania");
  25. return (123);
  26. }
  27.  
  28. public int modyfication(String text, String number){
  29.  
  30. int counter = Integer.parseInt(number);
  31. try {
  32. for (int i=0; i<counter; i++){
  33. System.out.println(text);
  34. Thread.sleep(1000);
  35. }
  36. } catch (InterruptedException e) {
  37. e.printStackTrace();
  38. }
  39.  
  40. return (123);
  41. }
  42.  
  43.  
  44. public static void main(String[] args) {
  45.  
  46. try{
  47. System.out.println("Startuje serwer XML-RPC...");
  48. int port = 10000;
  49. WebServer server = new WebServer(port);
  50.  
  51. server.addHandler("MojSerwer", new serwerRPC());
  52. server.start();
  53. System.out.println("Serwer wystartowal pomyslnie");
  54. System.out.println("Nasluchuje na porcie: " + port);
  55. System.out.println("Aby zatrzymać serwer nacisnij ctrl+c");
  56. }
  57. catch(Exception exception){
  58. System.err.println("Serwer XML-RPC: " + exception);
  59. }
  60.  
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement