summaryrefslogtreecommitdiffstats
path: root/connectivity
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2013-02-04 16:54:16 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-06-07 14:14:07 +0100
commitc154f180e22e5cd494b5c71453cb93f30fd71f6e (patch)
tree0f29684e4221e3a027c3821b2fe4b46d3dc1cc22 /connectivity
parentgbuild: simplify AutoInstallLibs makefiles (diff)
downloadcore-c154f180e22e5cd494b5c71453cb93f30fd71f6e.tar.gz
core-c154f180e22e5cd494b5c71453cb93f30fd71f6e.zip
Ensure UNO context propagation on drivers instantiation
Use a better approach than 33c2427824ac893b15777527b818ec99c78c61dd (cherry picked from commit 7f635eeb69e1257a37c2d3bfe9afe5e56daf259c) Conflicts: connectivity/source/manager/mdrivermanager.cxx connectivity/source/manager/mdrivermanager.hxx Change-Id: Ic7ce5449d4c5e5231c838f9b7733fd4703e6252c
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/manager/mdrivermanager.cxx18
-rw-r--r--connectivity/source/manager/mdrivermanager.hxx1
2 files changed, 12 insertions, 7 deletions
diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx
index 6458cf046c89..67ea3ec77ee0 100644
--- a/connectivity/source/manager/mdrivermanager.cxx
+++ b/connectivity/source/manager/mdrivermanager.cxx
@@ -114,6 +114,9 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, W
/// an STL functor which ensures that a SdbcDriver described by a DriverAccess is loaded
struct EnsureDriver : public ::std::unary_function< DriverAccess, DriverAccess >
{
+ EnsureDriver( const Reference< XComponentContext > &rxContext )
+ : mxContext( rxContext ) {}
+
const DriverAccess& operator()( const DriverAccess& _rDescriptor ) const
{
if ( !_rDescriptor.xDriver.is() )
@@ -121,9 +124,12 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, W
if ( _rDescriptor.xComponentFactory.is() )
// we have a factory for it
const_cast< DriverAccess& >( _rDescriptor ).xDriver = _rDescriptor.xDriver.query(
- _rDescriptor.xComponentFactory->createInstanceWithContext( _rDescriptor.xUNOContext ) );
+ _rDescriptor.xComponentFactory->createInstanceWithContext( mxContext ) );
return _rDescriptor;
}
+
+ private:
+ Reference< XComponentContext > mxContext;
};
/// an STL functor which extracts a SdbcDriver from a DriverAccess
@@ -139,7 +145,8 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, W
/// an STL functor which loads a driver described by a DriverAccess, and extracts the SdbcDriver
struct ExtractAfterLoad : public ExtractAfterLoad_BASE
{
- ExtractAfterLoad() : ExtractAfterLoad_BASE( ExtractDriverFromAccess(), EnsureDriver() ) { }
+ ExtractAfterLoad( const Reference< XComponentContext > &rxContext )
+ : ExtractAfterLoad_BASE( ExtractDriverFromAccess(), EnsureDriver( rxContext ) ) {}
};
struct ExtractDriverFromCollectionElement : public ::std::unary_function< DriverCollection::value_type, Reference<XDriver> >
@@ -287,7 +294,6 @@ void OSDBCDriverManager::bootstrapDrivers()
{ // yes -> no need to load the driver immediately (load it later when needed)
aDriverDescriptor.sImplementationName = xSI->getImplementationName();
aDriverDescriptor.xComponentFactory = xFactory;
- aDriverDescriptor.xUNOContext = m_xContext;
bValidDescriptor = sal_True;
m_aEventLogger.log( LogLevel::CONFIG,
@@ -475,7 +481,7 @@ Reference< XEnumeration > SAL_CALL OSDBCDriverManager::createEnumeration( ) thr
ODriverEnumeration::DriverArray aDrivers;
// ensure that all our bootstrapped drivers are instantiated
- ::std::for_each( m_aDriversBS.begin(), m_aDriversBS.end(), EnsureDriver() );
+ ::std::for_each( m_aDriversBS.begin(), m_aDriversBS.end(), EnsureDriver( m_xContext ) );
// copy the bootstrapped drivers
::std::transform(
@@ -655,13 +661,13 @@ Reference< XDriver > OSDBCDriverManager::implGetDriverForURL(const OUString& _rU
aFind = ::std::find_if(
m_aDriversBS.begin(), // begin of search range
m_aDriversBS.end(), // end of search range
- o3tl::unary_compose< AcceptsURL, ExtractAfterLoad >( AcceptsURL( _rURL ), ExtractAfterLoad() )
+ o3tl::unary_compose< AcceptsURL, ExtractAfterLoad >( AcceptsURL( _rURL ), ExtractAfterLoad( m_xContext ) )
// compose two functors: extract the driver from the access, then ask the resulting driver for acceptance
);
} // if ( m_aDriversBS.find(sDriverFactoryName ) == m_aDriversBS.end() )
else
{
- EnsureDriver aEnsure;
+ EnsureDriver aEnsure( m_xContext );
aEnsure(*aFind);
}
diff --git a/connectivity/source/manager/mdrivermanager.hxx b/connectivity/source/manager/mdrivermanager.hxx
index be1e2586e9c3..a311c0207218 100644
--- a/connectivity/source/manager/mdrivermanager.hxx
+++ b/connectivity/source/manager/mdrivermanager.hxx
@@ -47,7 +47,6 @@ namespace drivermanager
OUString sImplementationName; /// the implementation name of the driver
css::uno::Reference< css::sdbc::XDriver > xDriver; /// the driver itself
css::uno::Reference< css::lang::XSingleComponentFactory > xComponentFactory; /// the factory to create the driver component (if not already done so)
- css::uno::Reference<css::uno::XComponentContext> xUNOContext; /// ensure UNO context propagation
};
//==========================================================================