View Javadoc

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