01: /*
02: * HA-JDBC: High-Availability JDBC
03: * Copyright (c) 2004-2007 Paul Ferraro
04: *
05: * This library is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU Lesser General Public License as published by the
07: * Free Software Foundation; either version 2.1 of the License, or (at your
08: * option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13: * for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public License
16: * along with this library; if not, write to the Free Software Foundation,
17: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: *
19: * Contact: ferraro@users.sourceforge.net
20: */
21: package net.sf.hajdbc.sql;
22:
23: import java.lang.reflect.Method;
24: import java.sql.Connection;
25: import java.sql.SQLException;
26: import java.sql.Savepoint;
27: import java.util.Map;
28:
29: import net.sf.hajdbc.Database;
30:
31: /**
32: * @author Paul Ferraro
33: * @param <D>
34: */
35: public class SavepointInvocationHandler<D> extends
36: AbstractChildInvocationHandler<D, Connection, Savepoint> {
37: /**
38: * @param connection the connection that created this savepoint
39: * @param proxy the invocation handler of the connection that created this savepoint
40: * @param invoker the invoker used to create this savepoint
41: * @param savepointMap a map of database to underlying savepoint
42: * @throws Exception
43: */
44: protected SavepointInvocationHandler(Connection connection,
45: SQLProxy<D, Connection> proxy,
46: Invoker<D, Connection, Savepoint> invoker,
47: Map<Database<D>, Savepoint> savepointMap) throws Exception {
48: super (connection, proxy, invoker, Savepoint.class, savepointMap);
49: }
50:
51: /**
52: * @see net.sf.hajdbc.sql.AbstractChildInvocationHandler#getInvocationStrategy(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
53: */
54: @Override
55: protected InvocationStrategy<D, Savepoint, ?> getInvocationStrategy(
56: Savepoint object, Method method, Object[] parameters) {
57: return new DriverReadInvocationStrategy<D, Savepoint, Object>();
58: }
59:
60: /**
61: * @see net.sf.hajdbc.sql.AbstractChildInvocationHandler#close(java.lang.Object, java.lang.Object)
62: */
63: @Override
64: protected void close(Connection connection, Savepoint savepoint)
65: throws SQLException {
66: connection.releaseSavepoint(savepoint);
67: }
68: }
|