Listing 1
public interface Participant
{
public Vote prepare (Uid id, Qualifier[] qualifiers)
throws GeneralException, InvalidInferiorException,
WrongStateException, HeuristicHazardException,
HeuristicMixedException;


public void confirm (Uid id, Qualifier[] qualifiers)
throws GeneralException, InvalidInferiorException,
WrongStateException, HeuristicHazardException,
HeuristicMixedException, InferiorCancelledException;


public void cancel (Uid id, Qualifier[] qualifiers)
throws GeneralException, InvalidInferiorException,
WrongStateException, HeuristicHazardException,
HeuristicMixedException, InferiorConfirmedException;


public void contradiction (Uid id, Qualifier[] qualifiers)
throws GeneralException, InvalidInferiorException,
WrongStateException;

// Other methods...
}


Listing 2
// obtain a UserTransaction object (assume the factory is
// initialized)

UserTransaction userTransaction =
UserTransactionFactory.getTransaction();

// Obtain references to the web services we are going to use:
RestaurantService restaurant = new RestaurantService();
TaxiService taxi = new TaxiService();
TheatreService = new TheatreService():

// In a cohesion, we have to make an application-level mapping //of 
services to participants (outside of BTP scope). Our example // 
services support this.
String restaurantParticipantID = restaurant.getParticipantID();
String theatreParticipantID = theatre.getParticipantID();
String taxiParticipantID = taxi.getParticipantID();

// Start a new transaction, using a Cohesion
userTransaction.begin(com.hp.mw.xts.TxTypes.COHESION);

// Now invoke the business logic
restaurant.bookSeats(3);
theatre.bookSeats(3, 2);
taxi.bookTaxi();

// Prepare (all of) the participants (i.e. with null parameter)
StatusItem[] statusItems = userTransaction.prepare_inferiors(null);

// Iterate over the statuses, and make sure the taxi's pledged to 
honour the booking
boolean restuarantOK = false;
boolean taxiOK = false;
boolean theatreOK = false;
for(int i = 0; i < statusItems.length; i++)
{
if(statusItems[i].inferiorName().equals(restaurantParticipantID))
{
if(statusItems[i].status() == TwoPhaseStatus.PREPARED)
{
restaurantOK = true;
}
}

else if(statusItems[i].inferiorName().equals(taxiParticipantID))
{
if(statusItems[i].status() == TwoPhaseStatus.PREPARED)
{
taxiOK = true;
}
}

else if(statusItems[i].inferiorName().equals(theatreParticipantID))
{
if(statusItems[i].status() == TwoPhaseStatus.PREPARED)
{
theatreOK = true;
}
}
}

// If we can't get a taxi, then we have to call the whole // // event off.
if(!taxiOK)
{
ut.cancel(null); // Cancel everything
}
else if(restaurantOK || theatreOK)
{
ut.confirm(); // Confirm whatever is available
}
else
{
ut.cancel(null); // Can't get anywhere to go, cancel everything.
}