KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jivesoftware > database > ConnectionProvider


1 /**
2  * $RCSfile: ConnectionProvider.java,v $
3  * $Revision: 1.1 $
4  * $Date: 2004/10/21 06:08:42 $
5  *
6  * Copyright (C) 2004 Jive Software. All rights reserved.
7  *
8  * This software is published under the terms of the GNU Public License (GPL),
9  * a copy of which is included in this distribution.
10  */

11
12 package org.jivesoftware.database;
13
14 import java.sql.Connection JavaDoc;
15 import java.sql.SQLException JavaDoc;
16
17 /**
18  * Abstract class that defines the connection provider framework. Other classes
19  * extend this abstract class to make connection to actual data sources.<p>
20  * <p/>
21  * It is expected that each subclass be a JavaBean, so that properties of
22  * the connection provider are exposed through bean introspection.
23  *
24  * @author Jive Software
25  */

26 public interface ConnectionProvider {
27
28     /**
29      * Returns true if this connection provider provides connections out
30      * of a connection pool. Implementing and using connection providers that
31      * are pooled is strongly recommended, as they greatly increase the speed
32      * of Jive.
33      *
34      * @return true if the Connection objects returned by this provider are
35      * pooled.
36      */

37     public boolean isPooled();
38
39     /**
40      * Returns a database connection. When a Jive component is done with a
41      * connection, it will call the close method of that connection. Therefore,
42      * connection pools with special release methods are not directly
43      * supported by the connection provider infrastructure. Instead, connections
44      * from those pools should be wrapped such that calling the close method
45      * on the wrapper class will release the connection from the pool.
46      *
47      * @return a Connection object.
48      */

49     public Connection JavaDoc getConnection() throws SQLException JavaDoc;
50
51     /**
52      * Starts the connection provider. For some connection providers, this
53      * will be a no-op. However, connection provider users should always call
54      * this method to make sure the connection provider is started.
55      */

56     public void start();
57
58     /**
59      * This method should be called whenever properties have been changed so
60      * that the changes will take effect.
61      */

62     public void restart();
63
64     /**
65      * Tells the connection provider to destroy itself. For many connection
66      * providers, this will essentially result in a no-op. However,
67      * connection provider users should always call this method when changing
68      * from one connection provider to another to ensure that there are no
69      * dangling database connections.
70      */

71     public void destroy();
72 }
Popular Tags