Skip to content

Instantly share code, notes, and snippets.

View paulrobinson's full-sized avatar

Paul Robinson paulrobinson

  • Red Hat
  • Whitley Bay, UK
View GitHub Profile
@paulrobinson
paulrobinson / RestaurantParticipant.java
Created May 16, 2012 07:31
WS-AT without TXFramework
public class RestaurantParticipant implements Durable2PCParticipant {
Vote prepare() throws WrongStateException, SystemException;
void commit() throws WrongStateException, SystemException;
void rollback() throws WrongStateException, SystemException;
void unknown() throws SystemException;
void error() throws SystemException;
}
@AT(bridgeType=BridgeType.NONE)
@WebService
public class RestaurantServiceATImpl implements RestaurantServiceAT {
@WebMethod
@ServiceRequest
public void makeBooking() {
MockRestaurantManager.makeBooking();
}
@paulrobinson
paulrobinson / OrderParticipant.java
Created May 16, 2012 08:14
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) {
@paulrobinson
paulrobinson / OrderServiceBAImpl.java
Created May 16, 2012 08:22
WSBA with TXFramework
@BA
@WebService
public class OrderServiceBAImpl implements OrderServiceBA {
@DataManagement private Map txDataMap;
@WebMethod @ServiceRequest
public void placeOrder(String item) throws OrderServiceException {
txDataMap.put("value", item);
}
@paulrobinson
paulrobinson / BistroImpl.java
Created May 16, 2012 08:29
Bridging without TXFramework
@Stateless @Remote(Bistro.class)
@WebService()
@HandlerChain(file = "jaxws-handlers-server.xml")
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class BistroImpl implements Bistro
{
@PersistenceContext protected EntityManager em;
@WebMethod
@ServiceRequest
@paulrobinson
paulrobinson / BistroImpl.java
Created May 16, 2012 08:38
Bridging with TXFramework
@AT //By default bridge to JTA
@Stateless @Remote(Bistro.class)
@WebService()
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class BistroImpl implements Bistro
{
@PersistenceContext protected EntityManager em;
@WebMethod
@ServiceRequest
@paulrobinson
paulrobinson / RestaurantServiceATImpl.java
Created May 16, 2012 08:46
REST-AT with TXFramework
@AT(bridgeType=BridgeType.NONE)
@Path("/")
public class RestaurantServiceATImpl implements RestaurantServiceAT {
@POST
@ServiceRequest
public void makeBooking() {
MockRestaurantManager.makeBooking();
}
@BA
@WebService(serviceName = "OrderServiceBAService", portName = "OrderServiceBA", name = "OrderServiceBA", targetNamespace = "http://www.jboss.com/as/quickstarts/helloworld/wsba/participantcompletion/order")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@WebServlet("/OrderServiceBA")
public class OrderServiceBAImpl implements OrderServiceBA {
@WebMethod @ServiceRequest
@CompensatedBy(compensationMethod = "cancelOrder", confirmMethod = "confirmMethod2")
public void placeOrder(String item) throws OrderServiceException {
}
@paulrobinson
paulrobinson / BistroImpl.java
Created May 31, 2012 10:47
WSBA -> JTA Bridging with TXFramework
@BA
@Stateless @Remote(Bistro.class) @WebService()
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class BistroImpl implements Bistro
{
@DataManagement private Map txDataMap;
@PersistenceContext protected EntityManager em;
@WebMethod
@ServiceRequest
@paulrobinson
paulrobinson / BistroImpl.java
Created June 5, 2012 12:17
WSBA -> JTA Bridging with TXFramework (params)
@BA
@Stateless @Remote(Bistro.class) @WebService()
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class BistroImpl implements Bistro
{
@PersistenceContext protected EntityManager em;
@WebMethod
@ServiceRequest
public void bookSeats(int howMany) {