01: package com.jamonapi.proxy;
02:
03: import java.io.PrintWriter;
04: import java.io.Serializable;
05: import java.sql.Connection;
06: import java.sql.SQLException;
07:
08: import javax.sql.*;
09: import javax.naming.Referenceable;
10: import javax.naming.Reference;
11: import javax.naming.NamingException;
12:
13: /** The datasource is incomplete. the object factory is not done. It should
14: * be able to wrap an exisiting DataSource however.
15: * @author steve souza
16: *
17: */
18:
19: public class JAMonDataSource implements DataSource, Referenceable,
20: Serializable {
21: private DataSource realDataSource;
22:
23: public JAMonDataSource(DataSource realDataSource) {
24: this .realDataSource = realDataSource;
25: }
26:
27: public JAMonDataSource() {
28:
29: }
30:
31: /**
32: * Determines if a de-serialized file is compatible with this class.
33: *
34: * Maintainers must change this value if and only if the new version
35: * of this class is not compatible with old versions. See Sun docs
36: * for <a href=http://java.sun.com/products/jdk/1.1/docs/guide
37: * /serialization/spec/version.doc.html> details. </a>
38: *
39: * Not necessary to include in first version of the class, but
40: * included here as a reminder of its importance.
41: */
42: private static final long serialVersionUID = 0xABCDABC1;
43:
44: public Connection getConnection() throws SQLException {
45: return MonProxyFactory.monitor(realDataSource.getConnection());
46: }
47:
48: public Connection getConnection(String userName, String passWord)
49: throws SQLException {
50: return MonProxyFactory.monitor(realDataSource.getConnection(
51: userName, passWord));
52: }
53:
54: public int getLoginTimeout() throws SQLException {
55: return realDataSource.getLoginTimeout();
56: }
57:
58: public PrintWriter getLogWriter() throws SQLException {
59: return realDataSource.getLogWriter();
60: }
61:
62: public void setLoginTimeout(int seconds) throws SQLException {
63: realDataSource.setLoginTimeout(seconds);
64:
65: }
66:
67: public void setLogWriter(PrintWriter output) throws SQLException {
68: realDataSource.setLogWriter(output);
69:
70: }
71:
72: public Reference getReference() throws NamingException {
73: return ((Referenceable) realDataSource).getReference();
74: }
75:
76: }
|