Java Reference
In-Depth Information
71. updateStartDate = newStartDate;
72. currentAppointment = appointment;
73. return true;
74. }
75. return false;
76. }
77.
78. public boolean changeAppointment(Appointment appointment, Date[] possibleDates,
79. AppointmentTransactionParticipant[] participants, long transactionID){
80. try{
81. for (int i = 0; i < participants.length; i++){
82. if (!participants[i].join(transactionID)){
83. return false;
84. }
85. }
86. for (int i = 0; i < possibleDates.length; i++){
87. if (isDateAvailable(transactionID, appointment, possibleDates[i],
participants)){
88. try{
89. commitAll(transactionID, participants);
90. return true;
91. }
92. catch(TransactionException exc){ }
93. }
94. }
95. }
96. catch (RemoteException exc){ }
97. try{
98. cancelAll(transactionID, participants);
99. }
100. catch (RemoteException exc){}
101. return false;
102. }
103.
104. private boolean isDateAvailable(long transactionID, Appointment appointment,
105. Date date, AppointmentTransactionParticipant[] participants){
106. try{
107. for (int i = 0; i < participants.length; i++){
108. try{
109. if (!participants[i].changeDate(transactionID, appointment, date)){
110. return false;
111. }
112. }
113. catch (TransactionException exc){
114. return false;
115. }
116. }
117. }
118. catch (RemoteException exc){
119. return false;
120. }
121. return true;
122. }
123. private void commitAll(long transactionID, AppointmentTransactionParticipant[]
participants)
124. throws TransactionException, RemoteException{
125. for (int i = 0; i < participants.length; i++){
126. participants[i].commit(transactionID);
127. }
128. }
129. private void cancelAll(long transactionID, AppointmentTransactionParticipant[]
participants)
130. throws RemoteException{
131. for (int i = 0; i < participants.length; i++){
132. participants[i].cancel(transactionID);
133. }
134. }
135. public String toString(){
136. return serviceName + " " + appointments.values().toString();
137. }
138. }
Search WWH ::




Custom Search