01: /*
02: * NEMESIS-FORUM.
03: * Copyright (C) 2002 David Laurent(lithium2@free.fr). All rights reserved.
04: *
05: * Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
06: *
07: * Copyright (C) 2001 Yasna.com. All rights reserved.
08: *
09: * Copyright (C) 2000 CoolServlets.com. All rights reserved.
10: *
11: * NEMESIS-FORUM. is free software; you can redistribute it and/or
12: * modify it under the terms of the Apache Software License, Version 1.1,
13: * or (at your option) any later version.
14: *
15: * NEMESIS-FORUM core framework, NEMESIS-FORUM backoffice, NEMESIS-FORUM frontoffice
16: * application are parts of NEMESIS-FORUM and are distributed under
17: * same terms of licence.
18: *
19: *
20: * NEMESIS-FORUM includes software developed by the Apache Software Foundation (http://www.apache.org/)
21: * and software developed by CoolServlets.com (http://www.coolservlets.com).
22: * and software developed by Yasna.com (http://www.yasna.com).
23: *
24: */
25:
26: package org.nemesis.forum.util.jdbc;
27:
28: import java.sql.Connection;
29:
30: /**
31: * Abstract class that defines the connection provider framework. Other classes
32: * extend this abstract class to make connection to actual data sources.
33: */
34: public abstract class DbConnectionProvider {
35:
36: private static final boolean POOLED = false;
37:
38: /**
39: * Returns true if this connection provider provides connections out
40: * of a connection pool. Implementing and using connection providers that
41: * are pooled is strongly recommended, as they greatly increase the speed
42: * of Yazd.
43: *
44: * @return true if the Connection objects returned by this provider are
45: * pooled.
46: */
47: public boolean isPooled() {
48: return POOLED;
49: }
50:
51: /**
52: * Returns a database connection. When a Yazd component is done with a
53: * connection, it will call the close method of that connection. Therefore,
54: * connection pools with special release methods are not directly
55: * supported by the connection provider infrastructure. Instead, connections
56: * from those pools should be wrapped such that calling the close method
57: * on the wrapper class will release the connection from the pool.
58: *
59: * @return a Connection object.
60: */
61: public abstract Connection getConnection();
62:
63: /**
64: * Starts the connection provider. For some connection providers, this
65: * will be a no-op. However, connection provider users should always call
66: * this method to make sure the connection provider is started.
67: */
68: protected abstract void start();
69:
70: /**
71: * This method should be called whenever properties have been changed so
72: * that the changes will take effect.
73: */
74: protected abstract void restart();
75:
76: /**
77: * Tells the connection provider to destroy itself. For many connection
78: * providers, this will essentially result in a no-op. However,
79: * connection provider users should always call this method when changing
80: * from one connection provider to another to ensure that there are no
81: * dangling database connections.
82: */
83: protected abstract void destroy();
84:
85: }
|