View Javadoc

1   /*
2    * Copyright 2000-2004 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.ibatis.jpetstore.service;
17  
18  import com.ibatis.dao.client.DaoManager;
19  import com.ibatis.jpetstore.domain.Account;
20  import com.ibatis.jpetstore.persistence.DaoConfig;
21  import com.ibatis.jpetstore.persistence.iface.AccountDao;
22  
23  import java.util.List;
24  
25  /***
26   * <p/>
27   * Date: Mar 6, 2004 11:22:43 PM
28   *
29   * @author Clinton Begin
30   */
31  public class AccountService {
32  
33    /* Constants */
34  
35    private static final AccountService instance = new AccountService();
36  
37    /* Private Fields */
38  
39    private DaoManager daoManager = DaoConfig.getDaomanager();
40  
41    private AccountDao accountDao;
42  
43    /* Constructors */
44  
45    public AccountService() {
46      accountDao = (AccountDao) daoManager.getDao(AccountDao.class);
47    }
48  
49    /* Public Methods */
50  
51    public static AccountService getInstance() {
52      return instance;
53    }
54  
55    /* ACCOUNT */
56  
57    public Account getAccount(String username) {
58      return accountDao.getAccount(username);
59    }
60  
61    public Account getAccount(String username, String password) {
62      return accountDao.getAccount(username, password);
63    }
64  
65    public void insertAccount(Account account) {
66      accountDao.insertAccount(account);
67    }
68  
69    public void updateAccount(Account account) {
70      accountDao.updateAccount(account);
71    }
72  
73    public List getUsernameList() {
74      return accountDao.getUsernameList();
75    }
76  
77  }