1 7 package org.jfox.petstore.bo; 8 9 import java.sql.SQLException ; 10 import java.util.List ; 11 import javax.ejb.EJB ; 12 import javax.ejb.EJBException ; 13 import javax.ejb.Local ; 14 import javax.ejb.Stateless ; 15 16 import org.jfox.petstore.dao.ProductDAO; 17 import org.jfox.petstore.entity.Product; 18 19 22 @Stateless 23 @Local 24 public class ProductBOImpl implements ProductBO{ 25 26 @EJB 27 ProductDAO productDAO; 28 29 public List <Product> getProductsByCategory(String categoryId) { 30 try { 31 return productDAO.getProductListByCategory(categoryId); 32 } 33 catch(SQLException e) { 34 throw new EJBException (e); 35 } 36 } 37 38 39 public Product getProduct(String productId) { 40 try { 41 return productDAO.getProduct(productId); 42 } 43 catch(SQLException e) { 44 throw new EJBException (e); 45 } 46 } 47 48 public List <Product> searchProductList(String [] keywords) { 49 try { 50 String [] sqlKeyWords = new String [keywords.length]; 51 for(int i=0; i< keywords.length; i++){ 52 String sqlKW = "%" + keywords[i] + "%"; 53 sqlKeyWords[i] = sqlKW; 54 } 55 return productDAO.searchProductList(sqlKeyWords); 56 } 57 catch(SQLException e) { 58 throw new EJBException (e); 59 } 60 } 61 62 public static void main(String [] args) { 63 64 } 65 } 66 | Popular Tags |