1 7 package org.jfox.petstore.bo; 8 9 import java.util.List ; 10 import java.sql.SQLException ; 11 12 import javax.ejb.Stateless ; 13 import javax.ejb.Local ; 14 import javax.ejb.EJB ; 15 import javax.ejb.EJBException ; 16 17 import org.jfox.petstore.entity.Item; 18 import org.jfox.petstore.entity.Order; 19 import org.jfox.petstore.dao.ItemDAO; 20 21 24 @Stateless 25 @Local 26 public class ItemBOImpl implements ItemBO { 27 28 @EJB 29 ItemDAO itemDAO; 30 31 public List <Item> getItemListByProduct(String productId) { 32 try { 33 return itemDAO.getItemListByProduct(productId); 34 } 35 catch(SQLException e){ 36 throw new EJBException (e); 37 } 38 } 39 40 public Item getItem(String itemId) { 41 try { 42 return itemDAO.getItem(itemId); 43 } 44 catch(Exception e) { 45 return null; 46 } 47 } 48 49 public boolean isItemInStock(String itemId) { 50 try { 51 return itemDAO.getInventoryQuantity(itemId) > 0; 52 } 53 catch(Exception e){ 54 e.printStackTrace(); 55 return false; 56 } 57 } 58 59 public void updateQuantity(Order order) { 60 } 61 62 public static void main(String [] args) { 63 64 } 65 } 66 | Popular Tags |