1 /***
2 * JFoxSOAF, Service-Oriented Application Framework
3 *
4 * Copyright (C) www.huihoo.org
5 *
6 * Distributable under GNU LGPL
7 *
8 * For more information, please visit: http://www.huihoo.org/jfox/jfoxsoaf
9 */
10
11 package org.huihoo.jfox.soaf.services.persistence;
12
13 import java.io.Reader;
14
15 import org.huihoo.jfox.soaf.exception.IbatisConfigurationException;
16
17 import com.ibatis.common.resources.Resources;
18 import com.ibatis.dao.client.DaoManager;
19 import com.ibatis.dao.client.DaoManagerBuilder;
20
21 /***
22 * <p>
23 * Ibatis persistence service wrapper.
24 * </p>
25 *
26 * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
27 * @version $Revision: 1.2 $ $Date: 2004/11/16 07:58:12 $
28 * @version Revision: 1.0
29 */
30
31 public class IbatisServiceImpl implements IbatisService {
32
33 private DaoManager daoManager;
34
35 /***
36 * Defalut Constructor.
37 */
38 public IbatisServiceImpl() {
39 try {
40 String resource = "ibatis-dao.xml";
41 Reader reader = Resources.getResourceAsReader(resource);
42 daoManager = DaoManagerBuilder.buildDaoManager(reader);
43 } catch (Exception e) {
44 throw new IbatisConfigurationException(
45 "Could not initialize Ibatis DaoConfig. Cause: " + e);
46 }
47 }
48
49 /***
50 * @see org.huihoo.jfox.soaf.services.persistence.IbatisService#getDaoManager()
51 */
52 public DaoManager getDaoManager() {
53 return this.daoManager;
54 }
55
56 }