Java Reference
In-Depth Information
53.
54. System.out.println("Adding a contact. Both clients will attempt to edit");
55. System.out.println(" the same contact at first, which will result in a");
56. System.out.println(" SessionException.");
57. try {
58. clientOne.addContact(firstContact);
59. clientTwo.addContact(firstContact);
60. }
61. catch (SessionException exc){
62. System.err.println("Exception encountered:");
63. System.err.println(exc);
64. }
65. try {
66. System.out.println("Adding a different contact to the second client");
67. clientTwo.addContact(secondContact);
68. System.out.println("Adding addresses to the first and second clients");
69. clientTwo.addAddress(workAddress);
70. clientOne.addAddress(homeAddress);
71. clientTwo.addAddress(workAddress);
72. clientTwo.addAddress(homeAddress);
73. System.out.println("Removing address from a client");
74. clientTwo.removeAddress(homeAddress);
75. System.out.println("Finalizing the edits to the contacts");
76. clientOne.commitChanges();
77. clientTwo.commitChanges();
78. System.out.println("Changes finalized");
79. clientTwo.addContact(firstContact);
80. }
81. catch (SessionException exc){
82. System.err.println("Exception encountered:");
83. System.err.println(exc);
84. }
85. System.out.println("The following lines will show the state");
86. System.out.println(" of the server-side delegate, which in this");
87. System.out.println(" example represents a persistent data store.");
88. System.out.println();
89. System.out.println("Contact list:");
90. System.out.println(SessionServerDelegate.getContacts());
91. System.out.println("Address list:");
92. System.out.println(SessionServerDelegate.getAddresses());
93. System.out.println("Edit contacts:");
94. System.out.println(SessionServerDelegate.getEditContacts());
95. }
96. }
 
Search WWH ::




Custom Search