package com.ibatis.jpetstore.service;

import java.util.List;

import org.huihoo.jfox.soaf.container.ServiceFactory;
import org.huihoo.jfox.soaf.services.logging.LoggingService;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.jpetstore.domain.Account;
import com.ibatis.jpetstore.persistence.DaoConfig;
import com.ibatis.jpetstore.persistence.iface.AccountDao;

/**
 * <p/>Date: Mar 6, 2004 11:22:43 PM
 * 
 * @author Clinton Begin
 */
public class AccountServiceImpl implements AccountService {

    private LoggingService log = (LoggingService) ServiceFactory.getInstance()
            .getService(LoggingService.class);

    /* Private Fields */

    private DaoManager daoManager = DaoConfig.getDaomanager();

    private AccountDao accountDao;

    /* Constructors */

    public AccountServiceImpl() {
        accountDao = (AccountDao) daoManager.getDao(AccountDao.class);
        log.info("AccountDAO : " + accountDao);
    }

    /* ACCOUNT */

    public Account getAccount(String username) {
        log.info("Get Account **************");
        return accountDao.getAccount(username);
    }

    public Account getAccount(String username, String password) {
        return accountDao.getAccount(username, password);
    }

    public void insertAccount(Account account) {
        accountDao.insertAccount(account);
    }

    public void updateAccount(Account account) {
        log.info("Update Account **************");
        accountDao.updateAccount(account);
    }

    public List getUsernameList() {
        return accountDao.getUsernameList();
    }

}