1 package com.ibatis.jpetstore.service; 2 3 import com.ibatis.common.util.PaginatedList; 4 import com.ibatis.dao.client.DaoManager; 5 import com.ibatis.jpetstore.domain.Category; 6 import com.ibatis.jpetstore.domain.Item; 7 import com.ibatis.jpetstore.domain.Product; 8 import com.ibatis.jpetstore.persistence.DaoConfig; 9 import com.ibatis.jpetstore.persistence.iface.CategoryDao; 10 import com.ibatis.jpetstore.persistence.iface.ItemDao; 11 import com.ibatis.jpetstore.persistence.iface.ProductDao; 12 13 import java.util.List ; 14 15 public class CatalogService { 16 17 18 19 private static final CatalogService instance = new CatalogService(); 20 21 22 23 private DaoManager daoManager = DaoConfig.getDaomanager(); 24 25 private CategoryDao categoryDao; 26 private ItemDao itemDao; 27 private ProductDao productDao; 28 29 30 31 private CatalogService() { 32 categoryDao = (CategoryDao) daoManager.getDao(CategoryDao.class); 33 productDao = (ProductDao) daoManager.getDao(ProductDao.class); 34 itemDao = (ItemDao) daoManager.getDao(ItemDao.class); 35 } 36 37 38 39 public static CatalogService getInstance() { 40 return instance; 41 } 42 43 44 45 public List getCategoryList() { 46 return categoryDao.getCategoryList(); 47 } 48 49 public Category getCategory(String categoryId) { 50 return categoryDao.getCategory(categoryId); 51 } 52 53 54 55 public Product getProduct(String productId) { 56 return productDao.getProduct(productId); 57 } 58 59 public PaginatedList getProductListByCategory(String categoryId) { 60 return productDao.getProductListByCategory(categoryId); 61 } 62 63 public PaginatedList searchProductList(String keywords) { 64 return productDao.searchProductList(keywords); 65 } 66 67 68 69 public PaginatedList getItemListByProduct(String productId) { 70 return itemDao.getItemListByProduct(productId); 71 } 72 73 public Item getItem(String itemId) { 74 return itemDao.getItem(itemId); 75 } 76 77 public boolean isItemInStock(String itemId) { 78 return itemDao.isItemInStock(itemId); 79 } 80 81 } | Popular Tags |