01: /*
02: * HA-JDBC: High-Availability JDBC
03: * Copyright (c) 2004-2008 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.sql.Connection;
24: import java.sql.SQLException;
25:
26: /**
27: * Decorates and invocation strategy with transaction boundary logic.
28: * @author Paul Ferraro
29: * @param <D> DataSource or Driver
30: */
31: public interface TransactionContext<D> {
32: /**
33: * Decorates the specified invocation strategy with start transaction logic.
34: * @param <T> Target object type of the invocation
35: * @param <R> Return type of this invocation
36: * @param strategy
37: * @param connection
38: * @return the decorated invocation strategy
39: * @throws SQLException
40: */
41: public <T, R> InvocationStrategy<D, T, R> start(
42: InvocationStrategy<D, T, R> strategy, Connection connection)
43: throws SQLException;
44:
45: /**
46: * Decorates the specified invocation strategy with end transaction logic.
47: * @param <T> Target object type of the invocation
48: * @param <R> Return type of this invocation
49: * @param strategy
50: * @return the decorated invocation strategy
51: * @throws SQLException
52: */
53: public <T, R> InvocationStrategy<D, T, R> end(
54: InvocationStrategy<D, T, R> strategy) throws SQLException;
55:
56: /**
57: * Closes this transaction context.
58: */
59: public void close();
60: }
|