KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > core > persist > db > DatabaseFactoryImpl


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: DatabaseFactoryImpl.java,v 1.17 2007/01/07 06:14:18 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.core.persist.db;
23
24 import org.opensubsystems.core.error.OSSException;
25
26 /**
27  * Base class for all database factories. This class is mainly collecting reusable
28  * code that can be useful for other factories.
29  *
30  * @version $Id: DatabaseFactoryImpl.java,v 1.17 2007/01/07 06:14:18 bastafidli Exp $
31  * @author Miroslav Halas
32  * @code.reviewer Miroslav Halas
33  * @code.reviewed 1.6 2004/12/06 21:56:24 jlegeny
34  */

35 public abstract class DatabaseFactoryImpl implements DatabaseFactory
36 {
37    // Cached values ////////////////////////////////////////////////////////////
38

39    /**
40     * Connection factory to use to get connections to the database.
41     */

42    protected DatabaseConnectionFactory m_connectionFactory;
43    
44    /**
45     * Transaction factory to use to manage transactions on database connections.
46     */

47    protected DatabaseTransactionFactory m_transactionFactory;
48    
49    /**
50     * Result set type to use load list, see ResultSet.TYPE_XXX constants.
51     */

52    protected int m_iTypeSelectListResultSet;
53    
54    /**
55     * Result set concurrency to use load list, see ResultSet.CONCUR_XXX constants.
56     */

57    protected int m_iConcurrencySelectListResultSet;
58    
59    /**
60     * Data type code for DataObject.
61     */

62    protected int m_iDataType;
63    
64    // Constructors /////////////////////////////////////////////////////////////
65

66    /**
67     * Default constructor
68     *
69     * @param iDataType - data type the factory will be used for
70     * @throws OSSException - an error has occured
71     */

72    public DatabaseFactoryImpl(
73       int iDataType
74    ) throws OSSException
75    {
76       super();
77       
78       m_connectionFactory = DatabaseConnectionFactoryImpl.getInstance();
79       m_transactionFactory = DatabaseTransactionFactoryImpl.getInstance();
80       m_iDataType = iDataType;
81
82       Database activeDB;
83       
84       activeDB = DatabaseImpl.getInstance();
85       m_iTypeSelectListResultSet = activeDB.getSelectListResultSetType();
86       m_iConcurrencySelectListResultSet = activeDB.getSelectListResultSetConcurrency();
87    }
88
89    /**
90     * @return int - result set concurrency to use load list,
91     * see ResultSet.CONCUR_XXX constants.
92     */

93    public int getConcurrencySelectListResultSet(
94    )
95    {
96       return m_iConcurrencySelectListResultSet;
97    }
98
99    /**
100     * @return int - Result set type to use load list,
101     * see ResultSet.TYPE_XXX constants.
102     */

103    public int getTypeSelectListResultSet(
104    )
105    {
106       return m_iTypeSelectListResultSet;
107    }
108    
109    /**
110     * Get data type code for DataObject.
111     *
112     * @return int - unique data type code
113     */

114    public int getDataType()
115    {
116       return m_iDataType;
117    }
118 }
119
Popular Tags