001/*
002 * HA-JDBC: High-Availability JDBC
003 * Copyright (c) 2004-2007 Paul Ferraro
004 * 
005 * This library is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Lesser General Public License as published by the 
007 * Free Software Foundation; either version 2.1 of the License, or (at your 
008 * option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful, but WITHOUT
011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 
013 * for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public License
016 * along with this library; if not, write to the Free Software Foundation, 
017 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018 * 
019 * Contact: ferraro@users.sourceforge.net
020 */
021package net.sf.hajdbc.sql;
022
023import java.lang.reflect.Method;
024import java.sql.Connection;
025import java.sql.SQLException;
026import java.sql.Savepoint;
027import java.util.Map;
028
029import net.sf.hajdbc.Database;
030
031/**
032 * @author Paul Ferraro
033 * @param <D> 
034 */
035public class SavepointInvocationHandler<D> extends AbstractChildInvocationHandler<D, Connection, Savepoint>
036{
037        /**
038         * @param connection the connection that created this savepoint
039         * @param proxy the invocation handler of the connection that created this savepoint
040         * @param invoker the invoker used to create this savepoint
041         * @param savepointMap a map of database to underlying savepoint
042         * @throws Exception
043         */
044        protected SavepointInvocationHandler(Connection connection, SQLProxy<D, Connection> proxy, Invoker<D, Connection, Savepoint> invoker, Map<Database<D>, Savepoint> savepointMap) throws Exception
045        {
046                super(connection, proxy, invoker, Savepoint.class, savepointMap);
047        }
048
049        /**
050         * @see net.sf.hajdbc.sql.AbstractChildInvocationHandler#getInvocationStrategy(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
051         */
052        @Override
053        protected InvocationStrategy<D, Savepoint, ?> getInvocationStrategy(Savepoint object, Method method, Object[] parameters)
054        {
055                return new DriverReadInvocationStrategy<D, Savepoint, Object>();
056        }
057
058        /**
059         * @see net.sf.hajdbc.sql.AbstractChildInvocationHandler#close(java.lang.Object, java.lang.Object)
060         */
061        @Override
062        protected void close(Connection connection, Savepoint savepoint) throws SQLException
063        {
064                connection.releaseSavepoint(savepoint);
065        }
066}