<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDesign_Pattern%2FTransaction_Pattern</id>
		<title>Java/Design Pattern/Transaction Pattern - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FDesign_Pattern%2FTransaction_Pattern"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Design_Pattern/Transaction_Pattern&amp;action=history"/>
		<updated>2026-04-22T05:00:47Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Design_Pattern/Transaction_Pattern&amp;diff=7833&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Design_Pattern/Transaction_Pattern&amp;diff=7833&amp;oldid=prev"/>
				<updated>2010-06-01T06:51:02Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:51, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Design_Pattern/Transaction_Pattern&amp;diff=7832&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Design_Pattern/Transaction_Pattern&amp;diff=7832&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:45Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Transaction Pattern Demo ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
//[C] 2002 Sun Microsystems, Inc.---&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.Serializable;&lt;br /&gt;
import java.rmi.Naming;&lt;br /&gt;
import java.rmi.Remote;&lt;br /&gt;
import java.rmi.RemoteException;&lt;br /&gt;
import java.rmi.server.UnicastRemoteObject;&lt;br /&gt;
import java.util.ArrayList;&lt;br /&gt;
import java.util.Calendar;&lt;br /&gt;
import java.util.Date;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
public class RunTransactionPattern {&lt;br /&gt;
  private static Calendar dateCreator = Calendar.getInstance();&lt;br /&gt;
  public static void main(String[] arguments) {&lt;br /&gt;
    System.out.println(&amp;quot;Example for the Transaction pattern&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;This code example shows how a Transaction can&amp;quot;);&lt;br /&gt;
    System.out&lt;br /&gt;
        .println(&amp;quot; be applied to support change across a distributed&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot; system. In ths case, a distributed transaction&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot; is used to coordinate the change of dates in&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot; appointment books.&amp;quot;);&lt;br /&gt;
    System.out.println(&amp;quot;Running the RMI compiler (rmic)&amp;quot;);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    try {&lt;br /&gt;
      Process p1 = Runtime.getRuntime().exec(&amp;quot;rmic AppointmentBook&amp;quot;);&lt;br /&gt;
      p1.waitFor();&lt;br /&gt;
    } catch (IOException exc) {&lt;br /&gt;
      System.err&lt;br /&gt;
          .println(&amp;quot;Unable to run rmic utility. Exiting application.&amp;quot;);&lt;br /&gt;
      System.exit(1);&lt;br /&gt;
    } catch (InterruptedException exc) {&lt;br /&gt;
      System.err&lt;br /&gt;
          .println(&amp;quot;Threading problems encountered while using the rmic utility.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(&amp;quot;Starting the rmiregistry&amp;quot;);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    try {&lt;br /&gt;
      Process rmiProcess = Runtime.getRuntime().exec(&amp;quot;rmiregistry&amp;quot;);&lt;br /&gt;
      Thread.sleep(15000);&lt;br /&gt;
    } catch (IOException exc) {&lt;br /&gt;
      System.err&lt;br /&gt;
          .println(&amp;quot;Unable to start the rmiregistry. Exiting application.&amp;quot;);&lt;br /&gt;
      System.exit(1);&lt;br /&gt;
    } catch (InterruptedException exc) {&lt;br /&gt;
      System.err&lt;br /&gt;
          .println(&amp;quot;Threading problems encountered when starting the rmiregistry.&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(&amp;quot;Creating three appointment books&amp;quot;);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    AppointmentBook apptBookOne = new AppointmentBook();&lt;br /&gt;
    AppointmentBook apptBookTwo = new AppointmentBook();&lt;br /&gt;
    AppointmentBook apptBookThree = new AppointmentBook();&lt;br /&gt;
    System.out.println(&amp;quot;Creating appointments&amp;quot;);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    Appointment apptOne = new AppointmentImpl(&lt;br /&gt;
        &amp;quot;Swim relay to Kalimantan (or Java)&amp;quot;, new ArrayList(),&lt;br /&gt;
        new LocationImpl(&amp;quot;Sidney, Australia&amp;quot;), createDate(2001, 11, 5,&lt;br /&gt;
            11, 0));&lt;br /&gt;
    Appointment apptTwo = new AppointmentImpl(&lt;br /&gt;
        &amp;quot;Conference on World Patternization&amp;quot;, new ArrayList(),&lt;br /&gt;
        new LocationImpl(&amp;quot;London, England&amp;quot;), createDate(2001, 11, 5,&lt;br /&gt;
            14, 0));&lt;br /&gt;
    Appointment apptThree = new AppointmentImpl(&lt;br /&gt;
        &amp;quot;Society for the Preservation of Java - Annual Outing&amp;quot;,&lt;br /&gt;
        new ArrayList(), new LocationImpl(&amp;quot;Kyzyl, Tuva&amp;quot;), createDate(&lt;br /&gt;
            2001, 11, 5, 10, 0));&lt;br /&gt;
    System.out.println(&amp;quot;Adding appointments to the appointment books&amp;quot;);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    apptBookOne.addAppointment(apptThree);&lt;br /&gt;
    apptBookTwo.addAppointment(apptOne);&lt;br /&gt;
    apptBookOne.addAppointment(apptTwo);&lt;br /&gt;
    apptBookTwo.addAppointment(apptTwo);&lt;br /&gt;
    apptBookThree.addAppointment(apptTwo);&lt;br /&gt;
    System.out.println(&amp;quot;AppointmentBook contents:&amp;quot;);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    System.out.println(apptBookOne);&lt;br /&gt;
    System.out.println(apptBookTwo);&lt;br /&gt;
    System.out.println(apptBookThree);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    System.out.println(&amp;quot;Rescheduling an appointment&amp;quot;);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    boolean result = apptBookThree.changeAppointment(apptTwo, getDates(&lt;br /&gt;
        2001, 11, 5, 10, 3), lookUpParticipants(new String[] {&lt;br /&gt;
        apptBookOne.getUrl(), apptBookTwo.getUrl(),&lt;br /&gt;
        apptBookThree.getUrl() }), 20000L);&lt;br /&gt;
    System.out.println(&amp;quot;Result of rescheduling was &amp;quot; + result);&lt;br /&gt;
    System.out.println(&amp;quot;AppointmentBook contents:&amp;quot;);&lt;br /&gt;
    System.out.println();&lt;br /&gt;
    System.out.println(apptBookOne);&lt;br /&gt;
    System.out.println(apptBookTwo);&lt;br /&gt;
    System.out.println(apptBookThree);&lt;br /&gt;
  }&lt;br /&gt;
  private static AppointmentTransactionParticipant[] lookUpParticipants(&lt;br /&gt;
      String[] remoteUrls) {&lt;br /&gt;
    AppointmentTransactionParticipant[] returnValues = new AppointmentTransactionParticipant[remoteUrls.length];&lt;br /&gt;
    for (int i = 0; i &amp;lt; remoteUrls.length; i++) {&lt;br /&gt;
      try {&lt;br /&gt;
        returnValues[i] = (AppointmentTransactionParticipant) Naming&lt;br /&gt;
            .lookup(remoteUrls[i]);&lt;br /&gt;
      } catch (Exception exc) {&lt;br /&gt;
        System.out&lt;br /&gt;
            .println(&amp;quot;Error using RMI to look up a transaction participant&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    return returnValues;&lt;br /&gt;
  }&lt;br /&gt;
  private static Date[] getDates(int year, int month, int day, int hour,&lt;br /&gt;
      int increment) {&lt;br /&gt;
    Date[] returnDates = new Date[increment];&lt;br /&gt;
    for (int i = 0; i &amp;lt; increment; i++) {&lt;br /&gt;
      returnDates[i] = createDate(year, month, day, hour + i, 0);&lt;br /&gt;
    }&lt;br /&gt;
    return returnDates;&lt;br /&gt;
  }&lt;br /&gt;
  public static Date createDate(int year, int month, int day, int hour,&lt;br /&gt;
      int minute) {&lt;br /&gt;
    dateCreator.set(year, month, day, hour, minute);&lt;br /&gt;
    return dateCreator.getTime();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface Location extends Serializable {&lt;br /&gt;
  public String getLocation();&lt;br /&gt;
  public void setLocation(String newLocation);&lt;br /&gt;
}&lt;br /&gt;
class LocationImpl implements Location {&lt;br /&gt;
  private String location;&lt;br /&gt;
  public LocationImpl() {&lt;br /&gt;
  }&lt;br /&gt;
  public LocationImpl(String newLocation) {&lt;br /&gt;
    location = newLocation;&lt;br /&gt;
  }&lt;br /&gt;
  public String getLocation() {&lt;br /&gt;
    return location;&lt;br /&gt;
  }&lt;br /&gt;
  public void setLocation(String newLocation) {&lt;br /&gt;
    location = newLocation;&lt;br /&gt;
  }&lt;br /&gt;
  public String toString() {&lt;br /&gt;
    return location;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface Contact extends Serializable {&lt;br /&gt;
  public static final String SPACE = &amp;quot; &amp;quot;;&lt;br /&gt;
  public String getFirstName();&lt;br /&gt;
  public String getLastName();&lt;br /&gt;
  public String getTitle();&lt;br /&gt;
  public String getOrganization();&lt;br /&gt;
  public void setFirstName(String newFirstName);&lt;br /&gt;
  public void setLastName(String newLastName);&lt;br /&gt;
  public void setTitle(String newTitle);&lt;br /&gt;
  public void setOrganization(String newOrganization);&lt;br /&gt;
}&lt;br /&gt;
class ContactImpl implements Contact {&lt;br /&gt;
  private String firstName;&lt;br /&gt;
  private String lastName;&lt;br /&gt;
  private String title;&lt;br /&gt;
  private String organization;&lt;br /&gt;
  public ContactImpl() {&lt;br /&gt;
  }&lt;br /&gt;
  public ContactImpl(String newFirstName, String newLastName,&lt;br /&gt;
      String newTitle, String newOrganization) {&lt;br /&gt;
    firstName = newFirstName;&lt;br /&gt;
    lastName = newLastName;&lt;br /&gt;
    title = newTitle;&lt;br /&gt;
    organization = newOrganization;&lt;br /&gt;
  }&lt;br /&gt;
  public String getFirstName() {&lt;br /&gt;
    return firstName;&lt;br /&gt;
  }&lt;br /&gt;
  public String getLastName() {&lt;br /&gt;
    return lastName;&lt;br /&gt;
  }&lt;br /&gt;
  public String getTitle() {&lt;br /&gt;
    return title;&lt;br /&gt;
  }&lt;br /&gt;
  public String getOrganization() {&lt;br /&gt;
    return organization;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFirstName(String newFirstName) {&lt;br /&gt;
    firstName = newFirstName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setLastName(String newLastName) {&lt;br /&gt;
    lastName = newLastName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setTitle(String newTitle) {&lt;br /&gt;
    title = newTitle;&lt;br /&gt;
  }&lt;br /&gt;
  public void setOrganization(String newOrganization) {&lt;br /&gt;
    organization = newOrganization;&lt;br /&gt;
  }&lt;br /&gt;
  public String toString() {&lt;br /&gt;
    return firstName + SPACE + lastName;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface Appointment extends Serializable {&lt;br /&gt;
  public static final String EOL_STRING = System&lt;br /&gt;
      .getProperty(&amp;quot;line.separator&amp;quot;);&lt;br /&gt;
  public Date getStartDate();&lt;br /&gt;
  public String getDescription();&lt;br /&gt;
  public ArrayList getAttendees();&lt;br /&gt;
  public Location getLocation();&lt;br /&gt;
  public void setDescription(String newDescription);&lt;br /&gt;
  public void setLocation(Location newLocation);&lt;br /&gt;
  public void setStartDate(Date newStartDate);&lt;br /&gt;
  public void setAttendees(ArrayList newAttendees);&lt;br /&gt;
  public void addAttendee(Contact attendee);&lt;br /&gt;
  public void removeAttendee(Contact attendee);&lt;br /&gt;
}&lt;br /&gt;
class AppointmentImpl implements Appointment {&lt;br /&gt;
  private Date startDate;&lt;br /&gt;
  private String description;&lt;br /&gt;
  private ArrayList attendees = new ArrayList();&lt;br /&gt;
  private Location location;&lt;br /&gt;
  public AppointmentImpl(String newDescription, ArrayList newAttendees,&lt;br /&gt;
      Location newLocation, Date newStartDate) {&lt;br /&gt;
    description = newDescription;&lt;br /&gt;
    attendees = newAttendees;&lt;br /&gt;
    location = newLocation;&lt;br /&gt;
    startDate = newStartDate;&lt;br /&gt;
  }&lt;br /&gt;
  public Date getStartDate() {&lt;br /&gt;
    return startDate;&lt;br /&gt;
  }&lt;br /&gt;
  public String getDescription() {&lt;br /&gt;
    return description;&lt;br /&gt;
  }&lt;br /&gt;
  public ArrayList getAttendees() {&lt;br /&gt;
    return attendees;&lt;br /&gt;
  }&lt;br /&gt;
  public Location getLocation() {&lt;br /&gt;
    return location;&lt;br /&gt;
  }&lt;br /&gt;
  public void setDescription(String newDescription) {&lt;br /&gt;
    description = newDescription;&lt;br /&gt;
  }&lt;br /&gt;
  public void setLocation(Location newLocation) {&lt;br /&gt;
    location = newLocation;&lt;br /&gt;
  }&lt;br /&gt;
  public void setStartDate(Date newStartDate) {&lt;br /&gt;
    startDate = newStartDate;&lt;br /&gt;
  }&lt;br /&gt;
  public void setAttendees(ArrayList newAttendees) {&lt;br /&gt;
    if (newAttendees != null) {&lt;br /&gt;
      attendees = newAttendees;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void addAttendee(Contact attendee) {&lt;br /&gt;
    if (!attendees.contains(attendee)) {&lt;br /&gt;
      attendees.add(attendee);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void removeAttendee(Contact attendee) {&lt;br /&gt;
    attendees.remove(attendee);&lt;br /&gt;
  }&lt;br /&gt;
  public int hashCode() {&lt;br /&gt;
    return description.hashCode() ^ startDate.hashCode();&lt;br /&gt;
  }&lt;br /&gt;
  public boolean equals(Object object) {&lt;br /&gt;
    if (!(object instanceof AppointmentImpl)) {&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    if (object.hashCode() != hashCode()) {&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  public String toString() {&lt;br /&gt;
    return &amp;quot;  Description: &amp;quot; + description + EOL_STRING + &amp;quot;  Start Date: &amp;quot;&lt;br /&gt;
        + startDate + EOL_STRING + &amp;quot;  Location: &amp;quot; + location&lt;br /&gt;
        + EOL_STRING + &amp;quot;  Attendees: &amp;quot; + attendees;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class AppointmentBook implements AppointmentTransactionParticipant {&lt;br /&gt;
  private static final String TRANSACTION_SERVICE_PREFIX = &amp;quot;transactionParticipant&amp;quot;;&lt;br /&gt;
  private static final String TRANSACTION_HOSTNAME = &amp;quot;localhost&amp;quot;;&lt;br /&gt;
  private static int index = 1;&lt;br /&gt;
  private String serviceName = TRANSACTION_SERVICE_PREFIX + index++;&lt;br /&gt;
  private HashMap appointments = new HashMap();&lt;br /&gt;
  private long currentTransaction;&lt;br /&gt;
  private Appointment currentAppointment;&lt;br /&gt;
  private Date updateStartDate;&lt;br /&gt;
  public AppointmentBook() {&lt;br /&gt;
    try {&lt;br /&gt;
      UnicastRemoteObject.exportObject(this);&lt;br /&gt;
      Naming.rebind(serviceName, this);&lt;br /&gt;
    } catch (Exception exc) {&lt;br /&gt;
      System.err&lt;br /&gt;
          .println(&amp;quot;Error using RMI to register the AppointmentBook &amp;quot;&lt;br /&gt;
              + exc);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public String getUrl() {&lt;br /&gt;
    return &amp;quot;//&amp;quot; + TRANSACTION_HOSTNAME + &amp;quot;/&amp;quot; + serviceName;&lt;br /&gt;
  }&lt;br /&gt;
  public void addAppointment(Appointment appointment) {&lt;br /&gt;
    if (!appointments.containsValue(appointment)) {&lt;br /&gt;
      if (!appointments.containsKey(appointment.getStartDate())) {&lt;br /&gt;
        appointments.put(appointment.getStartDate(), appointment);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void removeAppointment(Appointment appointment) {&lt;br /&gt;
    if (appointments.containsValue(appointment)) {&lt;br /&gt;
      appointments.remove(appointment.getStartDate());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public boolean join(long transactionID) {&lt;br /&gt;
    if (currentTransaction != 0) {&lt;br /&gt;
      return false;&lt;br /&gt;
    } else {&lt;br /&gt;
      currentTransaction = transactionID;&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void commit(long transactionID) throws TransactionException {&lt;br /&gt;
    if (currentTransaction != transactionID) {&lt;br /&gt;
      throw new TransactionException(&amp;quot;Invalid TransactionID&amp;quot;);&lt;br /&gt;
    } else {&lt;br /&gt;
      removeAppointment(currentAppointment);&lt;br /&gt;
      currentAppointment.setStartDate(updateStartDate);&lt;br /&gt;
      appointments.put(updateStartDate, currentAppointment);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public void cancel(long transactionID) {&lt;br /&gt;
    if (currentTransaction == transactionID) {&lt;br /&gt;
      currentTransaction = 0;&lt;br /&gt;
      appointments.remove(updateStartDate);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public boolean changeDate(long transactionID, Appointment appointment,&lt;br /&gt;
      Date newStartDate) throws TransactionException {&lt;br /&gt;
    if ((appointments.containsValue(appointment))&lt;br /&gt;
        &amp;amp;&amp;amp; (!appointments.containsKey(newStartDate))) {&lt;br /&gt;
      appointments.put(newStartDate, null);&lt;br /&gt;
      updateStartDate = newStartDate;&lt;br /&gt;
      currentAppointment = appointment;&lt;br /&gt;
      return true;&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  public boolean changeAppointment(Appointment appointment,&lt;br /&gt;
      Date[] possibleDates,&lt;br /&gt;
      AppointmentTransactionParticipant[] participants, long transactionID) {&lt;br /&gt;
    try {&lt;br /&gt;
      for (int i = 0; i &amp;lt; participants.length; i++) {&lt;br /&gt;
        if (!participants[i].join(transactionID)) {&lt;br /&gt;
          return false;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      for (int i = 0; i &amp;lt; possibleDates.length; i++) {&lt;br /&gt;
        if (isDateAvailable(transactionID, appointment,&lt;br /&gt;
            possibleDates[i], participants)) {&lt;br /&gt;
          try {&lt;br /&gt;
            commitAll(transactionID, participants);&lt;br /&gt;
            return true;&lt;br /&gt;
          } catch (TransactionException exc) {&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    } catch (RemoteException exc) {&lt;br /&gt;
    }&lt;br /&gt;
    try {&lt;br /&gt;
      cancelAll(transactionID, participants);&lt;br /&gt;
    } catch (RemoteException exc) {&lt;br /&gt;
    }&lt;br /&gt;
    return false;&lt;br /&gt;
  }&lt;br /&gt;
  private boolean isDateAvailable(long transactionID,&lt;br /&gt;
      Appointment appointment, Date date,&lt;br /&gt;
      AppointmentTransactionParticipant[] participants) {&lt;br /&gt;
    try {&lt;br /&gt;
      for (int i = 0; i &amp;lt; participants.length; i++) {&lt;br /&gt;
        try {&lt;br /&gt;
          if (!participants[i].changeDate(transactionID, appointment,&lt;br /&gt;
              date)) {&lt;br /&gt;
            return false;&lt;br /&gt;
          }&lt;br /&gt;
        } catch (TransactionException exc) {&lt;br /&gt;
          return false;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    } catch (RemoteException exc) {&lt;br /&gt;
      return false;&lt;br /&gt;
    }&lt;br /&gt;
    return true;&lt;br /&gt;
  }&lt;br /&gt;
  private void commitAll(long transactionID,&lt;br /&gt;
      AppointmentTransactionParticipant[] participants)&lt;br /&gt;
      throws TransactionException, RemoteException {&lt;br /&gt;
    for (int i = 0; i &amp;lt; participants.length; i++) {&lt;br /&gt;
      participants[i].rumit(transactionID);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  private void cancelAll(long transactionID,&lt;br /&gt;
      AppointmentTransactionParticipant[] participants)&lt;br /&gt;
      throws RemoteException {&lt;br /&gt;
    for (int i = 0; i &amp;lt; participants.length; i++) {&lt;br /&gt;
      participants[i].cancel(transactionID);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  public String toString() {&lt;br /&gt;
    return serviceName + &amp;quot; &amp;quot; + appointments.values().toString();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
interface AppointmentTransactionParticipant extends Remote {&lt;br /&gt;
  public boolean join(long transactionID) throws RemoteException;&lt;br /&gt;
  public void commit(long transactionID) throws TransactionException,&lt;br /&gt;
      RemoteException;&lt;br /&gt;
  public void cancel(long transactionID) throws RemoteException;&lt;br /&gt;
  public boolean changeDate(long transactionID, Appointment appointment,&lt;br /&gt;
      Date newStartDate) throws TransactionException, RemoteException;&lt;br /&gt;
}&lt;br /&gt;
class TransactionException extends Exception {&lt;br /&gt;
  public TransactionException(String msg) {&lt;br /&gt;
    super(msg);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>