1 7 package org.jfox.petstore.bo; 8 9 import java.util.List ; 10 import java.util.Collections ; 11 import javax.ejb.Stateless ; 12 import javax.ejb.Local ; 13 import javax.ejb.EJB ; 14 import javax.ejb.EJBException ; 15 16 import org.jfox.petstore.entity.Account; 17 import org.jfox.petstore.dao.AccountDAO; 18 19 22 @Stateless 23 @Local 24 public class AccountBOImpl implements AccountBO { 25 26 @EJB 27 AccountDAO accountDAO; 28 29 public Account getAccount(String username) { 30 try { 31 return accountDAO.getAccount(username); 32 } 33 catch (Exception e) { 34 e.printStackTrace(); 35 return null; 36 } 37 } 38 39 public Account getAccount(String username, String password) { 40 try { 41 return accountDAO.getAccount(username, password); 42 } 43 catch (Exception e) { 44 e.printStackTrace(); 45 return null; 46 } 47 } 48 49 50 public void updateAccount(Account account) { 51 try { 52 accountDAO.updateAccount(account); 53 } 54 catch (Exception e) { 55 throw new EJBException (e); 56 } 57 } 58 59 60 public List <String > getUsernameList() { 61 try { 62 return accountDAO.getUsernameList(); 63 } 64 catch (Exception e) { 65 e.printStackTrace(); 66 return Collections.emptyList(); 67 } 68 } 69 70 public void insertAccount(Account account) { 71 try { 72 accountDAO.insertAccount(account); 73 } 74 catch (Exception e) { 75 throw new EJBException (e); 76 } 77 } 78 79 public static void main(String [] args) { 80 81 } 82 } 83 | Popular Tags |