KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > petstore > bo > ProductBOImpl


1 /*
2  * JFox - The most lightweight Java EE Application Server!
3  * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
4  *
5  * JFox is licenced and re-distributable under GNU LGPL.
6  */

7 package org.jfox.petstore.bo;
8
9 import java.sql.SQLException JavaDoc;
10 import java.util.List JavaDoc;
11 import javax.ejb.EJB JavaDoc;
12 import javax.ejb.EJBException JavaDoc;
13 import javax.ejb.Local JavaDoc;
14 import javax.ejb.Stateless JavaDoc;
15
16 import org.jfox.petstore.dao.ProductDAO;
17 import org.jfox.petstore.entity.Product;
18
19 /**
20  * @author <a HREF="mailto:jfox.young@gmail.com">Young Yang</a>
21  */

22 @Stateless JavaDoc
23 @Local JavaDoc
24 public class ProductBOImpl implements ProductBO{
25
26     @EJB JavaDoc
27     ProductDAO productDAO;
28
29     public List JavaDoc<Product> getProductsByCategory(String JavaDoc categoryId) {
30         try {
31             return productDAO.getProductListByCategory(categoryId);
32         }
33         catch(SQLException JavaDoc e) {
34             throw new EJBException JavaDoc(e);
35         }
36     }
37
38
39     public Product getProduct(String JavaDoc productId) {
40         try {
41             return productDAO.getProduct(productId);
42         }
43         catch(SQLException JavaDoc e) {
44             throw new EJBException JavaDoc(e);
45         }
46     }
47
48     public List JavaDoc<Product> searchProductList(String JavaDoc[] keywords) {
49         try {
50             String JavaDoc[] sqlKeyWords = new String JavaDoc[keywords.length];
51             for(int i=0; i< keywords.length; i++){
52                 String JavaDoc sqlKW = "%" + keywords[i] + "%";
53                 sqlKeyWords[i] = sqlKW;
54             }
55             return productDAO.searchProductList(sqlKeyWords);
56         }
57         catch(SQLException JavaDoc e) {
58             throw new EJBException JavaDoc(e);
59         }
60     }
61
62     public static void main(String JavaDoc[] args) {
63
64     }
65 }
66
Popular Tags