Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public class KlientRMI {
  2. public static void main(String[] args) {
  3. double wynik;
  4. ResultType wynik2;
  5. CalcObject zObiekt;
  6. CalcObject2 zObiekt2;
  7. InputType inObj;
  8. inObj = new InputType();
  9. inObj.x1 = 123;
  10. inObj.x2 = 435;
  11. inObj.operation = "add";
  12.  
  13. if (args.length == 0) {
  14. System.out.println("You have to enter RMI object address in the form:" +
  15. "//host_address/service_name");
  16. return;
  17. }
  18.  
  19. String adres = args[0];
  20. String adres2 = args[1];
  21.  
  22. // if (System.getSecurityManager() == null) {
  23. // System.setSecurityManager(new SecurityManager());
  24. // }
  25.  
  26. try {
  27. zObiekt = (CalcObject) java.rmi.Naming.lookup(adres);
  28. } catch (Exception e) {
  29. System.out.println("Nie mozna pobrac referencji do " + adres);
  30. e.printStackTrace();
  31. return;
  32. }
  33. System.out.println(("referencja do " + adres + " jest pobrana."));
  34.  
  35. try {
  36. zObiekt2 = (CalcObject2) java.rmi.Naming.lookup(adres2);
  37. } catch (Exception e) {
  38. System.out.println("Nie mozna pobrac referencji do " + adres2);
  39. e.printStackTrace();
  40. return;
  41. }
  42. System.out.println("referencja do " + adres2 + " jest pobrana.");
  43.  
  44. try {
  45. wynik = zObiekt.calculate(1.1, 2.2);
  46. wynik2 = zObiekt2.calculate(inObj);
  47. } catch (Exception e) {
  48. System.out.println("Blad zdalnego wywolania.");
  49. e.printStackTrace();
  50. return;
  51. }
  52. System.out.println("Wynik = " + wynik);
  53. System.out.println("Wynik2 " + wynik2.result_description + " " +wynik2.result);
  54. return;
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement