J2Weeeeeeeeeee

As strongbad would say, for good or for awesome…


@Path("/orders/")
@Interceptors(CallAudit.class)
@Stateless public class OrderService {

  @EJB BillingService billing;
  @EJB DeliveryService delivery;
  @EJB Warehouse warehouse;

  @PUT
  @Produces({"application/xml","application/json"})
  @Consumes({"application/xml","application/json"})
  public Order order(Order newOrder){
      Order order = warehouse.checkout(newOrder);
      billing.payForOrder(order);
      delivery.deliver(order);
      return order;
  }

  @GET
  @Path("{orderid}/")
  @Produces({"application/xml","application/json"})
  public Order status(@PathParam("orderid") long orderId){
     return delivery.status(orderId);
  }
}

Full details here