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.persistence;
17  
18  import com.ibatis.common.resources.Resources;
19  import com.ibatis.dao.client.DaoManager;
20  import com.ibatis.dao.client.DaoManagerBuilder;
21  
22  import java.io.Reader;
23  
24  /***
25   * <p/>
26   * Date: Mar 6, 2004 11:24:18 PM
27   *
28   * @author Clinton Begin
29   */
30  public class DaoConfig {
31  
32    private static final DaoManager daoManager;
33  
34    static {
35  
36      try {
37        String resource = "com/ibatis/jpetstore/persistence/dao.xml";
38        Reader reader = Resources.getResourceAsReader(resource);
39        daoManager = DaoManagerBuilder.buildDaoManager(reader);
40      } catch (Exception e) {
41        throw new RuntimeException("Could not initialize DaoConfig.  Cause: " + e);
42      }
43    }
44  
45    public static DaoManager getDaomanager() {
46      return daoManager;
47    }
48  
49  }