public class POProcessBean implements SessionBean {
  public Order order(String shipId, String billId, String sku, int quantity) throws POProcessException
  {
    try {
      Product product = productHome.findByPrimaryKey(sku);
      if (quantity>product.getInStock()) {
        throw( new POProcessException("Stock is not enough"));
      }
      product.setInStock(product.getInStock() - quantity);
      Order order = orderHome.create(""+System.currentTimeMillis());
      System.out.println("order class: " + order.getClass() );
      order.setBillTo(billId);
      order.setShipTo(shipId);
      order.setSKU(sku);
      order.setProductName(product.getName());
      order.setQuantity(quantity);
      int total=quantity*product.getPrice();
      order.setTotalPrice(total);
      if (total>MAX_TOTAL) {
        throw( new POProcessException("Exceed the max charge ("+MAX_TOTAL+")"));
      }
      return order;
    } catch (POProcessException e) {
      mySessionContext.setRollbackOnly();
      throw e;
    } catch (RemoteException e) {
      throw new EJBException("Fail in Order.order: " +e.getMessage());
    } catch (CreateException e) {
      throw new EJBException("Fail in Order.order: " +e.getMessage());
    } catch (FinderException e) {
      throw new EJBException("Fail in Order.order: " +e.getMessage());
    }
  }
}
