summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/mysql
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/source/drivers/mysql
parentd01fba6afc39092ae3ae85c38ac21bb7d26d63e2 (diff)
fdo#46808, Adapt sdbc::DriverManager UNO service to new style
Change-Id: Ic2be6bd08aaabc81d0fbe0269ca577868defe934
Diffstat (limited to 'connectivity/source/drivers/mysql')
-rw-r--r--connectivity/source/drivers/mysql/YDriver.cxx25
-rw-r--r--connectivity/source/drivers/mysql/Yservices.cxx31
2 files changed, 30 insertions, 26 deletions
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();
};