KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xquark > mapper > AccessManager


1 /*
2  * This file belongs to the XQuark distribution.
3  * Copyright (C) 2003 Universite de Versailles Saint-Quentin.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307.
18  * You can also get it at http://www.gnu.org/licenses/lgpl.html
19  *
20  * For more information on this software, see http://www.xquark.org.
21  */

22
23 package org.xquark.mapper;
24
25 import org.xquark.xml.xdbc.XMLDBCException;
26 import org.xquark.xml.xdbc.XMLDriverManager;
27
28 /** This class is used for maintaining unicity of access to repositories.
29  * @deprecated The {@link RepositoryDataSource} or {@link RepositoryDriver}
30  * approach is preferred.
31  * @see org.xquark.mapper.RepositoryConnection
32  */

33 final public class AccessManager
34 {
35     private static final String JavaDoc RCSRevision = "$Revision: 1.1 $";
36     private static final String JavaDoc RCSName = "$Name: $";
37     
38     static
39     {
40         try
41         {
42             Class.forName("org.xquark.mapper.RepositoryDriver");
43         }
44         catch (ClassNotFoundException JavaDoc e)
45         {
46             // no op
47
}
48     }
49     
50     /** Constructor not accessible (factory model).
51      */

52     private AccessManager() {}
53     
54     /** Returns a RepositoryConnection object in order to access
55      * XQuark Repository features.
56      * You can open as many connections with the same parameters for use in a
57      * multi-threaded context for instance.
58      * <p><B>WARNING :</B>
59      * Do not use differents URL for connecting the same relational
60      * database or the AccessManager will consider different instances and
61      * allocate multiple RepositoryConnection instantiations leading
62      * to unpredictable results.</p>
63      * @param URL JDBC string containing driver and database specification.
64      * @param user rdbms user name.
65      * @param password login password for rdbms user.
66      * @throws java.sql.SQLException if a database-access error occurs.
67      * @throws RepositoryException API exception.
68      * @return the new RepositoryConnection object allocated.
69      * @see RepositoryConnection
70      */

71     public static synchronized RepositoryConnection connect(String JavaDoc URL, String JavaDoc user, String JavaDoc password)
72     throws XMLDBCException
73     {
74         return (RepositoryConnection)XMLDriverManager.getConnection(
75                                             RepositoryDriver.REPOSITORY_URL_PREFIX + URL,
76                                             user,
77                                             password
78                                             );
79     }
80 }
81
Popular Tags