summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2005-10-24 07:21:12 +0000
committerRüdiger Timm <rt@openoffice.org>2005-10-24 07:21:12 +0000
commit66cccb91978b4a210454795ffc8eece7c4db1cf0 (patch)
tree335cb774334070c8cdd5c995858037ac3c1fae86 /connectivity
parentf4a2c2d566bac768be0c421dfa280528e0daec37 (diff)
INTEGRATION: CWS dba201d (1.3.12); FILE MERGED
2005/10/05 10:51:20 fs 1.3.12.1: #i55493# +XFlushable, -XTransactedObject
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/hsqldb/HConnection.cxx86
1 files changed, 73 insertions, 13 deletions
diff --git a/connectivity/source/drivers/hsqldb/HConnection.cxx b/connectivity/source/drivers/hsqldb/HConnection.cxx
index a7a4fb336516..22b2696f49d6 100644
--- a/connectivity/source/drivers/hsqldb/HConnection.cxx
+++ b/connectivity/source/drivers/hsqldb/HConnection.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: HConnection.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: rt $ $Date: 2005-09-08 06:03:01 $
+ * last change: $Author: rt $ $Date: 2005-10-24 08:21:12 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -33,9 +33,13 @@
*
************************************************************************/
#include "hsqldb/HConnection.hxx"
+
#ifndef _COMPHELPER_SEQUENCE_HXX_
#include <comphelper/sequence.hxx>
#endif
+#ifndef COMPHELPER_INC_COMPHELPER_LISTENERNOTIFICATION_HXX
+#include <comphelper/listenernotification.hxx>
+#endif
using namespace connectivity::hsqldb;
using namespace ::com::sun::star::uno;
@@ -43,16 +47,52 @@ using namespace ::com::sun::star::sdbc;
using namespace ::com::sun::star::sdbcx;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::embed;
+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:
+ virtual bool implNotify(
+ const Reference< XFlushListener >& _rxListener,
+ const EventObject& _rEvent
+ ) SAL_THROW( ( Exception ) );
+ };
+
+ // -----------------------------------------------------------------------------
+ bool FlushListeners::implNotify( const Reference< XFlushListener >& _rxListener, const EventObject& _rEvent ) SAL_THROW( ( Exception ) )
+ {
+ _rxListener->flushed( _rEvent );
+ return true; // continue notifying the other listeners, if any
+ }
+ }
+}
+// =============================================================================
+// = OConnectionWeakWrapper
+// =============================================================================
+// -----------------------------------------------------------------------------
void SAL_CALL OConnectionWeakWrapper::disposing(void)
{
+ m_pFlushListeners->disposing( EventObject( *this ) );
OConnectionWeakWrapper_BASE::disposing();
OConnectionWrapper::disposing();
}
// -----------------------------------------------------------------------------
-OConnectionWeakWrapper::OConnectionWeakWrapper(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection
- ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _xORB) : OConnectionWeakWrapper_BASE(m_aMutex)
+OConnectionWeakWrapper::OConnectionWeakWrapper(
+ const Reference< XConnection >& _xConnection ,const Reference< XMultiServiceFactory>& _xORB )
+ :OConnectionWeakWrapper_BASE( m_aMutex )
+ ,m_pFlushListeners( new FlushListeners( m_aMutex ) )
{
setDelegation(_xConnection,_xORB,m_refCount);
}
@@ -69,9 +109,9 @@ OConnectionWeakWrapper::~OConnectionWeakWrapper()
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)
-// -----------------------------------------------------------------------------
-// XTransactedObject
-void SAL_CALL OConnectionWeakWrapper::commit( ) throw (::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+// XFlushable
+//--------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::flush( ) throw (RuntimeException)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(rBHelper.bDisposed);
@@ -80,18 +120,38 @@ void SAL_CALL OConnectionWeakWrapper::commit( ) throw (::com::sun::star::io::IO
{
if ( m_xConnection.is() )
{
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement> xStmt = m_xConnection->createStatement();
- if ( xStmt.is() )
- xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CHECKPOINT")));
+// 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" ) ) );
}
+ m_pFlushListeners->notify( EventObject( *this ) );
}
catch(::com::sun::star::uno::Exception&)
{
+ OSL_ENSURE( false, "OConnectionWeakWrapper::flush: caught an exception!" );
}
}
-// -----------------------------------------------------------------------------
-void SAL_CALL OConnectionWeakWrapper::revert( ) throw (::com::sun::star::io::IOException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+
+//--------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::addFlushListener( const Reference< XFlushListener >& l ) throw (RuntimeException)
{
+ m_pFlushListeners->addListener( l );
}
+
+//--------------------------------------------------------------------
+void SAL_CALL OConnectionWeakWrapper::removeFlushListener( const Reference< XFlushListener >& l ) throw (RuntimeException)
+{
+ m_pFlushListeners->removeListener( l );
+}
+
// -----------------------------------------------------------------------------