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;
22:
23: import java.sql.Connection;
24: import java.sql.SQLException;
25: import java.util.Set;
26: import java.util.concurrent.ExecutorService;
27:
28: /**
29: * @author Paul Ferraro
30: * @since 2.0
31: */
32: public interface SynchronizationContext<D> {
33: /**
34: * Returns a connection to the specified database.
35: * @param database a database to which to connect
36: * @return a database connection
37: * @throws SQLException if connection could not be obtained
38: */
39: public Connection getConnection(Database<D> database)
40: throws SQLException;
41:
42: /**
43: * Returns the database from which to synchronize.
44: * @return a database
45: */
46: public Database<D> getSourceDatabase();
47:
48: /**
49: * Returns the database to synchronize.
50: * @return a database
51: */
52: public Database<D> getTargetDatabase();
53:
54: /**
55: * Returns a snapshot of the activate databases in the cluster at the time synchronization started.
56: * @return a collection of databases
57: */
58: public Set<Database<D>> getActiveDatabaseSet();
59:
60: /**
61: * Returns a cache of database meta data.
62: * @return a cache of database meta data.
63: */
64: public DatabaseProperties getDatabaseProperties();
65:
66: /**
67: * Returns the dialect of the cluster.
68: * @return a dialect
69: */
70: public Dialect getDialect();
71:
72: /**
73: * An executor service for executing tasks asynchronously.
74: * @return an executor service
75: */
76: public ExecutorService getExecutor();
77:
78: /**
79: * Closes any open database connections and shuts down the executor service.
80: */
81: public void close();
82: }
|