01: /*
02: * Copyright 2004-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.lucene.store.jdbc.datasource;
18:
19: import java.io.PrintWriter;
20: import java.sql.SQLException;
21: import javax.sql.DataSource;
22:
23: /**
24: * Abstract base class for Spring's DataSource implementations, taking care of
25: * the "uninteresting" glue.
26: *
27: * @author kimchy
28: */
29: public abstract class AbstractDataSource implements DataSource {
30:
31: /**
32: * Returns 0: means use default system timeout.
33: */
34: public int getLoginTimeout() throws SQLException {
35: return 0;
36: }
37:
38: public void setLoginTimeout(int timeout) throws SQLException {
39: throw new UnsupportedOperationException("setLoginTimeout");
40: }
41:
42: /**
43: * LogWriter methods are unsupported.
44: */
45: public PrintWriter getLogWriter() {
46: throw new UnsupportedOperationException("getLogWriter");
47: }
48:
49: /**
50: * LogWriter methods are unsupported.
51: */
52: public void setLogWriter(PrintWriter pw) throws SQLException {
53: throw new UnsupportedOperationException("setLogWriter");
54: }
55:
56: //---------------------------------------------------------------------
57: // Implementation of JDBC 4.0's Wrapper interface
58: //---------------------------------------------------------------------
59:
60: public Object unwrap(Class iface) throws SQLException {
61: if (!DataSource.class.equals(iface)) {
62: throw new SQLException(
63: "DataSource of type ["
64: + getClass().getName()
65: + "] can only be unwrapped as [javax.sql.DataSource], not as ["
66: + iface.getName());
67: }
68: return this ;
69: }
70:
71: public boolean isWrapperFor(Class iface) throws SQLException {
72: return DataSource.class.equals(iface);
73: }
74: }
|