@WebMethod
public void addValueToSet(String value) throws AlreadyInSetException, SetServiceException {
System.out.println("[SERVICE] invoked addValueToSet('" + value + "')");
BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();
/*
* get the transaction context of this thread:
*/
String transactionId;
try {
transactionId = activityManager.currentTransaction().toString();
} catch (SystemException e) {
throw new SetServiceException("Unable to lookup existing BusinesActivity", e);
}
/*
* Lookup existing participant or register new participant
*/
SetParticipantBA participantBA = SetParticipantBA.getParticipant(transactionId);
if (participantBA == null) {
try {
// enlist the Participant for this service:
SetParticipantBA participant = new SetParticipantBA(transactionId, value);
SetParticipantBA.recordParticipant(transactionId, participant);
System.out.println("[SERVICE] Enlisting a participant into the BA");
activityManager.enlistForBusinessAgreementWithCoordinatorCompletion(participant, "SetServiceBAImpl:"
+ UUID.randomUUID());
} catch (Exception e) {
System.err.println("Participant enlistment failed");
throw new SetServiceException("Error enlisting participant", e);
}