KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > sessions > Connector


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.sessions;
23
24 import java.util.*;
25 import java.sql.*;
26 import java.io.*;
27
28 /**
29  * <b>Purpose</b>:
30  * Define an interface for supplying TopLink with a <code>Connection</code> to
31  * a JDBC database.
32  * <p>
33  * <b>Description</b>:
34  * This interface defines the methods to be implemented that allow TopLink to
35  * acquire a <code>Connection</code> to a JDBC database. There are only 2
36  * methods that need to be implemented:
37  * <blockquote><code>
38  * java.sql.Connection connect(java.util.Properties properties)<br>
39  * void toString(java.io.PrintWriter writer)
40  * </code></blockquote>
41  * Once these methods have been implemented, an instance of the new
42  * <code>Connector</code> can be passed
43  * to a <code>JDBCLogin</code> at startup. For example:
44  * <blockquote><code>
45  * session.getLogin().setConnector(new FooConnector());<br>
46  * session.login();
47  * </code></blockquote>
48  *
49  * @see DatabaseLogin
50  * @author Big Country
51  * @since TOPLink/Java 2.1
52  */

53 public interface Connector extends Serializable, Cloneable JavaDoc {
54
55     /**
56      * PUBLIC:
57      * Must be cloneable.
58      */

59     Object JavaDoc clone();
60
61     /**
62      * PUBLIC:
63      * Connect with the specified properties and return the <code>Connection</code>.
64      * The properties are driver-specific; but usually contain the <code>"user"</code>
65      * and <code>"password"</code>. Additional
66      * properties can be built by using <code>JDBCLogin.setProperty(String propertyName,
67      * Object propertyValue)</code>.
68      * @return java.sql.Connection
69      */

70     Connection connect(Properties properties);
71
72     /**
73      * PUBLIC:
74      * Print something useful on the log. This information will be displayed
75      * on the TopLink log (by default <code>System.out</code>) at login.
76      * See the other implementations of this method for examples.
77      */

78     void toString(PrintWriter writer);
79
80     /**
81      * PUBLIC:
82      * Provide the details of my connection information. This is primarily for JMX runtime services.
83      * @return java.lang.String
84      */

85     String JavaDoc getConnectionDetails();
86 }
87
Popular Tags