Skip to content

Instantly share code, notes, and snippets.

@paulrobinson
Created May 16, 2012 08:14
Show Gist options
  • Save paulrobinson/2708619 to your computer and use it in GitHub Desktop.
Save paulrobinson/2708619 to your computer and use it in GitHub Desktop.
WS-BA without TXFramework
public class OrderParticipant implements
BusinessAgreementWithCoordinatorCompletionParticipant,
ConfirmCompletedParticipant {
void compensate() throws FaultedException, WrongStateException, SystemException {
EmailSender.sendEmail("Unfortunately, we have had to cancel your order for item: " +
MockOrderManager.getItem());
}
void confirmCompleted(boolean confirmed) {
if (confirmed)
EmailSender.sendEmail("Your order is now confirmed for the following item: " +
MockOrderManager.getItem());
}
@Deprecated
void unknown() throws SystemException {...}
String status() throws SystemException {...}
void error() throws SystemException {...}
void close() throws WrongStateException, SystemException {...}
void cancel() throws FaultedException, WrongStateException, SystemException {...}
}
@WebService
@HandlerChain(file="/context-handlers.xml", name="Context Handlers")
public class OrderServiceBAImpl implements OrderServiceBA {
@WebMethod
public void placeOrder(String item) throws OrderServiceException {
BAParticipantManager participantManager;
try {
OrderParticipant participant = new OrderParticipant(value);
BusinessActivityManager am =
BusinessActivityManagerFactory.businessActivityManager();
am.enlistForBusinessAgreementWithCoordinatorCompletion(
participant, "OrderServiceBAImpl:" + UUID.randomUUID());
} catch (Exception e) {
throw new OrderServiceException("Error enlisting participant", e);
}
MockOrderManager.registerOrder(item);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment