summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-12-06 16:37:57 +0200
committerNoel Grandin <noel@peralex.com>2012-12-10 08:05:36 +0200
commit9fc4553b6433fbb6565a5b946c4256c0bfe345f1 (patch)
tree347cd116da96a13f9087685017f6ee4a5fc7aca7 /connectivity
parentd01fba6afc39092ae3ae85c38ac21bb7d26d63e2 (diff)
fdo#46808, Adapt sdbc::DriverManager UNO service to new style
Change-Id: Ic2be6bd08aaabc81d0fbe0269ca577868defe934
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/inc/connectivity/dbtools.hxx4
-rw-r--r--connectivity/source/commontools/dbmetadata.cxx6
-rw-r--r--connectivity/source/commontools/dbtools2.cxx7
-rw-r--r--connectivity/source/cpool/ZPoolCollection.cxx26
-rw-r--r--connectivity/source/cpool/ZPoolCollection.hxx4
-rw-r--r--connectivity/source/drivers/hsqldb/HDriver.cxx7
-rw-r--r--connectivity/source/drivers/mysql/YDriver.cxx25
-rw-r--r--connectivity/source/drivers/mysql/Yservices.cxx31
-rw-r--r--connectivity/source/inc/mysql/YDriver.hxx7
-rw-r--r--connectivity/source/manager/mdrivermanager.hxx5
10 files changed, 61 insertions, 61 deletions
diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx
index fb1ff42d34d8..1fd66e910bf3 100644
--- a/connectivity/inc/connectivity/dbtools.hxx
+++ b/connectivity/inc/connectivity/dbtools.hxx
@@ -716,7 +716,7 @@ namespace dbtools
The URL used to connect to the database.
@param _xConnection
The connection used to find the correct driver.
- @param _rxFactory
+ @param _rxContext
Used to create the drivermanager.
@return
The datadefintion object.
@@ -724,7 +724,7 @@ namespace dbtools
OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> getDataDefinitionByURLAndConnection(
const ::rtl::OUString& _rsUrl,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
/** returns the table privileges to the given parameters
@param _xMetaData
diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx
index d9cc23c21b13..06aed4ea1a76 100644
--- a/connectivity/source/commontools/dbmetadata.cxx
+++ b/connectivity/source/commontools/dbmetadata.cxx
@@ -34,6 +34,7 @@
#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <tools/diagnose_ex.h>
#include <comphelper/namedvaluecollection.hxx>
@@ -67,6 +68,8 @@ namespace dbtools
using ::com::sun::star::sdbcx::XUsersSupplier;
using ::com::sun::star::sdbcx::XDataDefinitionSupplier;
using ::com::sun::star::sdbc::XDriverAccess;
+ using ::com::sun::star::sdbc::DriverManager;
+ using ::com::sun::star::sdbc::XDriverManager2;
using ::com::sun::star::uno::UNO_SET_THROW;
/** === end UNO using === **/
namespace BooleanComparisonMode = ::com::sun::star::sdb::BooleanComparisonMode;
@@ -376,8 +379,7 @@ namespace dbtools
if ( !xUsersSupp.is() )
{
// - or at the driver manager
- Reference< XDriverAccess > xDriverManager(
- _rContext.createComponent( "com.sun.star.sdbc.DriverManager" ), UNO_QUERY_THROW );
+ Reference< XDriverManager2 > xDriverManager = DriverManager::create( _rContext.getUNOContext() );
Reference< XDataDefinitionSupplier > xDriver( xDriverManager->getDriverByURL( m_pImpl->xConnectionMetaData->getURL() ), UNO_QUERY );
if ( xDriver.is() )
xUsersSupp.set( xDriver->getDataDefinitionByConnection( m_pImpl->xConnection ), UNO_QUERY );
diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx
index 4092e9e185de..acfb227703ab 100644
--- a/connectivity/source/commontools/dbtools2.cxx
+++ b/connectivity/source/commontools/dbtools2.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
@@ -636,14 +637,12 @@ sal_Bool isDataSourcePropertyEnabled(const Reference<XInterface>& _xProp,const :
Reference< XTablesSupplier> getDataDefinitionByURLAndConnection(
const ::rtl::OUString& _rsUrl,
const Reference< XConnection>& _xConnection,
- const Reference< XMultiServiceFactory>& _rxFactory)
+ const Reference< XComponentContext >& _rxContext)
{
Reference< XTablesSupplier> xTablesSup;
try
{
- Reference< XDriverAccess> xManager(
- _rxFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.DriverManager")) ),
- UNO_QUERY_THROW );
+ Reference< XDriverManager2 > xManager = DriverManager::create( _rxContext );
Reference< XDataDefinitionSupplier > xSupp( xManager->getDriverByURL( _rsUrl ), UNO_QUERY );
if ( xSupp.is() )
diff --git a/connectivity/source/cpool/ZPoolCollection.cxx b/connectivity/source/cpool/ZPoolCollection.cxx
index 68b5448b9506..b7d0abd075d5 100644
--- a/connectivity/source/cpool/ZPoolCollection.cxx
+++ b/connectivity/source/cpool/ZPoolCollection.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/reflection/ProxyFactory.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <comphelper/extract.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -75,9 +76,7 @@ OPoolCollection::OPoolCollection(const Reference< XMultiServiceFactory >& _rxF
:m_xServiceFactory(_rxFactory)
{
// bootstrap all objects supporting the .sdb.Driver service
- m_xManager = Reference< XDriverManager >(m_xServiceFactory->createInstance(::rtl::OUString("com.sun.star.sdbc.DriverManager") ), UNO_QUERY);
- m_xDriverAccess = Reference< XDriverAccess >(m_xManager, UNO_QUERY);
- OSL_ENSURE(m_xDriverAccess.is(), "have no (or an invalid) driver manager!");
+ m_xManager = DriverManager::create( comphelper::getComponentContext(m_xServiceFactory) );
m_xProxyFactory = ProxyFactory::create( comphelper::getComponentContext(m_xServiceFactory) );
@@ -277,20 +276,17 @@ sal_Bool OPoolCollection::isPoolingEnabledByUrl(const ::rtl::OUString& _sUrl,
Reference< XInterface >& _rxDriverNode)
{
sal_Bool bEnabled = sal_False;
- if (m_xDriverAccess.is())
+ _rxDriver = m_xManager->getDriverByURL(_sUrl);
+ if (_rxDriver.is() && isPoolingEnabled())
{
- _rxDriver = m_xDriverAccess->getDriverByURL(_sUrl);
- if (_rxDriver.is() && isPoolingEnabled())
- {
- Reference< XServiceInfo > xSerivceInfo(_rxDriver,UNO_QUERY);
- OSL_ENSURE(xSerivceInfo.is(),"Each driver should have a XServiceInfo interface!");
+ Reference< XServiceInfo > xSerivceInfo(_rxDriver,UNO_QUERY);
+ OSL_ENSURE(xSerivceInfo.is(),"Each driver should have a XServiceInfo interface!");
- if(xSerivceInfo.is())
- {
- // look for the implementation name of the driver
- _rsImplName = xSerivceInfo->getImplementationName();
- bEnabled = isDriverPoolingEnabled(_rsImplName,_rxDriverNode);
- }
+ if(xSerivceInfo.is())
+ {
+ // look for the implementation name of the driver
+ _rsImplName = xSerivceInfo->getImplementationName();
+ bEnabled = isDriverPoolingEnabled(_rsImplName,_rxDriverNode);
}
}
return bEnabled;
diff --git a/connectivity/source/cpool/ZPoolCollection.hxx b/connectivity/source/cpool/ZPoolCollection.hxx
index 20108fd87b08..6fb05bb31339 100644
--- a/connectivity/source/cpool/ZPoolCollection.hxx
+++ b/connectivity/source/cpool/ZPoolCollection.hxx
@@ -22,6 +22,7 @@
#include <cppuhelper/implbase4.hxx>
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbc/XDriverManager2.hpp>
#include <com/sun/star/sdbc/XConnectionPool.hpp>
#include <com/sun/star/sdbc/XPooledConnection.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
@@ -65,8 +66,7 @@ namespace connectivity
::osl::Mutex m_aMutex;
OConnectionPools m_aPools; // the driver pools
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverManager > m_xManager;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverAccess > m_xDriverAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverManager2 > m_xManager;
::com::sun::star::uno::Reference< ::com::sun::star::reflection::XProxyFactory > m_xProxyFactory;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xConfigNode; // config node for generel connection pooling
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop> m_xDesktop;
diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx
index 471d67bd5fbf..a805bfcf7756 100644
--- a/connectivity/source/drivers/hsqldb/HDriver.cxx
+++ b/connectivity/source/drivers/hsqldb/HDriver.cxx
@@ -22,6 +22,7 @@
#include <osl/diagnose.h>
#include "connectivity/dbexception.hxx"
#include <com/sun/star/configuration/theDefaultProvider.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
@@ -130,10 +131,8 @@ namespace connectivity
if ( !m_xDriver.is() )
{
::rtl::OUString sURL("jdbc:hsqldb:db");
- Reference<XDriverAccess> xDriverAccess(m_xFactory->createInstance(::rtl::OUString("com.sun.star.sdbc.DriverManager") ),UNO_QUERY);
- OSL_ENSURE(xDriverAccess.is(),"Could not load driver manager!");
- if ( xDriverAccess.is() )
- m_xDriver = xDriverAccess->getDriverByURL(sURL);
+ Reference<XDriverManager2> xDriverAccess = DriverManager::create( comphelper::getComponentContext(m_xFactory) );
+ m_xDriver = xDriverAccess->getDriverByURL(sURL);
}
return m_xDriver;
diff --git a/connectivity/source/drivers/mysql/YDriver.cxx b/connectivity/source/drivers/mysql/YDriver.cxx
index 941f47c1ec58..600a9855affc 100644
--- a/connectivity/source/drivers/mysql/YDriver.cxx
+++ b/connectivity/source/drivers/mysql/YDriver.cxx
@@ -21,9 +21,11 @@
#include "mysql/YCatalog.hxx"
#include <osl/diagnose.h>
#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/processfactory.hxx>
#include "connectivity/dbexception.hxx"
#include <connectivity/dbcharset.hxx>
-#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include "TConnection.hxx"
#include "resource/common_res.hrc"
#include "resource/sharedresources.hxx"
@@ -43,7 +45,7 @@ namespace connectivity
{
Reference< XInterface > SAL_CALL ODriverDelegator_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFac) throw( Exception )
{
- return *(new ODriverDelegator(_rxFac));
+ return *(new ODriverDelegator( comphelper::getComponentContext(_rxFac) ));
}
}
@@ -52,9 +54,9 @@ namespace connectivity
//= ODriverDelegator
//====================================================================
//--------------------------------------------------------------------
- ODriverDelegator::ODriverDelegator(const Reference< XMultiServiceFactory >& _rxFactory)
+ ODriverDelegator::ODriverDelegator(const Reference< XComponentContext >& _rxContext)
: ODriverDelegator_BASE(m_aMutex)
- ,m_xFactory(_rxFactory)
+ ,m_xContext(_rxContext)
{
}
@@ -140,13 +142,10 @@ namespace connectivity
return sNewUrl;
}
//--------------------------------------------------------------------
- Reference< XDriver > lcl_loadDriver(const Reference< XMultiServiceFactory >& _rxFactory,const ::rtl::OUString& _sUrl)
+ Reference< XDriver > lcl_loadDriver(const Reference< XComponentContext >& _rxContext,const ::rtl::OUString& _sUrl)
{
- Reference<XDriverAccess> xDriverAccess(_rxFactory->createInstance(::rtl::OUString("com.sun.star.sdbc.DriverManager") ),UNO_QUERY);
- OSL_ENSURE(xDriverAccess.is(),"Could not load driver manager!");
- Reference< XDriver > xDriver;
- if ( xDriverAccess.is() )
- xDriver = xDriverAccess->getDriverByURL(_sUrl);
+ Reference<XDriverManager2> xDriverAccess = DriverManager::create(_rxContext);
+ Reference< XDriver > xDriver = xDriverAccess->getDriverByURL(_sUrl);
return xDriver;
}
//--------------------------------------------------------------------
@@ -219,13 +218,13 @@ namespace connectivity
if ( eType == D_ODBC )
{
if ( !m_xODBCDriver.is() )
- m_xODBCDriver = lcl_loadDriver(m_xFactory,sCuttedUrl);
+ m_xODBCDriver = lcl_loadDriver(m_xContext,sCuttedUrl);
xDriver = m_xODBCDriver;
} // if ( bIsODBC )
else if ( eType == D_NATIVE )
{
if ( !m_xNativeDriver.is() )
- m_xNativeDriver = lcl_loadDriver(m_xFactory,sCuttedUrl);
+ m_xNativeDriver = lcl_loadDriver(m_xContext,sCuttedUrl);
xDriver = m_xNativeDriver;
}
else
@@ -236,7 +235,7 @@ namespace connectivity
TJDBCDrivers::iterator aFind = m_aJdbcDrivers.find(sDriverClass);
if ( aFind == m_aJdbcDrivers.end() )
- aFind = m_aJdbcDrivers.insert(TJDBCDrivers::value_type(sDriverClass,lcl_loadDriver(m_xFactory,sCuttedUrl))).first;
+ aFind = m_aJdbcDrivers.insert(TJDBCDrivers::value_type(sDriverClass,lcl_loadDriver(m_xContext,sCuttedUrl))).first;
xDriver = aFind->second;
}
diff --git a/connectivity/source/drivers/mysql/Yservices.cxx b/connectivity/source/drivers/mysql/Yservices.cxx
index ee2be92e9e06..ff6fe08804b1 100644
--- a/connectivity/source/drivers/mysql/Yservices.cxx
+++ b/connectivity/source/drivers/mysql/Yservices.cxx
@@ -80,24 +80,29 @@ extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL mysql_component_getFactory(
void* pServiceManager,
void* /*pRegistryKey*/)
{
- void* pRet = 0;
- if (pServiceManager)
+ if (!pServiceManager)
{
- ProviderRequest aReq(pServiceManager,pImplementationName);
+ return 0;
+ }
- aReq.CREATE_PROVIDER(
- ODriverDelegator::getImplementationName_Static(),
- ODriverDelegator::getSupportedServiceNames_Static(),
- ODriverDelegator_CreateInstance, ::cppu::createSingleFactory)
- ;
+ Reference< XSingleServiceFactory > xRet;
+ const Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast<XMultiServiceFactory*>(pServiceManager) );
+ const OUString sImplementationName( OUString::createFromAscii(pImplementationName) );
- if(aReq.xRet.is())
- aReq.xRet->acquire();
+ if( ODriverDelegator::getImplementationName_Static() == sImplementationName )
+ try
+ {
+ xRet = ::cppu::createSingleFactory( xServiceManager, sImplementationName, ODriverDelegator_CreateInstance,
+ ODriverDelegator::getSupportedServiceNames_Static(), 0);
+ }
+ catch(...)
+ {
+ }
- pRet = aReq.getProvider();
- }
+ if(xRet.is())
+ xRet->acquire();
- return pRet;
+ return xRet.get();
};
diff --git a/connectivity/source/inc/mysql/YDriver.hxx b/connectivity/source/inc/mysql/YDriver.hxx
index 32b6b21bd52b..a94a1711b381 100644
--- a/connectivity/source/inc/mysql/YDriver.hxx
+++ b/connectivity/source/inc/mysql/YDriver.hxx
@@ -22,6 +22,7 @@
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/compbase3.hxx>
#include <comphelper/uno3.hxx>
#include <comphelper/stl_types.hxx>
@@ -37,7 +38,7 @@ namespace connectivity
namespace mysql
{
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriverDelegator_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriverDelegator_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxMSF) throw( ::com::sun::star::uno::Exception );
typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver
, ::com::sun::star::sdbcx::XDataDefinitionSupplier
@@ -61,7 +62,7 @@ namespace connectivity
// for this Driver
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xODBCDriver;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xNativeDriver;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::rtl::OUString m_sOldDriverClass;
/** load the driver we want to delegate.
@@ -78,7 +79,7 @@ namespace connectivity
public:
/** creates a new delegator for a mysql driver
*/
- ODriverDelegator(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+ ODriverDelegator(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
// XServiceInfo
DECLARE_SERVICE_INFO();
diff --git a/connectivity/source/manager/mdrivermanager.hxx b/connectivity/source/manager/mdrivermanager.hxx
index 87b145dec0ed..be87e4283da7 100644
--- a/connectivity/source/manager/mdrivermanager.hxx
+++ b/connectivity/source/manager/mdrivermanager.hxx
@@ -27,7 +27,7 @@
#include <com/sun/star/sdbc/XDriverAccess.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/implbase3.hxx>
#include <comphelper/stl_types.hxx>
#include <comphelper/logging.hxx>
#include <comphelper/componentcontext.hxx>
@@ -54,8 +54,7 @@ namespace drivermanager
//==========================================================================
//= OSDBCDriverManager - the one-instance service for managing SDBC drivers
//==========================================================================
- typedef ::cppu::WeakImplHelper4 < ::com::sun::star::sdbc::XDriverManager2
- , ::com::sun::star::sdbc::XDriverAccess
+ typedef ::cppu::WeakImplHelper3 < ::com::sun::star::sdbc::XDriverManager2
, ::com::sun::star::lang::XServiceInfo
, ::com::sun::star::uno::XNamingService
> OSDBCDriverManager_Base;