2005-01-21 15:39:26 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 05:03:01 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2005-01-21 15:39:26 +00:00
|
|
|
*
|
2005-09-08 05:03:01 +00:00
|
|
|
* $RCSfile: HConnection.cxx,v $
|
2005-01-21 15:39:26 +00:00
|
|
|
*
|
2006-09-25 08:42:19 +00:00
|
|
|
* $Revision: 1.7 $
|
2005-01-21 15:39:26 +00:00
|
|
|
*
|
2006-09-25 08:42:19 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2006-09-25 09:42:19 $
|
2005-01-21 15:39:26 +00:00
|
|
|
*
|
2005-09-08 05:03:01 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2005-01-21 15:39:26 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 05:03:01 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2005-01-21 15:39:26 +00:00
|
|
|
*
|
2005-09-08 05:03:01 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2005-01-21 15:39:26 +00:00
|
|
|
*
|
2005-09-08 05:03:01 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2005-01-21 15:39:26 +00:00
|
|
|
*
|
2005-09-08 05:03:01 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2005-01-21 15:39:26 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 01:40:10 +00:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_connectivity.hxx"
|
2005-01-21 15:39:26 +00:00
|
|
|
#include "hsqldb/HConnection.hxx"
|
2005-10-24 07:21:12 +00:00
|
|
|
|
2005-01-21 15:39:26 +00:00
|
|
|
#ifndef _COMPHELPER_SEQUENCE_HXX_
|
|
|
|
#include <comphelper/sequence.hxx>
|
|
|
|
#endif
|
2005-10-24 07:21:12 +00:00
|
|
|
#ifndef COMPHELPER_INC_COMPHELPER_LISTENERNOTIFICATION_HXX
|
|
|
|
#include <comphelper/listenernotification.hxx>
|
|
|
|
#endif
|
2005-01-21 15:39:26 +00:00
|
|
|
|
|
|
|
using namespace connectivity::hsqldb;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::sdbc;
|
|
|
|
using namespace ::com::sun::star::sdbcx;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::lang;
|
2005-10-24 07:21:12 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
|
|
|
|
namespace connectivity
|
|
|
|
{
|
|
|
|
namespace hsqldb
|
|
|
|
{
|
|
|
|
// =============================================================================
|
|
|
|
// = FlushListeners
|
|
|
|
// =============================================================================
|
|
|
|
typedef ::comphelper::OListenerContainerBase< XFlushListener, EventObject > FlushListeners_Base;
|
|
|
|
class FlushListeners : public FlushListeners_Base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FlushListeners( ::osl::Mutex& _rMutex ) :FlushListeners_Base( _rMutex ) { }
|
|
|
|
|
|
|
|
protected:
|
2006-06-20 00:29:36 +00:00
|
|
|
virtual bool implTypedNotify(
|
2005-10-24 07:21:12 +00:00
|
|
|
const Reference< XFlushListener >& _rxListener,
|
|
|
|
const EventObject& _rEvent
|
|
|
|
) SAL_THROW( ( Exception ) );
|
|
|
|
};
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
2006-06-20 00:29:36 +00:00
|
|
|
bool FlushListeners::implTypedNotify( const Reference< XFlushListener >& _rxListener, const EventObject& _rEvent ) SAL_THROW( ( Exception ) )
|
2005-10-24 07:21:12 +00:00
|
|
|
{
|
|
|
|
_rxListener->flushed( _rEvent );
|
|
|
|
return true; // continue notifying the other listeners, if any
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-01-21 15:39:26 +00:00
|
|
|
|
2005-10-24 07:21:12 +00:00
|
|
|
// =============================================================================
|
|
|
|
// = OConnectionWeakWrapper
|
|
|
|
// =============================================================================
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-01-21 15:39:26 +00:00
|
|
|
void SAL_CALL OConnectionWeakWrapper::disposing(void)
|
|
|
|
{
|
2005-10-24 07:21:12 +00:00
|
|
|
m_pFlushListeners->disposing( EventObject( *this ) );
|
2005-01-21 15:39:26 +00:00
|
|
|
OConnectionWeakWrapper_BASE::disposing();
|
|
|
|
OConnectionWrapper::disposing();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2005-10-24 07:21:12 +00:00
|
|
|
OConnectionWeakWrapper::OConnectionWeakWrapper(
|
|
|
|
const Reference< XConnection >& _xConnection ,const Reference< XMultiServiceFactory>& _xORB )
|
|
|
|
:OConnectionWeakWrapper_BASE( m_aMutex )
|
|
|
|
,m_pFlushListeners( new FlushListeners( m_aMutex ) )
|
2005-01-21 15:39:26 +00:00
|
|
|
{
|
|
|
|
setDelegation(_xConnection,_xORB,m_refCount);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
OConnectionWeakWrapper::~OConnectionWeakWrapper()
|
|
|
|
{
|
|
|
|
if ( !OConnectionWeakWrapper_BASE::rBHelper.bDisposed )
|
|
|
|
{
|
|
|
|
osl_incrementInterlockedCount( &m_refCount );
|
|
|
|
dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
IMPLEMENT_FORWARD_XINTERFACE2(OConnectionWeakWrapper,OConnectionWeakWrapper_BASE,OConnectionWrapper)
|
|
|
|
IMPLEMENT_SERVICE_INFO(OConnectionWeakWrapper, "com.sun.star.sdbc.drivers.hsqldb.OConnectionWeakWrapper", "com.sun.star.sdbc.Connection")
|
|
|
|
IMPLEMENT_FORWARD_XTYPEPROVIDER2(OConnectionWeakWrapper,OConnectionWeakWrapper_BASE,OConnectionWrapper)
|
2005-10-24 07:21:12 +00:00
|
|
|
// XFlushable
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConnectionWeakWrapper::flush( ) throw (RuntimeException)
|
2005-01-21 15:39:26 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
checkDisposed(rBHelper.bDisposed);
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if ( m_xConnection.is() )
|
|
|
|
{
|
2005-10-24 07:21:12 +00:00
|
|
|
// Reference< XStatement> xStmt( m_xConnection->createStatement(), UNO_QUERY_THROW );
|
|
|
|
// xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SET WRITE_DELAY 0" ) ) );
|
|
|
|
//
|
|
|
|
// sal_Bool bPreviousAutoCommit = m_xConnection->getAutoCommit();
|
|
|
|
// m_xConnection->setAutoCommit( sal_False );
|
|
|
|
// m_xConnection->commit();
|
|
|
|
// m_xConnection->setAutoCommit( bPreviousAutoCommit );
|
|
|
|
//
|
|
|
|
// if ( xStmt.is() )
|
|
|
|
// xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SET WRITE_DELAY 60" ) ) );
|
|
|
|
Reference< XStatement > xStmt( m_xConnection->createStatement(), UNO_QUERY_THROW );
|
|
|
|
xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CHECKPOINT" ) ) );
|
2005-01-21 15:39:26 +00:00
|
|
|
}
|
2005-10-24 07:21:12 +00:00
|
|
|
m_pFlushListeners->notify( EventObject( *this ) );
|
2005-01-21 15:39:26 +00:00
|
|
|
}
|
|
|
|
catch(::com::sun::star::uno::Exception&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2005-10-24 07:21:12 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConnectionWeakWrapper::addFlushListener( const Reference< XFlushListener >& l ) throw (RuntimeException)
|
2005-01-21 15:39:26 +00:00
|
|
|
{
|
2006-06-20 00:29:36 +00:00
|
|
|
m_pFlushListeners->addTypedListener( l );
|
2005-01-21 15:39:26 +00:00
|
|
|
}
|
2005-10-24 07:21:12 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConnectionWeakWrapper::removeFlushListener( const Reference< XFlushListener >& l ) throw (RuntimeException)
|
|
|
|
{
|
2006-06-20 00:29:36 +00:00
|
|
|
m_pFlushListeners->removeTypedListener( l );
|
2005-10-24 07:21:12 +00:00
|
|
|
}
|
|
|
|
|
2005-01-21 15:39:26 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|