Tag: cws_src680_dba201d
User: fs      
Date: 05/10/05 03:51:26

Modified:
 /dba/connectivity/source/drivers/hsqldb/
  HConnection.cxx

Log:
 #i55493# +XFlushable, -XTransactedObject

File Changes:

Directory: /dba/connectivity/source/drivers/hsqldb/
===================================================

File [changed]: HConnection.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/hsqldb/HConnection.cxx?r1=1.3&r2=1.3.12.1
Delta lines:  +74 -14
---------------------
--- HConnection.cxx     8 Sep 2005 06:03:01 -0000       1.3
+++ HConnection.cxx     5 Oct 2005 10:51:20 -0000       1.3.12.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: HConnection.cxx,v $
  *
- *  $Revision: 1.3 $
+ *  $Revision: 1.3.12.1 $
  *
- *  last change: $Author: rt $ $Date: 2005/09/08 06:03:01 $
+ *  last change: $Author: fs $ $Date: 2005/10/05 10:51:20 $
  *
  *  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::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 @@
 
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 @@
        {
                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 );
+}
+
 // 
-----------------------------------------------------------------------------
 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to