Java Reference
In-Depth Information
22. }
23. catch (IOException exc){
24. System.err.println("Unable to run rmic utility. Exiting application.");
25. System.exit(1);
26. }
27. catch (InterruptedException exc){
28. System.err.println("Threading problems encountered while using the rmic utility.");
29. }
30.
31. System.out.println("Starting the rmiregistry");
32. System.out.println();
33. try{
34. Process rmiProcess = Runtime.getRuntime().exec("rmiregistry");
35. Thread.sleep(15000);
36. }
37. catch (IOException exc){
38. System.err.println("Unable to start the rmiregistry. Exiting application.");
39. System.exit(1);
40. }
41. catch (InterruptedException exc){
42. System.err.println("Threading problems encountered when starting the rmiregistry.");
43. }
44.
45. System.out.println("Creating three appointment books");
46. System.out.println();
47. AppointmentBook apptBookOne = new AppointmentBook();
48. AppointmentBook apptBookTwo = new AppointmentBook();
49. AppointmentBook apptBookThree = new AppointmentBook();
50.
51. System.out.println("Creating appointments");
52. System.out.println();
53. Appointment apptOne = new AppointmentImpl("Swim relay to Kalimantan (or Java)", new
ArrayList(),
54. new LocationImpl("Sidney, Australia"), createDate(2001, 11, 5, 11, 0));
55. Appointment apptTwo = new AppointmentImpl("Conference on World Patternization", new
ArrayList(),
56. new LocationImpl("London, England"), createDate(2001, 11, 5, 14, 0));
57. Appointment apptThree = new AppointmentImpl("Society for the Preservation of Java
- Annual Outing",
58. new ArrayList(), new LocationImpl("Kyzyl, Tuva"), createDate(2001, 11, 5, 10,
0));
59.
60. System.out.println("Adding appointments to the appointment books");
61. System.out.println();
62. apptBookOne.addAppointment(apptThree);
63. apptBookTwo.addAppointment(apptOne);
64. apptBookOne.addAppointment(apptTwo);
65. apptBookTwo.addAppointment(apptTwo);
66. apptBookThree.addAppointment(apptTwo);
67.
68. System.out.println("AppointmentBook contents:");
69. System.out.println();
70. System.out.println(apptBookOne);
71. System.out.println(apptBookTwo);
72. System.out.println(apptBookThree);
73. System.out.println();
74.
75. System.out.println("Rescheduling an appointment");
76. System.out.println();
77. System.out.println();
78. boolean result = apptBookThree.changeAppointment(apptTwo, getDates(2001, 11, 5, 10,
3),
79. lookUpParticipants(new String[] { apptBookOne.getUrl(), apptBookTwo.getUrl(),
apptBookThree.getUrl() }),
80. 20000L);
81.
82. System.out.println("Result of rescheduling was " + result);
83. System.out.println("AppointmentBook contents:");
84. System.out.println();
85. System.out.println(apptBookOne);
86. System.out.println(apptBookTwo);
87. System.out.println(apptBookThree);
88. }
89.
90. private static AppointmentTransactionParticipant[] lookUpParticipants(String[]
remoteUrls){
91. AppointmentTransactionParticipant[] returnValues =
92. new AppointmentTransactionParticipant[remoteUrls.length];
Search WWH ::




Custom Search