1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_connectivity.hxx" 30 #include "ZPoolCollection.hxx" 31 #include "ZDriverWrapper.hxx" 32 #include "ZConnectionPool.hxx" 33 #include <com/sun/star/container/XHierarchicalNameAccess.hpp> 34 #include <com/sun/star/beans/PropertyValue.hpp> 35 #include <comphelper/extract.hxx> 36 #include <com/sun/star/beans/XPropertySet.hpp> 37 #include "diagnose_ex.h" 38 39 using namespace ::com::sun::star::uno; 40 using namespace ::com::sun::star::lang; 41 using namespace ::com::sun::star::sdbc; 42 using namespace ::com::sun::star::beans; 43 using namespace ::com::sun::star::container; 44 using namespace ::com::sun::star::reflection; 45 using namespace ::osl; 46 using namespace connectivity; 47 48 //-------------------------------------------------------------------- 49 static const ::rtl::OUString& getConnectionPoolNodeName() 50 { 51 static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("org.openoffice.Office.DataAccess/ConnectionPool"); 52 return s_sNodeName; 53 } 54 //-------------------------------------------------------------------- 55 static const ::rtl::OUString& getEnablePoolingNodeName() 56 { 57 static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("EnablePooling"); 58 return s_sNodeName; 59 } 60 //-------------------------------------------------------------------- 61 static const ::rtl::OUString& getDriverNameNodeName() 62 { 63 static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("DriverName"); 64 return s_sNodeName; 65 } 66 // ----------------------------------------------------------------------------- 67 static const ::rtl::OUString& getDriverSettingsNodeName() 68 { 69 static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("DriverSettings"); 70 return s_sNodeName; 71 } 72 //-------------------------------------------------------------------------- 73 static const ::rtl::OUString& getEnableNodeName() 74 { 75 static ::rtl::OUString s_sNodeName = ::rtl::OUString::createFromAscii("Enable"); 76 return s_sNodeName; 77 } 78 79 //-------------------------------------------------------------------- 80 OPoolCollection::OPoolCollection(const Reference< XMultiServiceFactory >& _rxFactory) 81 :m_xServiceFactory(_rxFactory) 82 { 83 // bootstrap all objects supporting the .sdb.Driver service 84 m_xManager = Reference< XDriverManager >(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdbc.DriverManager") ), UNO_QUERY); 85 m_xDriverAccess = Reference< XDriverAccess >(m_xManager, UNO_QUERY); 86 OSL_ENSURE(m_xDriverAccess.is(), "have no (or an invalid) driver manager!"); 87 88 m_xProxyFactory = Reference< XProxyFactory >( 89 m_xServiceFactory->createInstance( 90 ::rtl::OUString::createFromAscii("com.sun.star.reflection.ProxyFactory")), 91 UNO_QUERY); 92 OSL_ENSURE(m_xProxyFactory.is(), "OConnectionPool::OConnectionPool: could not create a proxy factory!"); 93 94 Reference<XPropertySet> xProp(getConfigPoolRoot(),UNO_QUERY); 95 if ( xProp.is() ) 96 xProp->addPropertyChangeListener(getEnablePoolingNodeName(),this); 97 // attach as desktop listener to know when we have to release our pools 98 osl_incrementInterlockedCount( &m_refCount ); 99 { 100 101 m_xDesktop = Reference< ::com::sun::star::frame::XDesktop>( m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop") ), UNO_QUERY); 102 if ( m_xDesktop.is() ) 103 m_xDesktop->addTerminateListener(this); 104 105 } 106 osl_decrementInterlockedCount( &m_refCount ); 107 } 108 // ----------------------------------------------------------------------------- 109 OPoolCollection::~OPoolCollection() 110 { 111 clearConnectionPools(sal_False); 112 } 113 // ----------------------------------------------------------------------------- 114 Reference< XConnection > SAL_CALL OPoolCollection::getConnection( const ::rtl::OUString& _rURL ) throw(SQLException, RuntimeException) 115 { 116 return getConnectionWithInfo(_rURL,Sequence< PropertyValue >()); 117 } 118 // ----------------------------------------------------------------------------- 119 Reference< XConnection > SAL_CALL OPoolCollection::getConnectionWithInfo( const ::rtl::OUString& _rURL, const Sequence< PropertyValue >& _rInfo ) throw(SQLException, RuntimeException) 120 { 121 MutexGuard aGuard(m_aMutex); 122 Reference< XConnection > xConnection; 123 Reference< XDriver > xDriver; 124 Reference< XInterface > xDriverNode; 125 ::rtl::OUString sImplName; 126 if(isPoolingEnabledByUrl(_rURL,xDriver,sImplName,xDriverNode) && xDriver.is()) 127 { 128 OConnectionPool* pConnectionPool = getConnectionPool(sImplName,xDriver,xDriverNode); 129 130 if(pConnectionPool) 131 xConnection = pConnectionPool->getConnectionWithInfo(_rURL,_rInfo); 132 } 133 else if(xDriver.is()) 134 xConnection = xDriver->connect(_rURL,_rInfo); 135 136 return xConnection; 137 } 138 // ----------------------------------------------------------------------------- 139 void SAL_CALL OPoolCollection::setLoginTimeout( sal_Int32 seconds ) throw(RuntimeException) 140 { 141 MutexGuard aGuard(m_aMutex); 142 m_xManager->setLoginTimeout(seconds); 143 } 144 // ----------------------------------------------------------------------------- 145 sal_Int32 SAL_CALL OPoolCollection::getLoginTimeout( ) throw(RuntimeException) 146 { 147 MutexGuard aGuard(m_aMutex); 148 return m_xManager->getLoginTimeout(); 149 } 150 // ----------------------------------------------------------------------------- 151 ::rtl::OUString SAL_CALL OPoolCollection::getImplementationName( ) throw(RuntimeException) 152 { 153 MutexGuard aGuard(m_aMutex); 154 return getImplementationName_Static(); 155 } 156 157 //-------------------------------------------------------------------------- 158 sal_Bool SAL_CALL OPoolCollection::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException) 159 { 160 Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); 161 const ::rtl::OUString* pSupported = aSupported.getConstArray(); 162 const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); 163 for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) 164 ; 165 166 return pSupported != pEnd; 167 } 168 169 //-------------------------------------------------------------------------- 170 Sequence< ::rtl::OUString > SAL_CALL OPoolCollection::getSupportedServiceNames( ) throw(RuntimeException) 171 { 172 return getSupportedServiceNames_Static(); 173 } 174 175 //---------------------------------------OPoolCollection---------------------------------- 176 Reference< XInterface > SAL_CALL OPoolCollection::CreateInstance(const Reference< XMultiServiceFactory >& _rxFactory) 177 { 178 return static_cast<XDriverManager*>(new OPoolCollection(_rxFactory)); 179 } 180 181 //-------------------------------------------------------------------------- 182 ::rtl::OUString SAL_CALL OPoolCollection::getImplementationName_Static( ) throw(RuntimeException) 183 { 184 return ::rtl::OUString::createFromAscii("com.sun.star.sdbc.OConnectionPool"); 185 } 186 187 //-------------------------------------------------------------------------- 188 Sequence< ::rtl::OUString > SAL_CALL OPoolCollection::getSupportedServiceNames_Static( ) throw(RuntimeException) 189 { 190 Sequence< ::rtl::OUString > aSupported(1); 191 aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ConnectionPool"); 192 return aSupported; 193 } 194 // ----------------------------------------------------------------------------- 195 Reference< XDriver > SAL_CALL OPoolCollection::getDriverByURL( const ::rtl::OUString& _rURL ) throw(RuntimeException) 196 { 197 // returns the original driver when no connection pooling is enabled else it returns the proxy 198 MutexGuard aGuard(m_aMutex); 199 200 Reference< XDriver > xDriver; 201 Reference< XInterface > xDriverNode; 202 ::rtl::OUString sImplName; 203 if(isPoolingEnabledByUrl(_rURL,xDriver,sImplName,xDriverNode)) 204 { 205 Reference< XDriver > xExistentProxy; 206 // look if we already have a proxy for this driver 207 for ( ConstMapDriver2DriverRefIterator aLookup = m_aDriverProxies.begin(); 208 aLookup != m_aDriverProxies.end(); 209 ++aLookup 210 ) 211 { 212 // hold the proxy alive as long as we're in this loop round 213 xExistentProxy = aLookup->second; 214 215 if (xExistentProxy.is() && (aLookup->first.get() == xDriver.get())) 216 // already created a proxy for this 217 break; 218 } 219 if (xExistentProxy.is()) 220 { 221 xDriver = xExistentProxy; 222 } 223 else 224 { // create a new proxy for the driver 225 // this allows us to control the connections created by it 226 if (m_xProxyFactory.is()) 227 { 228 Reference< XAggregation > xDriverProxy = m_xProxyFactory->createProxy(xDriver.get()); 229 OSL_ENSURE(xDriverProxy.is(), "OConnectionPool::getDriverByURL: invalid proxy returned by the proxy factory!"); 230 231 OConnectionPool* pConnectionPool = getConnectionPool(sImplName,xDriver,xDriverNode); 232 xDriver = new ODriverWrapper(xDriverProxy, pConnectionPool); 233 } 234 else 235 OSL_ENSURE(sal_False, "OConnectionPool::getDriverByURL: could not instantiate a proxy factory!"); 236 } 237 } 238 239 return xDriver; 240 } 241 // ----------------------------------------------------------------------------- 242 sal_Bool OPoolCollection::isDriverPoolingEnabled(const ::rtl::OUString& _sDriverImplName, 243 Reference< XInterface >& _rxDriverNode) 244 { 245 sal_Bool bEnabled = sal_False; 246 Reference<XInterface> xConnectionPoolRoot = getConfigPoolRoot(); 247 // then look for which of them settings are stored in the configuration 248 Reference< XNameAccess > xDirectAccess(openNode(getDriverSettingsNodeName(),xConnectionPoolRoot),UNO_QUERY); 249 250 if(xDirectAccess.is()) 251 { 252 Sequence< ::rtl::OUString > aDriverKeys = xDirectAccess->getElementNames(); 253 const ::rtl::OUString* pDriverKeys = aDriverKeys.getConstArray(); 254 const ::rtl::OUString* pDriverKeysEnd = pDriverKeys + aDriverKeys.getLength(); 255 for (;pDriverKeys != pDriverKeysEnd; ++pDriverKeys) 256 { 257 // the name of the driver in this round 258 if(_sDriverImplName == *pDriverKeys) 259 { 260 _rxDriverNode = openNode(*pDriverKeys,xDirectAccess); 261 if(_rxDriverNode.is()) 262 getNodeValue(getEnableNodeName(),_rxDriverNode) >>= bEnabled; 263 break; 264 } 265 } 266 } 267 return bEnabled; 268 } 269 // ----------------------------------------------------------------------------- 270 sal_Bool OPoolCollection::isPoolingEnabled() 271 { 272 // the config node where all pooling relevant info are stored under 273 Reference<XInterface> xConnectionPoolRoot = getConfigPoolRoot(); 274 275 // the global "enabled" flag 276 sal_Bool bEnabled = sal_False; 277 if(xConnectionPoolRoot.is()) 278 getNodeValue(getEnablePoolingNodeName(),xConnectionPoolRoot) >>= bEnabled; 279 return bEnabled; 280 } 281 // ----------------------------------------------------------------------------- 282 Reference<XInterface> OPoolCollection::getConfigPoolRoot() 283 { 284 if(!m_xConfigNode.is()) 285 m_xConfigNode = createWithServiceFactory(getConnectionPoolNodeName()); 286 return m_xConfigNode; 287 } 288 // ----------------------------------------------------------------------------- 289 sal_Bool OPoolCollection::isPoolingEnabledByUrl(const ::rtl::OUString& _sUrl, 290 Reference< XDriver >& _rxDriver, 291 ::rtl::OUString& _rsImplName, 292 Reference< XInterface >& _rxDriverNode) 293 { 294 sal_Bool bEnabled = sal_False; 295 if (m_xDriverAccess.is()) 296 { 297 _rxDriver = m_xDriverAccess->getDriverByURL(_sUrl); 298 if (_rxDriver.is() && isPoolingEnabled()) 299 { 300 Reference< XServiceInfo > xSerivceInfo(_rxDriver,UNO_QUERY); 301 OSL_ENSURE(xSerivceInfo.is(),"Each driver should have a XServiceInfo interface!"); 302 303 if(xSerivceInfo.is()) 304 { 305 // look for the implementation name of the driver 306 _rsImplName = xSerivceInfo->getImplementationName(); 307 bEnabled = isDriverPoolingEnabled(_rsImplName,_rxDriverNode); 308 } 309 } 310 } 311 return bEnabled; 312 } 313 // ----------------------------------------------------------------------------- 314 void OPoolCollection::clearConnectionPools(sal_Bool _bDispose) 315 { 316 OConnectionPools::const_iterator aIter = m_aPools.begin(); 317 while(aIter != m_aPools.end()) 318 { 319 aIter->second->clear(_bDispose); 320 aIter->second->release(); 321 ::rtl::OUString sKeyValue = aIter->first; 322 ++aIter; 323 m_aPools.erase(sKeyValue); 324 } 325 } 326 // ----------------------------------------------------------------------------- 327 OConnectionPool* OPoolCollection::getConnectionPool(const ::rtl::OUString& _sImplName, 328 const Reference< XDriver >& _xDriver, 329 const Reference< XInterface >& _xDriverNode) 330 { 331 OConnectionPool *pRet = 0; 332 OConnectionPools::const_iterator aFind = m_aPools.find(_sImplName); 333 if (aFind != m_aPools.end()) 334 pRet = aFind->second; 335 else if (_xDriver.is() && _xDriverNode.is()) 336 { 337 Reference<XPropertySet> xProp(_xDriverNode,UNO_QUERY); 338 if(xProp.is()) 339 xProp->addPropertyChangeListener(getEnableNodeName(),this); 340 OConnectionPool* pConnectionPool = new OConnectionPool(_xDriver,_xDriverNode,m_xProxyFactory); 341 pConnectionPool->acquire(); 342 aFind = m_aPools.insert(OConnectionPools::value_type(_sImplName,pConnectionPool)).first; 343 pRet = aFind->second; 344 } 345 346 OSL_ENSURE(pRet, "Could not query DriverManager from ConnectionPool!"); 347 348 return pRet; 349 } 350 // ----------------------------------------------------------------------------- 351 Reference< XInterface > OPoolCollection::createWithServiceFactory(const ::rtl::OUString& _rPath) const 352 { 353 Reference< XInterface > xInterface; 354 try 355 { 356 Reference< XInterface > xProvider = m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))); 357 OSL_ENSURE(xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: could not instantiate the config provider service!"); 358 Reference< XMultiServiceFactory > xProviderAsFac(xProvider, UNO_QUERY); 359 OSL_ENSURE(xProviderAsFac.is() || !xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: the provider is missing an interface!"); 360 if (xProviderAsFac.is()) 361 xInterface = createWithProvider(xProviderAsFac, _rPath); 362 } 363 catch(const Exception&) 364 { 365 OSL_ENSURE(sal_False, "createWithServiceFactory: error while instantiating the provider service!"); 366 } 367 return xInterface; 368 } 369 //------------------------------------------------------------------------ 370 Reference< XInterface > OPoolCollection::createWithProvider(const Reference< XMultiServiceFactory >& _rxConfProvider, 371 const ::rtl::OUString& _rPath) const 372 { 373 OSL_ENSURE(_rxConfProvider.is(), "createWithProvider: invalid provider!"); 374 375 Reference< XInterface > xInterface; 376 #ifdef DBG_UTIL 377 if (_rxConfProvider.is()) 378 { 379 try 380 { 381 Reference< XServiceInfo > xSI(_rxConfProvider, UNO_QUERY); 382 if (!xSI.is()) 383 { 384 OSL_ENSURE(sal_False, "::createWithProvider: no XServiceInfo interface on the provider!"); 385 } 386 else 387 { 388 OSL_ENSURE(xSI->supportsService(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), 389 "::createWithProvider: sure this is a provider? Missing the ConfigurationProvider service!"); 390 } 391 } 392 catch(const Exception&) 393 { 394 OSL_ENSURE(sal_False, "::createWithProvider: unable to check the service conformance of the provider given!"); 395 } 396 } 397 #endif 398 399 if (_rxConfProvider.is()) 400 { 401 try 402 { 403 Sequence< Any > aCreationArgs(3); 404 aCreationArgs[0] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), 0, makeAny(_rPath), PropertyState_DIRECT_VALUE)); 405 aCreationArgs[1] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")), 0, makeAny((sal_Int32)-1), PropertyState_DIRECT_VALUE)); 406 aCreationArgs[2] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lazywrite")), 0, makeAny(sal_True), PropertyState_DIRECT_VALUE)); 407 408 static ::rtl::OUString sAccessService = ::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"); 409 410 xInterface = _rxConfProvider->createInstanceWithArguments(sAccessService, aCreationArgs); 411 OSL_ENSURE(xInterface.is(), "::createWithProvider: could not create the node access!"); 412 } 413 catch(Exception&) 414 { 415 OSL_ENSURE(sal_False, "OConfigurationTreeRoot::createWithProvider: caught an exception while creating the access object!"); 416 } 417 } 418 return xInterface; 419 } 420 // ----------------------------------------------------------------------------- 421 Reference<XInterface> OPoolCollection::openNode(const ::rtl::OUString& _rPath,const Reference<XInterface>& _xTreeNode) const throw() 422 { 423 Reference< XHierarchicalNameAccess > xHierarchyAccess(_xTreeNode, UNO_QUERY); 424 Reference< XNameAccess > xDirectAccess(_xTreeNode, UNO_QUERY); 425 Reference< XInterface > xNode; 426 427 try 428 { 429 if (xDirectAccess.is() && xDirectAccess->hasByName(_rPath)) 430 { 431 if (!::cppu::extractInterface(xNode, xDirectAccess->getByName(_rPath))) 432 OSL_ENSURE(sal_False, "OConfigurationNode::openNode: could not open the node!"); 433 } 434 else if (xHierarchyAccess.is()) 435 { 436 if (!::cppu::extractInterface(xNode, xHierarchyAccess->getByHierarchicalName(_rPath))) 437 OSL_ENSURE(sal_False, "OConfigurationNode::openNode: could not open the node!"); 438 } 439 440 } 441 catch(const NoSuchElementException&) 442 { 443 OSL_ENSURE(sal_False, 444 ::rtl::OString("::openNode: there is no element named ") 445 += ::rtl::OString(_rPath.getStr(), _rPath.getLength(), RTL_TEXTENCODING_ASCII_US) 446 += ::rtl::OString("!")); 447 } 448 catch(Exception&) 449 { 450 OSL_ENSURE(sal_False, "OConfigurationNode::openNode: caught an exception while retrieving the node!"); 451 } 452 return xNode; 453 } 454 // ----------------------------------------------------------------------------- 455 Any OPoolCollection::getNodeValue(const ::rtl::OUString& _rPath,const Reference<XInterface>& _xTreeNode) throw() 456 { 457 Reference< XHierarchicalNameAccess > xHierarchyAccess(_xTreeNode, UNO_QUERY); 458 Reference< XNameAccess > xDirectAccess(_xTreeNode, UNO_QUERY); 459 Any aReturn; 460 try 461 { 462 if (xDirectAccess.is() && xDirectAccess->hasByName(_rPath) ) 463 { 464 aReturn = xDirectAccess->getByName(_rPath); 465 } 466 else if (xHierarchyAccess.is()) 467 { 468 aReturn = xHierarchyAccess->getByHierarchicalName(_rPath); 469 } 470 } 471 catch(NoSuchElementException& e) 472 { 473 OSL_UNUSED( e ); // make compiler happy 474 OSL_ENSURE(sal_False, 475 ::rtl::OString("::getNodeValue: caught a NoSuchElementException while trying to open ") 476 += ::rtl::OString(e.Message.getStr(), e.Message.getLength(), RTL_TEXTENCODING_ASCII_US) 477 += ::rtl::OString("!")); 478 } 479 return aReturn; 480 } 481 // ----------------------------------------------------------------------------- 482 void SAL_CALL OPoolCollection::queryTermination( const EventObject& /*Event*/ ) throw (::com::sun::star::frame::TerminationVetoException, RuntimeException) 483 { 484 } 485 // ----------------------------------------------------------------------------- 486 void SAL_CALL OPoolCollection::notifyTermination( const EventObject& /*Event*/ ) throw (RuntimeException) 487 { 488 clearDesktop(); 489 } 490 // ----------------------------------------------------------------------------- 491 void SAL_CALL OPoolCollection::disposing( const EventObject& Source ) throw (RuntimeException) 492 { 493 MutexGuard aGuard(m_aMutex); 494 if ( m_xDesktop == Source.Source ) 495 { 496 clearDesktop(); 497 } 498 else 499 { 500 try 501 { 502 Reference<XPropertySet> xProp(Source.Source,UNO_QUERY); 503 if(Source.Source == m_xConfigNode) 504 { 505 if ( xProp.is() ) 506 xProp->removePropertyChangeListener(getEnablePoolingNodeName(),this); 507 m_xConfigNode.clear(); 508 } 509 else if ( xProp.is() ) 510 xProp->removePropertyChangeListener(getEnableNodeName(),this); 511 } 512 catch(const Exception&) 513 { 514 OSL_ENSURE(0,"Exception caught"); 515 } 516 } 517 } 518 // ----------------------------------------------------------------------------- 519 void SAL_CALL OPoolCollection::propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (RuntimeException) 520 { 521 MutexGuard aGuard(m_aMutex); 522 if(evt.Source == m_xConfigNode) 523 { 524 sal_Bool bEnabled = sal_True; 525 evt.NewValue >>= bEnabled; 526 if(!bEnabled ) 527 { 528 m_aDriverProxies.clear(); 529 m_aDriverProxies = MapDriver2DriverRef(); 530 OConnectionPools::iterator aIter = m_aPools.begin(); 531 for(;aIter != m_aPools.end();++aIter) 532 { 533 aIter->second->clear(sal_False); 534 aIter->second->release(); 535 } 536 m_aPools.clear(); 537 m_aPools = OConnectionPools(); 538 } 539 } 540 else if(evt.Source.is()) 541 { 542 sal_Bool bEnabled = sal_True; 543 evt.NewValue >>= bEnabled; 544 if(!bEnabled) 545 { 546 ::rtl::OUString sThisDriverName; 547 getNodeValue(getDriverNameNodeName(),evt.Source) >>= sThisDriverName; 548 // 1nd relase the driver 549 // look if we already have a proxy for this driver 550 MapDriver2DriverRefIterator aLookup = m_aDriverProxies.begin(); 551 while( aLookup != m_aDriverProxies.end()) 552 { 553 MapDriver2DriverRefIterator aFind = aLookup; 554 Reference<XServiceInfo> xInfo(aLookup->first,UNO_QUERY); 555 ++aLookup; 556 if(xInfo.is() && xInfo->getImplementationName() == sThisDriverName) 557 m_aDriverProxies.erase(aFind); 558 } 559 560 // 2nd clear the connectionpool 561 OConnectionPools::iterator aFind = m_aPools.find(sThisDriverName); 562 if(aFind != m_aPools.end() && aFind->second) 563 { 564 aFind->second->clear(sal_False); 565 aFind->second->release(); 566 m_aPools.erase(aFind); 567 } 568 } 569 } 570 } 571 // ----------------------------------------------------------------------------- 572 void OPoolCollection::clearDesktop() 573 { 574 clearConnectionPools(sal_True); 575 if ( m_xDesktop.is() ) 576 m_xDesktop->removeTerminateListener(this); 577 m_xDesktop.clear(); 578 } 579 // ----------------------------------------------------------------------------- 580 581 582