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