diff options
author | Noel Grandin <noel@peralex.com> | 2012-11-27 11:45:21 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-11-28 13:06:18 +0100 |
commit | 38cc919efb965e7982d23d5b1c91a639cc2c6fdd (patch) | |
tree | 3586b24e5d14c7612dae8da02cdd04ad7b2ec112 /connectivity | |
parent | 7470cc532fe408dc9d8735cde0e2eb5bb62fd69c (diff) |
fdo#46808, use service constructor for sdbc::ConnectionPool
Change-Id: Id12226af5e537b1eeacbb062ad937a3551e245c0
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/inc/connectivity/dbtools.hxx | 6 | ||||
-rw-r--r-- | connectivity/inc/connectivity/parameters.hxx | 8 | ||||
-rw-r--r-- | connectivity/inc/connectivity/virtualdbtools.hxx | 2 | ||||
-rw-r--r-- | connectivity/source/commontools/dbtools.cxx | 27 | ||||
-rw-r--r-- | connectivity/source/commontools/parameters.cxx | 10 | ||||
-rw-r--r-- | connectivity/source/simpledbt/staticdbtools_s.cxx | 4 | ||||
-rw-r--r-- | connectivity/source/simpledbt/staticdbtools_s.hxx | 2 |
7 files changed, 31 insertions, 28 deletions
diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx index 854e4e932422..18fd291f397d 100644 --- a/connectivity/inc/connectivity/dbtools.hxx +++ b/connectivity/inc/connectivity/dbtools.hxx @@ -151,7 +151,7 @@ namespace dbtools OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext, sal_Bool _bSetAsActiveConnection ) SAL_THROW ( ( ::com::sun::star::sdbc::SQLException , ::com::sun::star::lang::WrappedTargetException @@ -182,7 +182,7 @@ namespace dbtools */ OOO_DLLPUBLIC_DBTOOLS SharedConnection ensureRowSetConnection( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext, bool _bUseAutoConnectionDisposer ) SAL_THROW ( ( ::com::sun::star::sdbc::SQLException , ::com::sun::star::lang::WrappedTargetException @@ -423,7 +423,7 @@ namespace dbtools */ OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > getCurrentSettingsComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxRowSetProps, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext ); /** transfer and translate properties between two FormComponents diff --git a/connectivity/inc/connectivity/parameters.hxx b/connectivity/inc/connectivity/parameters.hxx index 0e25f99161be..e81e39feb45f 100644 --- a/connectivity/inc/connectivity/parameters.hxx +++ b/connectivity/inc/connectivity/parameters.hxx @@ -23,11 +23,11 @@ #include <vector> #include <com/sun/star/uno/XAggregation.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/form/XDatabaseParameterListener.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/sdbc/XParameters.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> @@ -101,8 +101,8 @@ namespace dbtools ::osl::Mutex& m_rMutex; ::cppu::OInterfaceContainerHelper m_aParameterListeners; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > - m_xORB; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > + m_xContext; ::com::sun::star::uno::WeakReference< ::com::sun::star::beans::XPropertySet > m_xComponent; // the database component whose parameters we're handling @@ -137,7 +137,7 @@ namespace dbtools */ explicit ParameterManager( ::osl::Mutex& _rMutex, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext ); /// late ctor diff --git a/connectivity/inc/connectivity/virtualdbtools.hxx b/connectivity/inc/connectivity/virtualdbtools.hxx index 7551bedac8d6..1e12e9a60fd9 100644 --- a/connectivity/inc/connectivity/virtualdbtools.hxx +++ b/connectivity/inc/connectivity/virtualdbtools.hxx @@ -125,7 +125,7 @@ namespace connectivity virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext, sal_Bool _bSetAsActiveConnection ) const SAL_THROW ( ( ::com::sun::star::sdbc::SQLException , ::com::sun::star::lang::WrappedTargetException diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 183ad8d39fa6..065fa84d306f 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -42,6 +42,7 @@ #include <com/sun/star/sdb/XParametersSupplier.hpp> #include <com/sun/star/sdb/XQueriesSupplier.hpp> #include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <com/sun/star/sdbc/ConnectionPool.hpp> #include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdbc/XDataSource.hpp> @@ -357,7 +358,7 @@ Reference< XConnection> getConnection(const Reference< XRowSet>& _rxRowSet) thro // helper function which allows to implement both the connectRowset and the ensureRowSetConnection semantics // if connectRowset (which is deprecated) is removed, this function and one of its parameters are // not needed anymore, the whole implementation can be moved into ensureRowSetConnection then) -SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory, +SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, bool _bSetAsActiveConnection, bool _bAttachAutoDisposer ) SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) ) { @@ -410,13 +411,15 @@ SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const R if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), xRowSetProps)) xRowSetProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd; - xPureConnection = getConnection_allowException( sDataSourceName, sUser, sPwd, comphelper::getComponentContext(_rxFactory) ); + xPureConnection = getConnection_allowException( sDataSourceName, sUser, sPwd, _rxContext ); } else if (!sURL.isEmpty()) { // the row set has no data source, but a connection url set // -> try to connection with that url - Reference< XDriverManager > xDriverManager( - _rxFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.ConnectionPool"))), UNO_QUERY); + Reference< XDriverManager > xDriverManager; + try { + xDriverManager = ConnectionPool::create( _rxContext ); + } catch( const Exception& ) { } if (xDriverManager.is()) { ::rtl::OUString sUser, sPwd; @@ -472,18 +475,18 @@ SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const R } //------------------------------------------------------------------------------ -Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory, +Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, sal_Bool _bSetAsActiveConnection ) SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) ) { - SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxFactory, _bSetAsActiveConnection, true ); + SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxContext, _bSetAsActiveConnection, true ); return xConnection.getTyped(); } //------------------------------------------------------------------------------ -SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory, +SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext>& _rxContext, bool _bUseAutoConnectionDisposer ) SAL_THROW ( ( SQLException, WrappedTargetException, RuntimeException ) ) { - return lcl_connectRowSet( _rxRowSet, _rxFactory, true, _bUseAutoConnectionDisposer ); + return lcl_connectRowSet( _rxRowSet, _rxContext, true, _bUseAutoConnectionDisposer ); } //------------------------------------------------------------------------------ @@ -1266,13 +1269,13 @@ Reference< XDataSource> findDataSource(const Reference< XInterface >& _xParent) } //------------------------------------------------------------------------------ -Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Reference< XPropertySet >& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory ) +Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Reference< XPropertySet >& _rxRowSet, const Reference< XComponentContext >& _rxContext ) SAL_THROW( ( SQLException ) ) { Reference< XSingleSelectQueryComposer > xComposer; try { - Reference< XConnection> xConn = connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxFactory, sal_True ); + Reference< XConnection> xConn = connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxContext, sal_True ); if ( xConn.is() ) // implies _rxRowSet.is() { // build the statement the row set is based on (can't use the ActiveCommand property of the set @@ -1317,12 +1320,12 @@ Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Refere //------------------------------------------------------------------------------ Reference< XSingleSelectQueryComposer > getCurrentSettingsComposer( const Reference< XPropertySet>& _rxRowSetProps, - const Reference< XMultiServiceFactory>& _rxFactory) + const Reference< XComponentContext>& _rxContext) { Reference< XSingleSelectQueryComposer > xReturn; try { - xReturn = getComposedRowSetStatement( _rxRowSetProps, _rxFactory ); + xReturn = getComposedRowSetStatement( _rxRowSetProps, _rxContext ); } catch( const SQLException& ) { diff --git a/connectivity/source/commontools/parameters.cxx b/connectivity/source/commontools/parameters.cxx index b082e88adff3..ef83e56ea80c 100644 --- a/connectivity/source/commontools/parameters.cxx +++ b/connectivity/source/commontools/parameters.cxx @@ -63,15 +63,15 @@ namespace dbtools //= ParameterManager //==================================================================== //-------------------------------------------------------------------- - ParameterManager::ParameterManager( ::osl::Mutex& _rMutex, const Reference< XMultiServiceFactory >& _rxORB ) + ParameterManager::ParameterManager( ::osl::Mutex& _rMutex, const Reference< XComponentContext >& _rxContext ) :m_rMutex ( _rMutex ) ,m_aParameterListeners( _rMutex ) - ,m_xORB ( _rxORB ) + ,m_xContext ( _rxContext ) ,m_pOuterParameters ( NULL ) ,m_nInnerCount ( 0 ) ,m_bUpToDate ( false ) { - OSL_ENSURE( m_xORB.is(), "ParameterManager::ParameterManager: no service factory!" ); + OSL_ENSURE( m_xContext.is(), "ParameterManager::ParameterManager: no service factory!" ); } //-------------------------------------------------------------------- @@ -147,7 +147,7 @@ namespace dbtools try { // get a query composer for the 's settings - m_xComposer.reset( getCurrentSettingsComposer( _rxComponent, m_xORB ), SharedQueryComposer::TakeOwnership ); + m_xComposer.reset( getCurrentSettingsComposer( _rxComponent, m_xContext ), SharedQueryComposer::TakeOwnership ); // see if the composer found parameters Reference< XParametersSupplier > xParamSupp( m_xComposer, UNO_QUERY ); @@ -817,7 +817,7 @@ namespace dbtools // re-create the parent composer all the time. Else, we'd have to bother with // being a listener at its properties, its loaded state, and event the parent-relationship. m_xParentComposer.reset( - getCurrentSettingsComposer( xParent, m_xORB ), + getCurrentSettingsComposer( xParent, m_xContext ), SharedQueryComposer::TakeOwnership ); xParentColSupp = xParentColSupp.query( m_xParentComposer ); diff --git a/connectivity/source/simpledbt/staticdbtools_s.cxx b/connectivity/source/simpledbt/staticdbtools_s.cxx index 1d8939052326..f40f5e3b6932 100644 --- a/connectivity/source/simpledbt/staticdbtools_s.cxx +++ b/connectivity/source/simpledbt/staticdbtools_s.cxx @@ -90,10 +90,10 @@ namespace connectivity } //---------------------------------------------------------------- - Reference< XConnection> ODataAccessStaticTools::connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XMultiServiceFactory>& _rxFactory, sal_Bool _bSetAsActiveConnection) const + Reference< XConnection> ODataAccessStaticTools::connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, sal_Bool _bSetAsActiveConnection) const SAL_THROW ( (SQLException, WrappedTargetException, RuntimeException) ) { - return ::dbtools::connectRowset( _rxRowSet, _rxFactory, _bSetAsActiveConnection); + return ::dbtools::connectRowset( _rxRowSet, _rxContext, _bSetAsActiveConnection); } // ------------------------------------------------ diff --git a/connectivity/source/simpledbt/staticdbtools_s.hxx b/connectivity/source/simpledbt/staticdbtools_s.hxx index a8597209084b..83512c46572c 100644 --- a/connectivity/source/simpledbt/staticdbtools_s.hxx +++ b/connectivity/source/simpledbt/staticdbtools_s.hxx @@ -76,7 +76,7 @@ namespace connectivity // ------------------------------------------------ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext, sal_Bool _bSetAsActiveConnection ) const SAL_THROW ( ( ::com::sun::star::sdbc::SQLException , ::com::sun::star::lang::WrappedTargetException |